- This topic has 1 reply, 2 voices, and was last updated 1 year, 3 months ago by .
- You must be logged in to reply to this topic.
Home › Forums › The libraries hosted on the site › EByte LoRa e220 UART devices LLCC68 › How does receiveInitialMessage return uint8_t?
Hi Renzo
The LoRa_E220::receiveInitialMessage
function returns a char
value, but I would like the returned value to be uint8_t
.
I’m identifying my messages by number:
struct msg_01 {
uint8_t type;
char message[8];
byte temperature[4];
};
struct msg_02 {
uint8_t type;
char txt[10];
byte distance[4];
bool ack;
};
So instead of using a String
as in the provided example:
char type[5]; // first part of structure
ResponseContainer rs = e220ttl.receiveInitialMessage(sizeof(type));
String typeStr = rs.data;
I would use a uint8_t
like this:
uint8_t type; // first part of structure
ResponseContainer rs = e220ttl.receiveInitialMessage(sizeof(type));
uint8_t typeStr = rs.data;
If I change char buff[size];
(line 131 in ‘LoRa_E220.cpp’) to uint8_t buff[size];
, with the aim that LoRa_E220::receiveInitialMessage
returns a uint8_t
would this change cause a bug?
ResponseContainer LoRa_E220::receiveInitialMessage(uint8_t size){
ResponseContainer rc;
rc.status.code = E220_SUCCESS;
char buff[size];
uint8_t len = this->serialDef.stream->readBytes(buff, size);
if (len!=size) {
if (len==0){
rc.status.code = ERR_E220_NO_RESPONSE_FROM_DEVICE;
}else{
rc.status.code = ERR_E220_DATA_SIZE_NOT_MATCH;
}
return rc;
}
rc.data = buff; // malloc(sizeof (moduleInformation));
return rc;
}
Hi George,
It seems that It’s ok.
You can also use a byte or char as a number.
Bye Renzo
More
3D Printer 3D printer upgrade ABB Arduino Arduino IDE Arduino SAMD boards Aurora AWS CNC Cyclone PCB Factory Cyclone PCB Factory how to build It Display DynamoDB E32 EMail esp01 esp32 esp8266 File System Firmware i2c Library LoRa MicroPython Milling PCB My PCB Networking PCB pinout Power saving Programming board Raspberry Pi REST API RF rp2040 SD Card Sensors Sleep and Wake UP SPI STM32 Temperature Tutorial Web Server Wemos D1 mini WiFi