Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.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++ 如何让nrFToolbox for BLE应用程序使用使用ArduinoBLE库编写的Arduino代码?_C++_Arduino_Bluetooth Lowenergy_Android Ble_Arduino Nano - Fatal编程技术网

C++ 如何让nrFToolbox for BLE应用程序使用使用ArduinoBLE库编写的Arduino代码?

C++ 如何让nrFToolbox for BLE应用程序使用使用ArduinoBLE库编写的Arduino代码?,c++,arduino,bluetooth-lowenergy,android-ble,arduino-nano,C++,Arduino,Bluetooth Lowenergy,Android Ble,Arduino Nano,作为参考,我使用的是Arduino Nano 33 BLE感应板 目前,我可以让nrFToolbox应用程序将主板识别为蓝牙设备,但仅此而已。我想能够使用该应用程序获得有关温度的数据并显示出来 #include <Arduino_LPS22HB.h> //Pressure sensor, documentation found on https://www.arduino.cc/en/Reference/ArduinoLPS22HB #include <Arduino_HTS2

作为参考,我使用的是Arduino Nano 33 BLE感应板

目前,我可以让nrFToolbox应用程序将主板识别为蓝牙设备,但仅此而已。我想能够使用该应用程序获得有关温度的数据并显示出来

#include <Arduino_LPS22HB.h> //Pressure sensor, documentation found on https://www.arduino.cc/en/Reference/ArduinoLPS22HB
#include <Arduino_HTS221.h>  //Temperature sensor, documentation found on https://www.arduino.cc/en/Reference/ArduinoHTS221
#include <ArduinoBLE.h>      //Bluetooth LE sensor, documentation found on https://www.arduino.cc/en/Reference/ArduinoBLE


// Service for the BLE module, using a 128-bit UUID.
BLEService TestService("32BC370F-88AF-4928-B8AB-9B56902FA670");

//TODO: BLE temperature characteristic

//TODO: BLE humidity characteristic

//TODO: BLE pressure characteristic

void setup() {
// put your setup code here, to run once:
    Serial.begin(9600); //Initialize the serial connection
    while(!Serial); //Will pause until a serial connection is established.

    if (!BARO.begin() ) { //Initialize the barometer
    Serial.println("Unable to initialize the barometer, stopping.");
    while (1);
    }
    if (!HTS.begin() ) { //Initialize the Temperature & Humidity sensor
        Serial.println("Unable to initialize the temp/humidity sensor, stopping.");
        while (1);
    }
    if (!BLE.begin() ) { //Initialize the bluetooth module
        Serial.println("Unable to initialize the bluetooth module, stopping");
        while (1);
    }


    /* Set a local name for the BLE device
    This name will appear in advertising packets
    and can be used by remote devices to identify this BLE device
    The name can be changed but maybe be truncated based on space left in advertisement packet
    */
    BLE.setLocalName("TestDevice");
    BLE.setAdvertisedService(TestService); // add the service UUID



}

void loop() {
// put your main code here, to run repeatedly:
    Serial.print("Temperature: ");
    Serial.print(HTS.readTemperature(FAHRENHEIT));
    Serial.print(" -- Humidity: ");
    Serial.print(HTS.readHumidity() );
    Serial.print(" -- Pressure: ");
    Serial.println(BARO.readPressure() );
    delay(1000);
}
#包括//压力传感器,可在https://www.arduino.cc/en/Reference/ArduinoLPS22HB
#包括//温度传感器,可在https://www.arduino.cc/en/Reference/ArduinoHTS221
#包括//蓝牙LE传感器,可在上找到文档https://www.arduino.cc/en/Reference/ArduinoBLE
//使用128位UUID为BLE模块提供服务。
BLEService测试服务(“32BC370F-88AF-4928-B8AB-9B56902FA670”);
//TODO:可调温度特性
//TODO:可调湿度特性
//TODO:可调压力特性
无效设置(){
//将安装代码放在此处,以便运行一次:
Serial.begin(9600);//初始化串行连接
而(!Serial);//将暂停,直到建立串行连接。
如果(!BARO.begin()){//初始化气压计
Serial.println(“无法初始化气压计,正在停止”);
而(1),;
}
如果(!HTS.begin()){//初始化温度和湿度传感器
Serial.println(“无法初始化温度/湿度传感器,正在停止”);
而(1),;
}
如果(!BLE.begin()){//初始化蓝牙模块
Serial.println(“无法初始化蓝牙模块,正在停止”);
而(1),;
}
/*为可扩展设备设置本地名称
此名称将出现在广告包中
并可由远程设备用于识别此可扩展设备
该名称可以更改,但可能会根据广告包中剩余的空间而被截断
*/
table.setLocalName(“TestDevice”);
BLE.setAdvertisedService(TestService);//添加服务UUID
}
void循环(){
//将主代码放在此处,以便重复运行:
连续打印(“温度:”);
串行打印(高温超导读数温度(华氏度));
串行打印(“--湿度:”);
Serial.print(HTS.read湿度());
串行打印(“--Pressure:”);
Serial.println(BARO.readPressure());
延迟(1000);
}

我的意思是,我知道它的文档存在(我自己在代码中链接了它),但它对这个问题没有帮助