I have a test app created to simply list all devices found during a "DiscoverDevices" call e.g. BluetoothLE1.DiscoverDevices(60000);
In MacOS and Android, the "OnDiscoverLEDevice" event is called for every receipt of an advertising packet from any given device.
In iOS, it appears that the OnDiscoverLEDevice event is only called on the first received advertising packet from any given device.
Is this the expected behaviour in iOS, or is this something not quite working within the Delphi RTL?
I've tried it with DX10 Seattle and now with DX10.1 Berlin - exactly the same results.
The app has a listview that adds items once (based on making sure any given device identifier is only added to the LV once).
Here's my OnDiscoverLEDevice code:
procedure TForm6.BluetoothLE1DiscoverLEDevice(const Sender: TObject; const ADevice: TBluetoothLEDevice; Rssi: Integer; const ScanResponse: TScanResponse); var Name: string; Ident: string; I: Integer; DCount: Integer; Item: TListViewItem; ndx:Integer; found: Boolean; begin // what happens if a new device is found when this is already running? DCount := BluetoothLE1.DiscoveredDevices.Count; for I := 0 to DCount - 1 do begin // for every BT device in list Name := BluetoothLE1.DiscoveredDevices[I].DeviceName; Ident:= BluetoothLE1.DiscoveredDevices[I].Identifier; if Name = '' then Name := 'Unknown device'; found:=False; // loop through listview looking for matching identifier for ndx := 0 to lvTSX.ItemCount-1 do begin if (lvTSX.Items[ndx].Detail=Ident) then begin lvTSX.BeginUpdate; lvTSX.Items[ndx].Text:=Name+' '+RSSI.tostring; // name might have changed lvTSX.Items[ndx].Tag:=I; lvTSX.EndUpdate; found:=True; Break; end; end; if not found then begin // nothing in the listview yet lvTSX.BeginUpdate; Item := lvTSX.Items.Add; Item.Text := Name+' '+RSSI.tostring; Item.Detail:= Ident; Item.Tag := I; lvTSX.EndUpdate; end; end; end;
In MacOS and Android, the device name shows up with a constantly changing RSSI value.
In iOS, the RSSI value is unchanged (as this event is never triggered more than once per device).
I've tested this with the TI Sensor tag, a Trakr Bravo button, a heart rate monitor, a playbulb, and a HomeBrite "smart LED bulb".
Can anyone confirm that this is expected behaviour in iOS? If so, any suggestions on how I can get "live" capture of advertising data packet within iOS?
TIA.
Cheers,
EdB