Как мне заставить приложение nrFToolbox для BLE использовать код Arduino, написанный с использованием библиотеки ArduinoBLE?
Для справки я использую плату Arduino Nano 33 BLE Sense.
На данный момент я могу заставить приложение nrFToolbox распознавать плату как устройство Bluetooth, но это все. Я хотел бы использовать приложение для получения данных о температуре и их отображения.
#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);
}