Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Windows上的蓝牙低能量堆栈溢出_C++_Windows_Bluetooth Lowenergy_C++builder - Fatal编程技术网

C++ Windows上的蓝牙低能量堆栈溢出

C++ Windows上的蓝牙低能量堆栈溢出,c++,windows,bluetooth-lowenergy,c++builder,C++,Windows,Bluetooth Lowenergy,C++builder,我想写一个程序,通过蓝牙低能量每10毫秒接收一次数据 我有很多事情要做,但我总是有一个问题,找不到问题的根源。 这是我在Windows10上用C++Builder10编写的代码的基础 > //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //-------------

我想写一个程序,通过蓝牙低能量每10毫秒接收一次数据

我有很多事情要做,但我总是有一个问题,找不到问题的根源。 这是我在Windows10上用C++Builder10编写的代码的基础

> //---------------------------------------------------------------------------

#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++;
}
//---------------------------------------------------------------------------
>//---------------------------------------------------------------------------
#包括
#布拉格语hdrstop
#包括“Unit1.h”
//---------------------------------------------------------------------------
#pragma包(智能初始化)
#定义特性_UUID“{6e400003-b5a3-f393-e0a9-E50E24DCA9E}”
#定义服务UUID“{6e400001-b5a3-f393-e0a9-E50E24DCA9E}”
#pragma资源“*.dfm”
TForm1*Form1;
t蓝牙设备*设备;
t BluetoothGattCharacteristicList*特性;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent*Owner)
:t表格(所有者)
{
蓝牙1->发现设备(100);
}
//---------------------------------------------------------------------------
void _fastcall TForm1::BluetoothLE1EndDiscoverDevices(TObject*const Sender,TBluetoothLEDeviceList*const ADeviceList)
{
device=ADeviceList->First();
蓝牙1->发现服务(设备);
}
//---------------------------------------------------------------------------
void _ufastcall TForm1::BluetoothLe1ServicesDiscoveryd(TObject*常量发送方,TBluetoothGattServiceList*常量AServiceList)
{
GUID AGuid;
CLSIDFromString(文本(服务)和AGuid);
TBluetoothGattService*service=BluetoothLE1->GetService(设备,AGuid);
//TBluetoothGattServiceList*abcd=BluetoothLE1->GetServices(设备);
CLSIDFromString(文本(特征)和AGuid);
特征=蓝牙1->GetCharacteristics(服务);
while(characteristic->First()->UUID!=AGuid)
{
特征->删除(0);
}
如果(特征->第一个()!=NULL);
BluetoothLE1->subscribeTecharacteristic(设备,特征->第一个());
}
//---------------------------------------------------------------------------
void _fastcall TForm1::BluetoothLE1CharacteristicRead(TObject*常量发送器,TBluetoothGattCharacteristic*常量ACharacteristic,
t蓝色牙关状态(状态)
{
静态长i;
标签1->Caption=i;
i++;
}
//---------------------------------------------------------------------------
在86303次NOTIFY(调用BluetoothLE1CharacteristicRead)之后,我得到了一个堆栈溢出。所以一定是出了什么问题。 开始时,我用VisualStudio在C++中用Windows驱动程序函数编写程序,但同样的事情。p> 我发现了问题所在。 这是Win32 Bluetooth API中的一个错误。 使用Windows Update KB3156421,每个程序在一次通知后都会崩溃,Mircosoft提供了一种解决方法

这个解决方法也解决了我上面的问题。

我已经找到了问题。 这是Win32 Bluetooth API中的一个错误。 使用Windows Update KB3156421,每个程序在一次通知后都会崩溃,Mircosoft提供了一种解决方法


这个解决方法也解决了我上面的问题。

编写“堆栈溢出”以区别于堆栈溢出。网站是另一回事:)你检查过实际的堆栈了吗?这通常是堆栈溢出的原因。通常,它上面有一个模式
abcab
,其中一些可能不是您的函数。一个常见的原因是从回调调用库函数,以便库再次调用回调…好的,我注意到现在几乎整个堆栈都充满了这些12字节0x014F3200->.O2。0x005FFF64->.ÿd 0x00000000->。。。。但我怎么才能知道这是什么呢?写“堆栈溢出”来区别于堆栈溢出。网站是另一回事:)你检查过实际的堆栈了吗?这通常是堆栈溢出的原因。通常,它上面有一个模式
abcab
,其中一些可能不是您的函数。一个常见的原因是从回调调用库函数,以便库再次调用回调…好的,我注意到现在几乎整个堆栈都充满了这些12字节0x014F3200->.O2。0x005FFF64->.ÿd 0x00000000->。。。。但我怎样才能知道那是什么呢。