- This topic has 1 reply, 2 voices, and was last updated 2 years, 7 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
Just like a well-organized workbench, this website uses cookies to function properly and efficiently.
🛠️ The Essentials (Necessary): Some cookies are categorized as necessary and are stored on your browser because they are critical for the basic working of the site.
📊 The Analytics (Third-party): We also use third-party cookies to help us analyze traffic and understand which projects you like the most. These are stored only if you give us the green light.
You can choose to opt-out, but keep in mind that disabling them might make the site experience a bit less "smooth".
| Cookie | Duration | Description |
|---|---|---|
| cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
| cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
| cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
| cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
| cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
| viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
