1

Im trying to develop a ble application, where a peripheral device (a Ti CC2650LP) reads sensor data via UART and writes them to a characteristic. The central device (a Win 10 PC) reads this characteristic via notification and outputs it in a special software.

My problem is: when I use my test pc everything works fine, but when ich use a different pc with my software i always get the same readings. It seems i cant access the characteristic. Everytime i reconnect the peripheral as a bluetooth device, the reading changes, but the software still only shows this one reading. I can see in my software, that the characteristic gets read but the value doesnt change. I'm pretty sure its a connection issue.

Has anyone had this kind of issue before?

Static
  • 87
  • 8
  • Use ReadFromDevice flag instead of default None or Cache. Especially if your device is paired. – Mike Petrichenko Jul 15 '20 at 08:56
  • @Mike Petrichenko Thank you for the fast answer. I replaced the flag in the BluetoothGATTGetCharacteristicValue function with BLUETOOTH_GATT_FLAG_FORCE_READ_FROM_DEVICE in every use of the function. Now my app doesnt work at all. No Data gets transmitted – Static Jul 15 '20 at 09:15
  • Ah, You use classic (legacy) GATT API. Switch to WinRT one or use third party libraries (www.btframework.com is good enough). – Mike Petrichenko Jul 15 '20 at 09:49
  • @Mike Petrichenko Im new to BLE and i was happy i found a sample code for reading characteristics. do i have to write completely new code with a new GATT API or is it enough to change some calls and functions? – Static Jul 15 '20 at 11:07
  • Unfortunately you have to write completly new code bacuse WinRT BLE API is absolutely different. The problem that on WIndows 10 if device is paired legacy GATT API does not work correctly. The legacy GATT API can be used on old Win 10 builds (early 10240) and on Windows 8. You can save time with Bluetooth Framework that supports legacy GATT API on Windows 8 and new WinRT API on Windows 10. It also supports BlueSoleil Bluetooth drivers that can be used on WIn 7. For better GATT understanding you can take a look on this article: https://www.btframework.com/ble.htm – Mike Petrichenko Jul 15 '20 at 11:14
  • @Mike Petrichenko So, i already have compiled a dll using legacy GATT API and it works on my test PC (win10 V.2004), but not on another Laptop (win10 V.2004). Do you really think that the wrong API is the issue here? – Static Jul 15 '20 at 11:49
  • I do not think that this is the legacy GATT problem. I know that htis is it.Legacy GATT requires pairing. During pairing Windows cache all the services, characteristics and, sometimes, its values. Then it reads it from cache. The other possible problem is that your device has random MAC (that is possible reason of getting error when you use read from device flag). So you must re-pair your device each time when need to connect if you use legacy GATT API. – Mike Petrichenko Jul 15 '20 at 11:53
  • @Mike Petrichenko Ok, I understand that. I actually had to re-pair my device every time i connect it anew. I will definitely look into the new API and try to find samples. One last question: Why does it work well on my test machine? – Static Jul 15 '20 at 12:18
  • Because it can. :) If you take few PCs/laptops it will work on some and will not work on others. Hard to say why because there are few reasons: probably because of debugger, probably because of registry security settings (sometimes it matters cause Windows needs to access to the GATT cache). The logged in user group also matters. – Mike Petrichenko Jul 15 '20 at 12:34
  • @Mike Petrichenko Ok, thanks for your help! – Static Jul 15 '20 at 13:54
  • @Mike I have managed to write new code to read a value, using a newer API, but im getting the same issue as before. I started a new question concerning this: https://stackoverflow.com/questions/63336568/bluetooth-le-characteristic-values-only-read-once It would be nice if you could help me again – Static Aug 10 '20 at 08:24

0 Answers0