Home › Forums › The libraries hosted on the site › EByte LoRa e220 UART devices LLCC68 › LoRa E220 and sending data with security
- This topic has 16 replies, 4 voices, and was last updated 1 year, 2 months ago by
Renzo Mischianti.
-
AuthorPosts
-
-
3 February 2023 at 22:48 #24106
Hello everyone. I am using the “LoRa E220” library. I managed to get two Ebyte LoRa modules to communicate in fixed mode. Since I will be using the modules to open a gate located at a long distance, I was wondering if there is a need to implement some security thing like a rolling code, or if I am already protected in this way.
If I ever implement something like this, can you help me figure out how to do it? I’m using the library methods e220ttl.sendFixedMessage(); for the transmitter; while the receiver reads the received data like this:
if (e220ttl.available() > 0) { ResponseContainer rs = e220ttl.receiveMessage(); if (rs.data == "on") { digitalWrite(relay, HIGH); } else if (rs.data == "off"){ digitalWrite(relay, LOW); } }
-
3 February 2023 at 23:21 #24107
Hi Morpheus,
the EByte modules integrate cryptography, so you can change the key in configuration to be more sure that nobody can read your message.configuration.CRYPT.CRYPT_H configuration.CRYPT.CRYPT_L
Bye Renzo
-
4 February 2023 at 00:45 #24110
Thank you very much Renzo. This way I am sure that no one can clone the message I send?
Also is possible an example of how to set these instructions?
configuration.CRYPT.CRYPT_H; configuration.CRYPT.CRYPT_L;
Should I leave them like this as you wrote them? Or do I have to give it values? like that:
configuration.CRYPT.CRYPT_H = X; configuration.CRYPT.CRYPT_L = Z;
-
4 February 2023 at 08:46 #24111
Hi Morpheus,
the complexity is 255*255 and I think It’s sufficient.You can use the code you write and set via setConfiguration.
Bye Renzo
-
4 February 2023 at 10:33 #24112
Thanks, Renzo!
So, Have I to input like this?configuration.CRYPT.CRYPT_H = 123456; configuration.CRYPT.CRYPT_L = 123456;
Where ‘123456’ is my key, right?
-
-
4 February 2023 at 13:47 #24113
Hi,
no, the max value per key is 255.
The key result in H*L.
Bye Renzo-
4 February 2023 at 14:28 #24114
Thanks Renzo!
I set it up successfully! There is only one small problem: if the transmitter lora module sends an “on” or “off” string, the transmitter rs.data reads like this: “on%?d05”I fixed it by making a substring like this:
if(rs.data.substring(0,2) == "on"){ digitalWrite(relay, HIGH); }
But I was wondering why the transmitter in rs.data doesn’t give me “on” and “off” without the other weird characters.
Both the receiver and the transmitter have been set to fixed transmission, with the same baud rate and all other settings.
-
-
4 February 2023 at 21:56 #24119
Hi morpheus,
It’s very strange, can you share your code.
Bye Renzo-
5 February 2023 at 10:25 #24120
Without the Crypt, the strings are correct. Instead since I set the encryption key, the strings arrive strange.
This is the transmitter:
#include "Arduino.h" #include "LoRa_E220.h" LoRa_E220 e220ttl(3, 2); #define button 9 bool status; void setup() { Serial.begin(9600); pinMode(button, INPUT_PULLUP); delay(500); e220ttl.begin(); } String msg; void loop() { if(!digitalRead(button)){ status=!status; delay(200); } if(status){ msg = "on"; //on e220ttl.sendFixedMessage(0, 3, 4, msg); Serial.println(msg); } else { msg = "off"; //off e220ttl.sendFixedMessage(0, 3, 4, msg); Serial.println(msg); } }
This is the receiver:
#include "Arduino.h" #include "LoRa_E220.h" #define relay 12 LoRa_E220 e220ttl(3, 2); void setup() { Serial.begin(9600); pinMode(relay, OUTPUT); delay(500); e220ttl.begin(); } void loop() { if (e220ttl.available() > 0) { ResponseContainer rs = e220ttl.receiveMessage(); Serial.println(rs.data); if (rs.data == "on" ) { //ON digitalWrite(relay, HIGH); } else if (rs.data == "off" ) { //OFF digitalWrite(relay, LOW); } } }
-
-
13 February 2023 at 08:23 #24155
Hi Cris,
Sorry if I reply only now, I lost the last message.But remember that you must set the same CRYPT to all devices.
Bye Renzo-
15 February 2023 at 18:20 #24166
Thanks for the reply Renzo. Yes, the key is the same for both devices.
I set it like this:
configuration.CRYPT.CRYPT_H = 123; configuration.CRYPT.CRYPT_L = 123;
however, the strings I receive on the transmitter have strange characters.
However it doesn’t matter, since I finished the project and set up as I told you earlier like this:rs.data.substring(0,2) == "on"
Thanks so much for your patience!
-
20 March 2023 at 21:41 #24872
In the file ‘LoRa_E220.cpp’ change lines 831 and 850:
LoRa_E220.cpp#L831
in:
byte size = message.length(); // sizeof(message.c_str())+1;
to:
byte size = message.length() + 1; // sizeof(message.c_str())+1;
LoRa_E220.cpp#L850
in:
byte size = message.length(); // sizeof(message.c_str())+1;
to:
byte size = message.length() + 1; // sizeof(message.c_str())+1;
Please let us know if the message was sent and received correctly after these changes.
-
-
16 February 2023 at 09:47 #24204
Hi Morpheus,
It’s possible that you have activated the RSSI bit?
Bye Renzo-
10 April 2023 at 09:05 #24860
Hi Renzo
I had a similar problem and I think I found the source of the bug.
The bug occurs when using aString
type variable for the message. The Sender does not send the last character of the String.
Ex: When sending “101”, the Sender sends “10”, that is, it does not send the last character.
Ex:static int msg = 100; msg++; String msg_sent = String(msg); Serial.print("Sent Message: "); Serial.println(msg_sent); ResponseStatus rs = e220ttl.sendMessage(sent_msg);
I think the bug is on line 831:
https://github.com/xreef/EByte_LoRa_E220_Series_Library/blob/7acecaede468559df9a2e8ccf7367059748df80c/LoRa_E220.cpp#L831At the moment:
byte size = message.length(); // sizeof(message.c_str())+1;
I changed it to:
byte size = message.length() + 1; // sizeof(message.c_str())+1;
Everything worked fine.
There are other parts of the code that may need fixing. (I haven’t tested yet)
Ex:
https://github.com/xreef/EByte_LoRa_E220_Series_Library/blob/7acecaede468559df9a2e8ccf7367059748df80c/LoRa_E220.cpp#L850
-
-
10 April 2023 at 09:07 #25282
Hi,
I re-do all the specified test, and the library work correctly, the problem is born when you don’t set RSSI enabled on all devices, but only in one.
Bye Renzo-
19 February 2024 at 00:45 #29791
Hi Renzo, I apologize for replying late! In fact the problem is the one you mentioned, that is the application of RSSI. Thank you!
I wanted to ask you another thing, is the encryption with the two constants CRYPT_H and CRYPT_L with a maximum value of 255 for each, which are multiplied, AES type?
Also, with FIXED mode, and Encryption, am I sure that no “smart thief” can intercept the sent command, to use it to send it to the receiving station with LoRa? 😛
-
-
19 February 2024 at 09:40 #29792
Hi Morpheus,
The algorithm of encryption is proprietary to EByte, and I think It’s quite impossible to decrypt, but with brute force (if people try all the 255*255 combinations and the correct channel) people can intercept and read the communication.
Bye Renzo
-
-
AuthorPosts
- You must be logged in to reply to this topic.