I'm using Xamarin.iOS to wrote a BLE scanner. I'm interrested in getting the GUID of the device the 2 word associated with it and finally the signal strength to compute the distance between the phone and the BLE beacon. The beacons are using the iBeacon protocol.
Here is the pseudocode I have so far:
if (scanner == null)
{
scanner = new CBCentralManager();
}
if (scanner != null)
{
// FIXME Should I pass null to the first parameter of ScanForPeripherals?
scanner.DiscoveredPeripheral += Scanner_DiscoveredPeripheral;
scanner.ScanForPeripherals(null, new PeripheralScanningOptions { AllowDuplicatesKey = true });
}
private void Scanner_DiscoveredPeripheral(object sender, CBDiscoveredPeripheralEventArgs e)
{
lock (this.visibleBeacons)
{
// FIXME : How do I get the 2 word values and the signal strength?
BeaconInfo discoveredPeripheral = new BeaconInfo(e.Peripheral.Identifier.ToString(), word1, word2, signalStrength);
...
}
}
We never open a session with a beacon to receive data. We only rely on the advertising characteristics (send every 250ms) for our business needs. The 2 16-bit fields are used to told what we need to do when walking near a beacon.
The beacon is programmed with the manufacturer software.