Wireless interface using LoRa technology

Dependencies:   AlohaTransceiver RingBuffer SX1276Lib_inAir SerialInterfaceProtocol mbed L3PDU

Revision:
11:c7c0036efdbd
Parent:
10:7dcb951ecabd
Child:
14:80cee3991860
--- a/main.cpp	Wed Jul 27 05:09:23 2016 +0000
+++ b/main.cpp	Fri Jul 29 04:03:24 2016 +0000
@@ -223,149 +223,149 @@
         
         case 0x05: //Symbol Timeout
         {
-                 if (isSet) 
-                 {
-                     uint16_t SymbolTimeout = payload[3] | (payload[2] << 8);
-                     settings->SymbolTimeout = SymbolTimeout;
-                     return 0;
-                 }
-                 else 
-                 {
-                     response[1] = (uint8_t) (settings->SymbolTimeout);
-                     response[0] = (uint8_t) (settings->SymbolTimeout >> 8);
-                     *response_length = 2;
-                     
-                     return 0;
-                 }
+             if (isSet) 
+             {
+                 uint16_t SymbolTimeout = payload[3] | (payload[2] << 8);
+                 settings->SymbolTimeout = SymbolTimeout;
+                 return 0;
+             }
+             else 
+             {
+                 response[1] = (uint8_t) (settings->SymbolTimeout);
+                 response[0] = (uint8_t) (settings->SymbolTimeout >> 8);
+                 *response_length = 2;
+                 
+                 return 0;
+             }
         }
         
         case 0x06: //FixLen
         {
-                 if (isSet) 
-                 {
-                     bool FixLen = payload[2];
-                     settings->FixLen = FixLen;
-                     return 0;
-                 }
-                 else 
-                 {
-                     response[0] = (bool) (settings->SymbolTimeout);
-                     *response_length = 1;
-                     
-                     return 0;
-                 }
+             if (isSet) 
+             {
+                 bool FixLen = payload[2];
+                 settings->FixLen = FixLen;
+                 return 0;
+             }
+             else 
+             {
+                 response[0] = (bool) (settings->SymbolTimeout);
+                 *response_length = 1;
+                 
+                 return 0;
+             }
         }
         
         case 0x07: //PayloadLen
         {
-                 if (isSet)
-                 {
-                     uint8_t PayloadLen = payload[2];
-                     settings->PayloadLen = PayloadLen;
-                     return 0;
-                 }
-                 else 
-                 {
-                     response[0] = (uint8_t) (settings->PayloadLen);
-                     
-                     return 0;
-                }
+             if (isSet)
+             {
+                 uint8_t PayloadLen = payload[2];
+                 settings->PayloadLen = PayloadLen;
+                 return 0;
+             }
+             else 
+             {
+                 response[0] = (uint8_t) (settings->PayloadLen);
+                 
+                 return 0;
+            }
         }
         
         case 0x08: //CrcOn
         {
-                if (isSet) {
-                    bool CrcOn = payload[2];
-                    settings->CrcOn = CrcOn;
-                    return 0;
-                }
-                else 
-                {
-                    response[0] = (bool) (settings->CrcOn);
-                    
-                    return 0;
-                }
+            if (isSet) {
+                bool CrcOn = payload[2];
+                settings->CrcOn = CrcOn;
+                return 0;
+            }
+            else 
+            {
+                response[0] = (bool) (settings->CrcOn);
+                
+                return 0;
+            }
         }
         
         case 0x09: //FreqHopOn
         {
-                 if (isSet) {
-                     bool FreqHopOn = payload[2];
-                     settings->FreqHopOn = FreqHopOn;
-                     return 0;
-                }
-                else 
-                {
-                    response[0] = (bool) (settings->FreqHopOn);
-                    
-                    return 0;
-                }
+             if (isSet) {
+                 bool FreqHopOn = payload[2];
+                 settings->FreqHopOn = FreqHopOn;
+                 return 0;
+            }
+            else 
+            {
+                response[0] = (bool) (settings->FreqHopOn);
+                
+                return 0;
+            }
         }
         
         case 0x0A: //HopPeriod
         {
-                 if (isSet) {
-                     uint8_t HopPeriod = payload[2];
-                     settings->HopPeriod = HopPeriod;
-                     return 0;
-                }
-                else 
-                {
-                    response[0] = (uint8_t) (settings->HopPeriod);
-                    return 0;
-                }
+             if (isSet) {
+                 uint8_t HopPeriod = payload[2];
+                 settings->HopPeriod = HopPeriod;
+                 return 0;
+            }
+            else 
+            {
+                response[0] = (uint8_t) (settings->HopPeriod);
+                return 0;
+            }
         }
         
         case 0x0B: //IqInverted
         {
-                 if (isSet) {
-                     bool IqInverted = payload[2];
-                     settings->IqInverted = IqInverted;
-                     return 0;
-                }
-                else 
-                {
-                    response[0] = (bool) (settings->IqInverted);
-                    return 0;
-                }
+             if (isSet) {
+                 bool IqInverted = payload[2];
+                 settings->IqInverted = IqInverted;
+                 return 0;
+            }
+            else 
+            {
+                response[0] = (bool) (settings->IqInverted);
+                return 0;
+            }
         }
         
         case 0x0C: //RxContinuous
         {
-                 if(isSet) 
-                 {
-                     bool RxContinuous = payload[2];
-                     settings->RxContinuous = RxContinuous;
-                     return 0;
-                }
-                else 
-                {
-                    response[0] = (bool) (settings->RxContinuous);
-                    return 0;
-                }
+             if(isSet) 
+             {
+                 bool RxContinuous = payload[2];
+                 settings->RxContinuous = RxContinuous;
+                 return 0;
+            }
+            else 
+            {
+                response[0] = (bool) (settings->RxContinuous);
+                return 0;
+            }
         }
         
         case 0x0D: //TxTimeout
         {
-                 if (isSet) 
-                 {
-                     uint32_t TxTimeout = (payload[5]) | 
-                                    (payload[4] << 8) |
-                                    (payload[3] << 16) | 
-                                    (payload[2] << 24);
-                    settings->TxTimeout = TxTimeout;
-                    return 0;
-                }
-                else 
-                {
-                    response[3] = (uint8_t) (settings->TxTimeout);
-                    response[2] = (uint8_t) (settings->TxTimeout >> 8);
-                    response[1] = (uint8_t) (settings->TxTimeout >> 16);
-                    response[0] = (uint8_t) (settings->TxTimeout >> 24);
-                    *response_length = 4;
-                    
-                    return 0;
-                }
+             if (isSet) 
+             {
+                 uint32_t TxTimeout = (payload[5]) | 
+                                (payload[4] << 8) |
+                                (payload[3] << 16) | 
+                                (payload[2] << 24);
+                settings->TxTimeout = TxTimeout;
+                return 0;
+            }
+            else 
+            {
+                response[3] = (uint8_t) (settings->TxTimeout);
+                response[2] = (uint8_t) (settings->TxTimeout >> 8);
+                response[1] = (uint8_t) (settings->TxTimeout >> 16);
+                response[0] = (uint8_t) (settings->TxTimeout >> 24);
+                *response_length = 4;
+                
+                return 0;
+            }
         }
                  
         
@@ -381,6 +381,13 @@
     return 0;
 }
 
+int radioUpdateSettings(uint8_t *payload, uint8_t payload_length, uint8_t *response, uint8_t *response_length)
+{
+    aloha.updateSettings();
+    
+    return 0;
+}
+
 void AlohaDataHandler(AlohaFrame *frame)
 {
     // stop the timer to measure round trip time
@@ -446,6 +453,7 @@
     SIP.registerCommand(0x00, toggleChecksum);
     SIP.registerCommand(0x01, sendMessage);
     SIP.registerCommand(0x02, configureRadio);
+    SIP.registerCommand(0x03, radioUpdateSettings);
     
     // register callback functions for aloha transceiver
     aloha.registerType(AlohaFrame::Aloha_Data, AlohaDataHandler);