Replies: 3 comments
-
There are no "two types of data", there's just bytes. Regardless of whether the characters you are sending are printable or not, it's always bytes. I tried to follow your code and I have failed completely, I have no idea what's going on there. So I suggest you take a step back. Try with a simple example sending strings. Then change those strings to a byte array that contains unprintable characters. Then move onto structs and unions. And only then introduce high-level logic such as the concept of a master or slave node. PS: In your union you have an array of character pointers PPS: You seem to have tried to re-implement blocking transmission/reception, and have done it incorrectly. You are waiting for BUSY pin instead of DIO1. Why are you trying to re-implement something that is already done in the library? |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for the prompt reply. Thank you for this library also. Lots of work for something nice for many to use. I will work on the suggestions you have put forth. I do get characters but they are incomprehensible on the receiving side. It's like the conversion from text to hex doesn't translate well. The dataBuff8 array has something but the hex values make no sense for characters. The numbers transmit and translate from hex well. I will look at size and pointers in the data stream and see if that fixes things but I also see nothing in the data stream that looks anything like the character I am sending even when trying to convert the hex values back over to ASCII. Good or bad... More to come after I work on your suggestions provided. Appreciate the help. |
Beta Was this translation helpful? Give feedback.
-
O.K. Nothing wrong with RadioLib as you said. It was all me. :-) After your suggestion to review UNION and STRUCT, I came up with the following code that allows me to send and receive text and numbers. This is functioning for me but the code mentioned above is no longer valid and the below code is only presented as an example for others. It may be helpful for some: typedef struct TransmitData { //Do not user wildcards like char*. Size of struct can't be determined reliably
}; #define BytesToSend 16 //sizeof[TransmitData] //number of data bytes to transmit from struct TransmitData. Anaylze struct to determine value. typedef union TransmitArray {
}; TransmitArray TA; //shortname alias for TransmitArray The array, dataByteArray, from above now transmits properly with the following code: state = radio.startTransmit(TA.dataByteArray, BytesToSend); The code submitted originally used a UNION and when trying to assign values to the referenced variables in the union, using its logic, did not work for me when it came to text (i.e. dataBuffChar[0] in Slave transmits data section.... Even with the correction from char* to char for that variable definition in the UNION and changing the order to dataBuffChar[3]). Thanks so much for the help and direction. It's helped a lot. |
Beta Was this translation helpful? Give feedback.
-
I am trying to send a mix of numbers and text via the radio.startTransmit byte array method. Here is the basic ping pong code I am testing with. I added to the union a char* variable (dataBuffChar) and set it to some text (variable char* text) for transmission and reception. Code compiles but I do not receive any text from the other SX126X board. I am using a SEEED Wio-LoRa-E5 Mini. Very little documentation on this so it has taken me some time to get to where I am with this project. It is similar to an STM32WLE5xx board. I am using the Arduino IDE. I am very new to this and have come to a road block on trying to figure out how to send text and numbers via the byte array method. I guess, first off, is it possible to do that with RadioLib and mix the two types of data or does one need to use the string method and parse out data from the transmitted string (radio.transmit(string))? Secondly, does the subroutine for radio.startTransmit not handle char variables? Does the text need to be converted to something else like a byte array and how would I add that to the union code defining the new field, dataBuffChar? If it involves a for next loop to pull each character out, how does one build such an array and feed it properly to RadioLib for transmit and for reception? It's been a frustrating week of lost hours on this. LOL. Any help is greatly appreciated. Below is a sample of the code being used. Note dataBuffChar in the union and adding that to the dataBuff8 array for sending and receiving: Thanks so much, everyone!
Beta Was this translation helpful? Give feedback.
All reactions