The scanner works like this:
When creating a scanner, you need to specify the type of device to search. It can be either one device or several. Here is example for one type of devices - BrainBit.
SensorFamily filter[] = {
SensorFamily::SensorLEBrainBit
};
OpStatus st;
auto scanner = createScanner(filter, sizeof(filter), &st);
Scanner scanner = new Scanner(SensorFamily.SensorLEBrainBit);
var scanner = Scanner( SensorFamily.SensorLEBrainBit)
Scanner scanner = new Scanner(SensorFamily.SensorLEBrainBit);
var scanner = new Scanner()
await scanner.init([SensorFamily.LEBrainBit])
scanner = Scanner([SensorFamily.LEBrainBit])
var scanner = NTScanner(sensorFamily: [NTSensorFamily.leBrainBit.rawValue])
NTScanner* scanner = [[NTScanner alloc] initWithSensorFamily:@[@(NTSensorFamilyLEBrainBit)]];
Scanner sc = await Scanner.create([SensorFamily.leBrainBit]);
You need to use the following device types to search:
|Sensor family | Description |
|--|--|
|SensorLEBrainBit |BrainBit device|
|SensorLEBrainBit2 |BrainBit2 device|
|SensorLEBrainBitPro |BrainBit2 Pro device|
|SensorLEBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
|Sensor family | Description |
|--|--|
|SensorLEBrainBit |BrainBit device|
|SensorLEBrainBit2 |BrainBit2 device|
|SensorLEBrainBitPro |BrainBit2 Pro device|
|SensorLEBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
|Sensor family | Description |
|--|--|
|SensorLEBrainBit |BrainBit device|
|SensorLEBrainBit2 |BrainBit2 device|
|SensorLEBrainBitPro |BrainBit2 Pro device|
|SensorLEBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
|Sensor family | Description |
|--|--|
|SensorLEBrainBit |BrainBit device|
|SensorLEBrainBit2 |BrainBit2 device|
|SensorLEBrainBitPro |BrainBit2 Pro device|
|SensorLEBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
|Sensor family | Description |
|--|--|
|LEBrainBit |BrainBit device|
|LEBrainBit2 |BrainBit2 device|
|LEBrainBitPro |BrainBit2 Pro device|
|LEBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
|Sensor family | Description |
|--|--|
|LEBrainBit |BrainBit device|
|LEBrainBit2 |BrainBit2 device|
|LEBrainBitPro |BrainBit2 Pro device|
|LEBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
|Sensor family | Description |
|--|--|
|leBrainBit |BrainBit device|
|leBrainBit2 |BrainBit2 device|
|leBrainBitPro |BrainBit2 Pro device|
|leBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
|Sensor family | Description |
|--|--|
|NTSensorFamilyLEBrainBit |BrainBit device|
|NTSensorFamilyLEBrainBit2 |BrainBit2 device|
|NTSensorFamilyLEBrainBitPro |BrainBit2 Pro device|
|NTSensorFamilyLEBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
|Sensor family | Description |
|--|--|
|leBrainBit |BrainBit device|
|leBrainBit2 |BrainBit2 device|
|leBrainBitPro |BrainBit2 Pro device|
|leBrainBitFlex |BrainBit Flex4 / BrainBit Flex8|
void sensorsCallback(SensorScanner* ptr, SensorInfo* sensors, int32_t szSensors, void* userData){
}
...
OpStatus st;
SensorsListenerHandle lHandle = nullptr;
addSensorsCallbackScanner(scanner, sensorsCallback, &lHandle, nullptr, &st);
scanner.sensorsChanged = (scanner, sensors) -> {
sensors.forEach(sensorInfo -> Log.i("TAG", sensorInfo.getName() + ": " + sensorInfo.getAddress()));
};
...
scanner.sensorsChanged = null;
scanner?.sensorsChanged = Scanner.ScannerCallback { scanner, sensors ->
sensors.forEach { sensorInfo -> Log.i("TAG", sensorInfo.name+ ": " + sensorInfo.address) }
}
...
scanner.sensorsChanged = null
private void Scanner_Founded(IScanner scanner, IReadOnlyList<SensorInfo> sensors)
{
foreach(SensorInfo sensorInfo in sensors){
Console.WriteLine(sensorInfo.Name + ": " + sensorInfo.Address);
}
}
scanner.EventSensorsChanged += Scanner_Founded;
...
scanner.EventSensorsChanged -= Scanner_Founded;
scanner.AddSensorListChanged(sensorFounded => {
console.log(sensorFounded)
});
...
scanner.RemoveSensorListChanged();
def sensorFound(scanner, sensors):
for i in range(len(sensors)):
print('Sensor %s' % sensors[i])
scanner.sensorsChanged = sensorFound
...
scanner.sensorsChanged = None
scanner?.setSensorsCallback({ sensors in
for info in sensors{
print(info.name)
}
})
...
scanner?.setSensorsCallback(nil)
[scanner setSensorsCallback:^(NSArray<NTSensorInfo *> * _Nonnull sensors) {
for (NTSensorInfo* info in sensors) {
NSLog(@"Founded %@", info.Name);
}
}];
...
[scanner setSensorsCallback:nil];
StreamSubscription<List<SensorInfo>>? scannerSubscription = scanner.sensorsStream.listen((foundedSensors) {
for (SensorInfo info in foundedSensors) {
print("${info.name}");
}
});
// remove subscription after use
scannerSubscription.cancel();
OpStatus outStatus;
startScanner(scanner, &outStatus);
scanner.start();
scanner.start();
scanner.Start();
scanner.Start()
scanner.start()
scanner?.startScan()
[scanner startScan];
await scanner.start();
OpStatus outStatus;
stopScanner(scanner, &outStatus);
scanner.stop();
scanner.stop();
scanner.Stop();
scanner.Stop()
scanner.stop()
scanner?.stopScan()
[scanner stopScan];
await scanner.stop();
int32_t szSensorsInOut = 32;
SensorInfo* sensors = new SensorInfo[szSensorsInOut];
OpStatus outStatus;
sensorsScanner(scanner, sensors, &szSensorsInOut, &outStatus);
List<SensorInfo> sensors = scanner.getSensors();
var sensors: List<SensorInfo>? = scanner.sensors
IReadOnlyList<SensorInfo> sensors = scanner.Sensors;
var sensors = await scanner.Sensors()
sensors = scanner.sensors()
var sensors = scanner?.sensors
NSArray<NTSensorInfo*>* sensors = scanner.sensors;
List<SensorInfo?> sensors = await scanner.getSensors();
`SensorInfo` contains information about device:
| Field | Type | Description |
|--|--|--|
|SensFamily|SensorFamily|type of device|
|SensModel|uint8_t|numerical value of the device model|
|Name|char[SENSOR_NAME_LEN]|the name of device|
|Address|char [SENSOR_ADR_LEN]|MAC address of device (UUID for iOS/MacOS)|
|SerialNumber|char [SENSOR_SN_LEN]|device's serial number|
|PairingRequired|uint8_t|whether the device needs to be paired or not|
|RSSI|int16_t|current signal strength in dBm. The valid range is [-127, 126]|
| Field | Type | Description |
|--|--|--|
|Name|String|the name of device|
|Address|String|MAC address of device (UUID for iOS/MacOS)|
|SerialNumber|String|device's serial number|
|SensFamily|SensorFamily|type of device|
|SensModel|int|numerical value of the device model|
|PairingRequired|byte|whether the device needs to be paired or not|
|RSSI|short|current signal strength in dBm. The valid range is [-127, 126]|
| Field | Type | Description |
|--|--|--|
|name|String!|the name of device|
|address|String!|MAC address of device (UUID for iOS/MacOS)|
|serialNumber|String!|device's serial number|
|sensFamily|SensorFamily!|type of device|
|sensModel|Int|numerical value of the device model|
|pairingRequired|Byte|whether the device needs to be paired or not|
|RSSI|Short|current signal strength in dBm. The valid range is [-127, 126]|
| Field | Type | Description |
|--|--|--|
|Name|string|the name of device|
|Address|string|MAC address of device (UUID for iOS/MacOS)|
|SerialNumber|string|device's serial number|
|SensFamily|SensorFamily|type of device|
|SensModel|byte|numerical value of the device model|
|PairingRequired|bool|whether the device needs to be paired or not|
|RSSI|short|current signal strength in dBm. The valid range is [-127, 126]|
| Field | Type | Description |
|--|--|--|
|Name|string|the name of device|
|Address|string|MAC address of device (UUID for iOS/MacOS)|
|SerialNumber|string|device's serial number|
|SensFamily|SensorFamily|type of device|
|SensModel|number|numerical value of the device model|
|PairingRequired|boolean|whether the device needs to be paired or not|
|RSSI|number|current signal strength in dBm. The valid range is [-127, 126]|
| Field | Type | Description |
|--|--|--|
|Name|str|the name of device|
|Address|str|MAC address of device (UUID for iOS/MacOS)|
|SerialNumber|str|device's serial number|
|SensFamily|SensorFamily|type of device|
|SensModel|int|numerical value of the device model|
|PairingRequired|bool|whether the device needs to be paired or not|
|RSSI|int|current signal strength in dBm. The valid range is [-127, 126]|
| Field | Type | Description |
|--|--|--|
|name|String?|the name of device|
|address|String?|MAC address of device (UUID for iOS/MacOS)|
|serialNumber|String?|device's serial number|
|sensFamily|NTSensorFamily?|type of device|
|sensModel|UInt8?|numerical value of the device model|
|PairingRequired|Bool?|whether the device needs to be paired or not|
|rssi|Int16?|current signal strength in dBm. The valid range is [-127, 126]|
| Field | Type | Description |
|--|--|--|
|Name|NSString *_Nonnull|the name of device|
|Address|NSString *_Nonnull|MAC address of device (UUID for iOS/MacOS)|
|SerialNumber|NSString *_Nonnull|device's serial number|
|SensFamily|enum NTSensorFamily|type of device|
|SensModel|UInt8|numerical value of the device model|
|PairingRequired|BOOL|whether the device needs to be paired or not|
|RSSI|SInt16|current signal strength in dBm. The valid range is [-127, 126]|
| Field | Type | Description |
|--|--|--|
|name|String|the name of device|
|address|String|MAC address of device (UUID for iOS/MacOS)|
|serialNumber|String|device's serial number|
|sensFamily|SensorFamily|type of device|
|sensModel|int|numerical value of the device model|
|PairingRequired|bool|whether the device needs to be paired or not|
|rssi|int|current signal strength in dBm. The valid range is [-127, 126]|
freeScanner(scanner);
scanner.close();
scanner.close()
scanner.Dispose();
scanner.Close();
del scanner
scanner = nil
scanner = nil;
scanner.dispose();
Important! When restarting the search, the callback will only be called when a new device is found. If you need to get all devices found by the current scanner instance, call the appropriate method.