Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: Can't get Services from BluetoothLE Device (10.2)


This question is answered.


Permlink Replies: 4 - Last Post: Jul 6, 2017 12:50 PM Last Post By: Scott Pinkham
Aaron McNeil

Posts: 8
Registered: 5/13/17
Can't get Services from BluetoothLE Device (10.2)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2017 8:17 AM
After I successfully discover the BlutoothLE device I am looking for, I use the following code to get the services:

if BluetoothLE1.GetServices(BLEDevice).Count = 0 then begin
Memo.Lines.Add('No Services Found!');
end else begin
Memo.Lines.Add('UART Services Found: ' + IntToStr(BLuetoothLE1.GetServices(BLEDevice).Count));
GetServiceAndCharacteristics;
end;

The statement always gives me the "No services found" line. I have an app that came with the device where I can see the device and services, so I know the device itself is working properly. Any ideas what could be going on here?

Edited by: Aaron McNeil on Jun 30, 2017 8:25 AM
Scott Pinkham

Posts: 54
Registered: 3/19/07
Re: Can't get Services from BluetoothLE Device (10.2)
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2017 9:53 AM   in response to: Aaron McNeil in response to: Aaron McNeil
Aaron McNeil wrote:
After I successfully discover the BlutoothLE device I am looking for, I use the following code to get the services:

if BluetoothLE1.GetServices(BLEDevice).Count = 0 then begin
Memo.Lines.Add('No Services Found!');
end else begin
Memo.Lines.Add('UART Services Found: ' + IntToStr(BLuetoothLE1.GetServices(BLEDevice).Count));
GetServiceAndCharacteristics;
end;

The statement always gives me the "No services found" line. I have an app that came with the device where I can see the device and services, so I know the device itself is working properly. Any ideas what could be going on here?

Edited by: Aaron McNeil on Jun 30, 2017 8:25 AM

What platform are you using? Be aware that Windows has a lot of limitations when it comes to BLE.
I've been doing a lot of work with BLE lately on all platforms and can try to help you. I don't think GetServices works with BLE. The way I do it is like this (using the TBluetoothLEManager object):
1. Use StartDiscovery to enumerate the available devices -- the OnDiscoveryEnd event will give you a list of devices.
2. Find the device you want to connect to in the list of available devices (the LastDiscoveredDevices property can also be used), and call its DiscoverServices() method, which will generate a DeviceServicesDiscovered event.
3. The DeviceServicesDiscovered event gives you a list of the available services for the device.

Hope this helps.
Aaron McNeil

Posts: 8
Registered: 5/13/17
Re: Can't get Services from BluetoothLE Device (10.2)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2017 10:00 AM   in response to: Scott Pinkham in response to: Scott Pinkham
Scott Pinkham wrote:
Aaron McNeil wrote:
After I successfully discover the BlutoothLE device I am looking for, I use the following code to get the services:

if BluetoothLE1.GetServices(BLEDevice).Count = 0 then begin
Memo.Lines.Add('No Services Found!');
end else begin
Memo.Lines.Add('UART Services Found: ' + IntToStr(BLuetoothLE1.GetServices(BLEDevice).Count));
GetServiceAndCharacteristics;
end;

The statement always gives me the "No services found" line. I have an app that came with the device where I can see the device and services, so I know the device itself is working properly. Any ideas what could be going on here?

Edited by: Aaron McNeil on Jun 30, 2017 8:25 AM

What platform are you using? Be aware that Windows has a lot of limitations when it comes to BLE.
I've been doing a lot of work with BLE lately on all platforms and can try to help you. I don't think GetServices works with BLE. The way I do it is like this (using the TBluetoothLEManager object):
1. Use StartDiscovery to enumerate the available devices -- the OnDiscoveryEnd event will give you a list of devices.
2. Find the device you want to connect to in the list of available devices (the LastDiscoveredDevices property can also be used), and call its DiscoverServices() method, which will generate a DeviceServicesDiscovered event.
3. The DeviceServicesDiscovered event gives you a list of the available services for the device.

Hope this helps.

Thank you! This solution worked for me. I am using it on the iOS platform.
Aaron McNeil

