manufacturer-specific
central := adapter.central
device := find_by_name central DEV_NAME
print device.data.raw
identifier := device.identifier
remote_device := central.connect identifier
print "Address: $remote_device.identifier"
find_by_name central/ble.Central name/string:
central.scan --duration=SCAN_DURATION: | device/ble.RemoteScannedDevice |
if device.identifier and device.data.name == name:
return device
throw "no ring device found"
ble-scan-next_ central-manager:
#primitive.ble.scan-next
(venv) ?1 circul % jag run -d host ble_scan.toit
Class 'DataBlock' does not have any method 'hash-code'.
0: HashedInsertionOrderedCollection_.hash-code_ <sdk>/core/collections.toit:2188:16
1: HashedInsertionOrderedCollection_.find_ <sdk>/core/collections.toit:2303:13
2: Set.add <sdk>/core/collections.toit:2565:17
3: Set.add-all.<block> <sdk>/core/collections.toit:2577:20
4: SmallArray_.do_ <sdk>/core/collections.toit:954:3
5: List_.do <sdk>/core/collections.toit:1983:19
6: Set.add-all <sdk>/core/collections.toit:2577:16
7: main.<block> ble_scan.toit:18:12
8: Central.scan.<block> <sdk>/ble/remote.toit:135:9
9: Central.scan <sdk>/ble/remote.toit:74:3
10: main ble_scan.toit:16:11
Error: exit status 1
(venv) ?1 circul %
AD
--active
--.is-scan-response
main:
adapter := ble.Adapter
central := adapter.central
// An active scan may need the responses to be merged.
central.scan --duration=(Duration --s=5) --active: | device/ble.RemoteScannedDevice |
print "$device.is-scan-response $device.rssi"
jag run -d host ble_scan.toit
false -47
false -82
false -48
false -78
false -54
false -76
false -77
false -83
false -91
false -87
false -75
false -61
false -73
false -95
false -88
false -90
false -102
false -98
false -95
[central_manager->central_manager() scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:@"180D"]]
options:@{CBCentralManagerScanOptionAllowDuplicatesKey: @YES}];
ble_darwin.mm
options
// An active scan may need the responses to be merged.
central.scan --duration=(Duration --s=5) --active: | device/ble.RemoteScannedDevice |
print "$device.is-scan-response $device.rssi"
kCBAdvDataManufacturerData
2025-02-12 08:59:07.338 toit.run[24749:1947303] Peripheral: <CBPeripheral: 0x104c05250, identifier = 6EF5B2E2-87AF-477E-D116-B27C6F7EF37E, name = MR, mtu = 0, state = disconnected>
2025-02-12 08:59:07.338 toit.run[24749:1947303] RSSI: -84
2025-02-12 08:59:07.338 toit.run[24749:1947303] Advertisement Data: {
kCBAdvDataIsConnectable = 1;
kCBAdvDataLocalName = MR;
kCBAdvDataManufacturerData = {length = 37, bytes = 0x00002b51 b0233ad1 01010100 00000000 ... 000067ac b73b0000 };
kCBAdvDataRxPrimaryPHY = 129;
kCBAdvDataRxSecondaryPHY = 0;
kCBAdvDataServiceUUIDs = (
FAB1
);
kCBAdvDataTimestamp = "761065147.33799";
}
2025-02-12 08:59:07.339 toit.run[24749:1947303] Peripheral: <CBPeripheral: 0x104c05250, identifier = 6EF5B2E2-87AF-477E-D116-B27C6F7EF37E, name = MR, mtu = 0, state = disconnected>
2025-02-12 08:59:07.339 toit.run[24749:1947303] RSSI: -83
2025-02-12 08:59:07.693 toit.run[24749:1947303] Advertisement Data: {
kCBAdvDataIsConnectable = 1;
kCBAdvDataManufacturerData = {length = 10, bytes = 0x4c001006351e1ab800cd};
kCBAdvDataRxPrimaryPHY = 1;
kCBAdvDataRxSecondaryPHY = 0;
kCBAdvDataTimestamp = "761065147.693242";
kCBAdvDataTxPowerLevel = 12;
}
2025-02-12 09:05:12.713 toit.run[30024:1967859] Advertisement Mnfr Data: {length = 8, bytes = 0x00002b51b0233ad1}
2025-02-12 09:05:12.713 toit.run[30024:1967859] Peripheral: <CBPeripheral: 0x13e706860, identifier = 6EF5B2E2-87AF-477E-D116-B27C6F7EF37E, name = MR, mtu = 0, state = disconnected>
2025-02-12 09:05:12.713 toit.run[30024:1967859] RSSI: -84
false -84
2025-02-12 09:05:12.713 toit.run[30024:1967859] Advertisement Mnfr Data: {length = 37, bytes = 0x00002b51 b0233ad1 01010100 00000000 ... 000067ac b8a90000 }
2025-02-12 09:05:12.713 toit.run[30024:1967859] Peripheral: <CBPeripheral: 0x13e706860, identifier = 6EF5B2E2-87AF-477E-D116-B27C6F7EF37E, name = MR, mtu = 0, state = disconnected>
2025-02-12 09:05:12.713 toit.run[30024:1967859] RSSI: -82
2025-02-12 09:05:12.720 toit.run[30024:1967859] Advertisement Mnfr Data: {length = 6, bytes = 0x4c0012020000}
2025-02-12 09:05:12.720 toit.run[30024:1967859] Peripheral: <CBPeripheral: 0x13e611c90, identifier = 6D78A7EF-B545-7E99-B985-DED0AA52BC29, name = (null), mtu = 0, state = disconnected>
2025-02-12 09:05:12.720 toit.run[30024:1967859] RSSI: -37
false -82