Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Use Bluetooth Devices in Local Service


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: May 15, 2017 12:35 AM Last Post By: Arnaldo Caliari
Arnaldo Caliari

Posts: 5
Registered: 9/28/12
Use Bluetooth Devices in Local Service  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 14, 2017 5:38 AM
I need / want to use BLE devices in a local Android service. The service reads devices data, and write the values to a file. I'm using 10.1 Berlin, and Android Lollipop.

I've tried, i have workarounded some little problems, and after digging and debugged the system units i've found that System.Bluetooth.Components and System.Android.Bluetooth are full of "Thread.Synchronize" instructions, like

procedure TBluetoothLE.DoOnEndDiscoverDevices(const Sender: TObject; const ADeviceList: TBluetoothLEDeviceList);
begin
  if FEnabled and Assigned(FOnEndDiscoverDevices) then
    TThread.Synchronize(nil, procedure begin
      if FEnabled and Assigned(FOnEndDiscoverDevices) then
          FOnEndDiscoverDevices(Sender, ADeviceList);
    end);
end;


or

 
procedure TBluetoothLE.DoConnectedDevice(const Sender: TObject; const ADevice: TBluetoothLEDevice);
begin
  if FEnabled and Assigned(FOnConnectedDevice) then
    TThread.Synchronize(nil, procedure begin
      if FEnabled and Assigned(FOnConnectedDevice) then
        FOnConnectedDevice(Sender, ADevice);
    end);
end;


Ok, if i understand well, the general need for a Synchronize is for the use of bluetooth components in an app, when from an event you can show sometingh on UI. Those Synchronize instructions lock my service during the scan / discovery of devices.

So, i've tried to copy / paste / modify those units, to delete all the synchronize instructions (i use these new units in a service, so i know that i don't use a UI and [if i'm not wrong] i don't need a Synchronize), and the discover of BLE devices now works. Great result, i was thinking of having a beer to celebrate, but....

All the BLE devices sources in GetIt Package Manager (HRM's, SCS's, ecc..) have in Uses list a reference to Iot.Family.BluetoothLE, Iot.Family.BluetoothLE.GattTypes, and these system units in berlin are installed without sources. I'can't do my version of these units, to make them use my versions of System.Bluetooth.Components and System.Android.Bluetooth.

For example, i can modify the Iot.Device.PolarHeartRateMonitor unit to use my modified System.MyBluetooth (where i deleted all references to Synchronize), but i can't modify the reference to Iot.Family.BluetoothLE, because i can't make "my version" of Iot.Family.BluetoothLE.

And now, i'm stuck in this situation. Any idea ?

Thanks to all !!

Edited by: Arnaldo Caliari on May 14, 2017 2:38 PM
Arnaldo Caliari

Posts: 5
Registered: 9/28/12
Re: Use Bluetooth Devices in Local Service  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 15, 2017 12:35 AM   in response to: Arnaldo Caliari in response to: Arnaldo Caliari
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02