c++ - Bluetooth Low Energy on Windows
i wanted write program receiving data every 10ms on bluetooth low energy.
i lot of things work, have 1 problem , can´t find source. here basis of code written in c++builder 10 on windows 10.
> //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #define characteristic_uuid "{6e400003-b5a3-f393-e0a9-e50e24dcca9e}" #define service_uuid "{6e400001-b5a3-f393-e0a9-e50e24dcca9e}" #pragma resource "*.dfm" tform1 *form1; tbluetoothledevice* device; tbluetoothgattcharacteristiclist* characteristic ; //--------------------------------------------------------------------------- __fastcall tform1::tform1(tcomponent* owner) : tform(owner) { bluetoothle1->discoverdevices(100); } //--------------------------------------------------------------------------- void __fastcall tform1::bluetoothle1enddiscoverdevices(tobject * const sender, tbluetoothledevicelist * const adevicelist) { device = adevicelist->first(); bluetoothle1->discoverservices(device); } //--------------------------------------------------------------------------- void __fastcall tform1::bluetoothle1servicesdiscovered(tobject * const sender, tbluetoothgattservicelist * const aservicelist) { guid aguid; clsidfromstring(text(service_uuid), &aguid); tbluetoothgattservice* service = bluetoothle1->getservice(device,aguid); //tbluetoothgattservicelist* abcd = bluetoothle1->getservices(device); clsidfromstring(text(characteristic_uuid), &aguid); characteristic = bluetoothle1->getcharacteristics(service); while(characteristic->first()->uuid != aguid) { characteristic->delete(0); } if(characteristic->first()!= null); bluetoothle1->subscribetocharacteristic(device,characteristic->first()); } //--------------------------------------------------------------------------- void __fastcall tform1::bluetoothle1characteristicread(tobject * const sender, tbluetoothgattcharacteristic * const acharacteristic, tbluetoothgattstatus agattstatus) { static long i; label1->caption = i; i++; } //---------------------------------------------------------------------------
after 86303 notifys (calling bluetoothle1characteristicread) stack overflow. there must wrong. @ beginning wrote program in visual studio in c++ windows drivers functions, same thing.
i have found problem. bug in win32 bluetooth apis. windows update kb3156421 every program crashes after 1 notification , mircosoft gives workaround. link
that workaround fixes problem above too.
Comments
Post a Comment