Home › Forums › The libraries hosted on the site › EByte LoRa e32 UART devices sx1262/sx1268 › EByte e32 sendFixedMessage Parameters Issue
Tagged: Question
- This topic has 5 replies, 1 voice, and was last updated 5 years ago by
Renzo Mischianti.
-
AuthorPosts
-
-
6 June 2020 at 18:26 #4458
cglkr97
Ciao Renzo!
I’m trying to do a project where I tell my sender E32 which receiver address it will send the message to. I give the address info via serial monitor. I ask the user to provide the ADDH, ADDL, CHAN bytes.
For example I give the ADDH=0 ADDL=0 and CHAN=17 and pass these into sendFixedMessage as parameters.ResponseStatus wakeMes = e32ttl.sendFixedMessage(ADDH,ADDL,CHAN, "Sensor Data");
But when the sender sends to this address, the receiver gives overflows and data get messed up since I can’t write the CHAN byte as 0x17.
I’ve tried writing it as,
ResponseStatus wakeMes = e32ttl.sendFixedMessage(ADDH,ADDL,Serial.print(23,HEX), "Sensor Data");
but it again gave overflow and data got messed up.Is there any other way that I can store the serial byte input as hex and then pass it into sendFixedMessage function as address parameter?
I’ve tried doing this,
byte b =Serial.println(a,HEX); Serial.println(b);
but again, it always turned something incorrect.Or is there any other way that I could play with your library to make the sendFixedMessage function to accept the user input byte without writing it as 0xCHAN?
Thanks,
C. -
6 June 2020 at 18:26 #4459
Hi cglkr97,
can you send the complete code PLZ.
Thanks Renzo -
6 June 2020 at 18:27 #4460
cglkr97
Hi Renzo,
Here is my code.
gatewayFixedMessage2.txtThanks
-
6 June 2020 at 18:36 #4461
Hi,
I do some change (set WAKE UP mode to sent do the receiver) and I set channel to 4 (but I test It with 17 also with send 23 that in HEX is 17) and works correctly the first handshake.
---------------------------------------- HEAD : 11000000 192 C0 AddH : 0 AddL : 2 Chan : 4 -> 414MHz SpeedParityBit : 0 -> 8N1 (Default) SpeedUARTDatte : 11 -> 9600bps (default) SpeedAirDataRate : 10 -> 2.4kbps (default) OptionTrans : 1 -> Fixed transmission (first three bytes can be used as high/low address and channel) OptionPullup : 1 -> TXD, RXD, AUX are push-pulls/pull-ups OptionWakeup : 0 -> 250ms (default) OptionFEC : 1 -> Turn on Forward Error Correction Switch (Default) OptionPower : 0 -> 20dBm (Default) ---------------------------------------- Press any key to start conversation with any node at any time. Start listening! ---------------------------------------- HEAD : 11000000 192 C0 AddH : 0 AddL : 1 Chan : 4 -> 414MHz SpeedParityBit : 0 -> 8N1 (Default) SpeedUARTDatte : 11 -> 9600bps (default) SpeedAirDataRate : 10 -> 2.4kbps (default) OptionTrans : 1 -> Fixed transmission (first three bytes can be used as high/low address and channel) OptionPullup : 1 -> TXD, RXD, AUX are push-pulls/pull-ups OptionWakeup : 0 -> 250ms (default) OptionFEC : 1 -> Turn on Forward Error Correction Switch (Default) OptionPower : 0 -> 20dBm (Default) ---------------------------------------- Press any key to start conversation with any node at any time. Start listening! >>Send to COM3: "0"<< ---------------------------------------- Now you are in interrupt mode. First, tell me the node adress you want to talk to Enter the ADDH in decimal >>Send to COM3: "0"<< ADDH: 0 Enter the ADDL in decimal >>Send to COM3: "1"<< ADDL: 1 Enter the CHAN in hex >>Send to COM3: "4"<< CHAN: 4 Your adress is: 0 1 4 Press 1 if you want to wake the node up and fetch the sensor data, press 2 to see the sleep schedule.. >>Send to COM3: "1"<< Sending message to wake the node up! Success ---------------------------------------- Data is coming thru.. Coming from -> 0 1 4 Temperature -> 18.91°C Humidity -> 67.89 Pressure -> 1234 Light intensity -> 433 Current battery state -> 0 Sending confirmation info to the sender.. Success
I used 2 arduino UNO (with my shield) but no overflow.
Bye Renzo
Attachments:
You must be logged in to view attached files. -
7 June 2020 at 09:13 #4487
cglkr97
Hey Renzo,
I can’t quite understand what you have changed in your code Renzo. Can you please give me some more details about the changes you made?
I have solved the problem by defining bunch of (32 to be exact, because there are 32 channels as you know) hex values such as
#define chan0 0x0
#define chan23 0x17
….
#define chan32 0x1F
And wrote a swith case for each one of those. 32 switch cases look terrible I know, but I had no choice. I’m going to be presenting my work next week, so whatever works I have to use it right now. But in the future, I’ll definitely look for a solution with a cleaner code.
I had another problem with your sendFixedMessage function earlier this week. I want to be able to set or change the sleep time wirelessly whenever I want. So I need to send an int or a byte data to the receiver for this and I don’t want to set up a structure for one small piece of data. So I tried turning my byte data to String so that I could send it as normal String message. But it didn’t accept it since it wasn’t written explicitly inside the quotation mark. So I had to set up another 32 switch cases for each sleep option I have, such as 1 minute, 15 minutes and 30 minutes.
So I ended up having 4 set of switch cases with 32 items inside each of them because of the inconvenience caused by the sendFixedMessage function. The code works but there’s gotta be some other way.
If you have any ideas on how I can do all these without writing hundred lines of hideous switch cases please let me know.
Thanks again for your work tho. If it wasn’t for it, I wouldn’t be able to finish my project.
Cheers,
C.
-
7 June 2020 at 22:21 #4488
Hi cglkr97,
as you can see in the file at line 228 I add
e32ttl.setMode(MODE_1_WAKE_UP);
than I use simple Int value to set ADDH, ADDL and CHAN (I print the HEX value to check the channel).I don’t have problem to use decimal value instead HEX.
I try to send a string value without problem, If you use ArduinoJSON pay attention the string generated isn’t clean value check this http://mischianti.org/forums/topic/how-to-send-message-use-json-format/
But if you want use a String value remember that you have only 59Byte to send message and binary data like structure is good optimized.
Bye Renzo
-
-
AuthorPosts
- You must be logged in to reply to this topic.