LoRa E220 and sending data with security

Home Forums The libraries hosted on the site EByte LoRa e220 UART devices LLCC68 LoRa E220 and sending data with security

Viewing 7 reply threads
  • Author
    Posts
    • #24106
      morpheus19900
      Participant

        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);
           }
         }
      • #24107
        Renzo Mischianti
        Keymaster

          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

          • #24110
            morpheus19900
            Participant

              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;
            • #24111
              Renzo Mischianti
              Keymaster

                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

              • #24112
                morpheus19900
                Participant

                  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?

              • #24113
                Renzo Mischianti
                Keymaster

                  Hi,
                  no, the max value per key is 255.
                  The key result in H*L.
                  Bye Renzo

                  • #24114
                    morpheus19900
                    Participant

                      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.

                  • #24119
                    Renzo Mischianti
                    Keymaster

                      Hi morpheus,
                      It’s very strange, can you share your code.
                      Bye Renzo

                      • #24120
                        morpheus19900
                        Participant

                          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);
                                  }  
                               }
                          }
                      • #24155
                        Renzo Mischianti
                        Keymaster

                          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

                          • #24166
                            morpheus19900
                            Participant

                              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!

                            • #24872
                              george_santiago
                              Participant

                                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.

                            • #24204
                              Renzo Mischianti
                              Keymaster

                                Hi Morpheus,
                                It’s possible that you have activated the RSSI bit?
                                Bye Renzo

                              • #25282
                                Renzo Mischianti
                                Keymaster

                                  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

                                  • #29791
                                    morpheus19900
                                    Participant

                                      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? 😛

                                  • #29792
                                    Renzo Mischianti
                                    Keymaster

                                      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

                                  Viewing 7 reply threads
                                  • You must be logged in to reply to this topic.
                                  Exit mobile version