I’m developing a BLE project with an ESP32-SE. I need to change from sending byte characteristics to integer characteristics, but there is an error each time I build with an integer syntax to test. The h file is BLECharacteristic.h
For bytes this works: pTxLBATL->setValue(&Data_LBatVLow, 1);
where Data_LBatVLow is an unsigned byte. In the h file the format is shown as setValue(const uint8_t *data, size_t size);
I can get this to compile with ‘2’ after the comma but as soon as I make an array of 2 bytes for the variable Data_LBatVLow there is an error.
For integers I have tried different combinations, looking at the syntax stated in the h file:
what is the error ? You probably don't need to make it an array.
Typing here without testing, but if you declare the characteristic as a BLECharacteristic with the usual BLE UUID and properties; you can probably just send the integer as bytes using setValue. For example:
The MIT App project receives an open and a closed bracket when the 1234 is sent. I tried changing that number, still the same result.
I set up code to check for bytes and for integers, only the IntegersReceived responds (as I wanted), but not with a number. The received integers go straight into a text label OK, but sending to a slider shows the error
The operation ThumbPosition cannot accept the arguments: ‘ [()]
it's sent in binary - so two bytes 1234 is 0x04D2 so on the receiving end you should get two bytes as part of the payload. The transmission is not an ASCII text.
(its better to post the full code or a minimum code demonstrating what you are doing when you post - that was @sonofcy's ask - as very often the issue is not where you think it is and might be elsewhere in the code).
If it sends bytes, App Inventor does not receives them. But immediately fires the IntegersReceived event. Same response/error no matter what I send. I also checked to see if it receives it as a string but no.
I think in this case the h file is misleading.
Do you think the code that compiles is incorrect for the data? Does it need to be converted to a different form?
The basic idea if anyone else is struggling, is to send an ID/index byte with each data byte. Flag them when received and process when both have been received. More overheads so I’m not totally happy about it.