Posts: 8
Registered: 5/13/17
Re: Can't get Services from BluetoothLE Device (10.2)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2017 10:16 AM   in response to: Scott Pinkham in response to: Scott Pinkham
Scott Pinkham wrote:
Aaron McNeil wrote:
After I successfully discover the BlutoothLE device I am looking for, I use the following code to get the services:

if BluetoothLE1.GetServices(BLEDevice).Count = 0 then begin
Memo.Lines.Add('No Services Found!');
end else begin
Memo.Lines.Add('UART Services Found: ' + IntToStr(BLuetoothLE1.GetServices(BLEDevice).Count));
GetServiceAndCharacteristics;
end;

The statement always gives me the "No services found" line. I have an app that came with the device where I can see the device and services, so I know the device itself is working properly. Any ideas what could be going on here?

Edited by: Aaron McNeil on Jun 30, 2017 8:25 AM

What platform are you using? Be aware that Windows has a lot of limitations when it comes to BLE.
I've been doing a lot of work with BLE lately on all platforms and can try to help you. I don't think GetServices works with BLE. The way I do it is like this (using the TBluetoothLEManager object):
1. Use StartDiscovery to enumerate the available devices -- the OnDiscoveryEnd event will give you a list of devices.
2. Find the device you want to connect to in the list of available devices (the LastDiscoveredDevices property can also be used), and call its DiscoverServices() method, which will generate a DeviceServicesDiscovered event.
3. The DeviceServicesDiscovered event gives you a list of the available services for the device.

Hope this helps.

Maybe you can help with my next problem. Now when I get my list of characteristics and try to read or write to any of them I am getting an access violation. I am using iOS. Is there something I should be doing before I can read or write to a characteristic? I tried SubscribeToCharacteristic() to no avail.

Thanks in advance.
Scott Pinkham

Posts: 54
Registered: 3/19/07
Re: Can't get Services from BluetoothLE Device (10.2)  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 6, 2017 12:50 PM   in response to: Aaron McNeil in response to: Aaron McNeil
Aaron McNeil wrote:
Scott Pinkham wrote:
Aaron McNeil wrote:
After I successfully discover the BlutoothLE device I am looking for, I use the following code to get the services:

if BluetoothLE1.GetServices(BLEDevice).Count = 0 then begin
Memo.Lines.Add('No Services Found!');
end else begin
Memo.Lines.Add('UART Services Found: ' + IntToStr(BLuetoothLE1.GetServices(BLEDevice).Count));
GetServiceAndCharacteristics;
end;

The statement always gives me the "No services found" line. I have an app that came with the device where I can see the device and services, so I know the device itself is working properly. Any ideas what could be going on here?

Edited by: Aaron McNeil on Jun 30, 2017 8:25 AM

What platform are you using? Be aware that Windows has a lot of limitations when it comes to BLE.
I've been doing a lot of work with BLE lately on all platforms and can try to help you. I don't think GetServices works with BLE. The way I do it is like this (using the TBluetoothLEManager object):
1. Use StartDiscovery to enumerate the available devices -- the OnDiscoveryEnd event will give you a list of devices.
2. Find the device you want to connect to in the list of available devices (the LastDiscoveredDevices property can also be used), and call its DiscoverServices() method, which will generate a DeviceServicesDiscovered event.
3. The DeviceServicesDiscovered event gives you a list of the available services for the device.

Hope this helps.

Maybe you can help with my next problem. Now when I get my list of characteristics and try to read or write to any of them I am getting an access violation. I am using iOS. Is there something I should be doing before I can read or write to a characteristic? I tried SubscribeToCharacteristic() to no avail.

Thanks in advance.

Aaron -

Without seeing some code, I may not be able to offer much help. One thing I can tell you to watch out for is that some of the BluetoothLE events occur on a background thread, NOT on the main thread, so if you access anything on the main GUI thread you'll need to use TThread.Synchronize(). SubscribeToCharacteristic only works on characteristics that support it. I use the ExploreDevicesLE example app to find out what characteristics the device supports, and if they support reads/writes and subscriptions. I use it on a Mac since OSX supports BluetoothLE much better than Windows does. There are also some good Bluetooth diagnostic apps on the Play store (there are a few on the Apple store as well, but I haven't tried them).
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02