Hello, I am using an Arduino to send an integer value between -90 and 90 to an esp32. I am able to read everything fine when I only send a value between 0 and 90 but now things are trickier. In the notifyCallback function, pData is of data type uint8_t, so that means between 0 and 255, right? However, if it was just int8_t, then it would be between -128 and 127 which would be great, but I can't get it to work.
Code: Select all
static void notifyCallback(
BLERemoteCharacteristic* pBLERemoteCharacteristic,
uint8_t* pData, size_t length, bool isNotify)
Is there a way to for notifyCallback to be able to produce a negative number? Or, should I just ignore that function and focus on putting this this line in my main loop?
Code: Select all
std::string value = pRemoteCharacteristic->readValue();
Serial.print("The characteristic value was: ");
Serial.println(value.c_str());
I am having all sorts of problems trying to convert std::string value to an integer that doesn't produce an ascii symbol in my serial monitor. I've tried a few solutions (e.g. atoi(), toInt(), std::stoi(value) ) but I have not had any luck. Does anyone have any insight on how to get BLE_client to read a negative number? Thank you.