CharKik & PoulpGas / Mbed OS ers4_lorawan_base

Dependencies:   Servo Cayenne-LPP

Files at this revision

API Documentation at this revision

Comitter:
superphil06
Date:
Mon Jan 27 13:55:34 2020 +0000
Parent:
58:81c66fac6476
Child:
60:f4e2002a9138
Commit message:
programme de base ers4 mdot

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 22 08:45:41 2019 +0000
+++ b/main.cpp	Mon Jan 27 13:55:34 2020 +0000
@@ -52,19 +52,18 @@
 
 DigitalOut Alarme (PC_13);// alarme LED output
 Servo Myservo(PA_7); //servomotor output
-
 TH02 MyTH02 (I2C_SDA,I2C_SCL,TH02_I2C_ADDR<<1);// connect hsensor on RX2 TX2
 /*
  * Sets up an application dependent transmission timer in ms. Used only when Duty Cycling is off for testing
  */
-#define TX_TIMER                        10000
+#define TX_TIMER                        20000
 
 /**
  * Maximum number of events for the event queue.
  * 10 is the safe number for the stack events, however, if application
  * also uses the queue for whatever purposes, this number should be increased.
  */
-#define MAX_NUMBER_OF_EVENTS            10
+#define MAX_NUMBER_OF_EVENTS            30
 
 /**
  * Maximum number of retries for CONFIRMED messages before giving up
@@ -189,20 +188,15 @@
     int16_t retcode;
     int32_t sensor_value, rh_value;
 
-  MyTH02.startTempConv(true,true);
+ /*MyTH02.startTempConv(true,true);
     iTime= MyTH02.waitEndConversion();// wait until onversion  is done
      iTempbrute= MyTH02.getConversionValue();
     sensor_value=MyTH02.getLastRawTemp();
     printf ("\n\r temp value=%d  %d",sensor_value,iTempbrute );
-  
-  MyTH02.startRHConv(true,true);
-       iTime= MyTH02.waitEndConversion();// wait until onversion  is done
-         printf ("\n\r time=%d",iTime);
-      iRHbrute= MyTH02.getConversionValue();
-        rh_value=MyTH02.getLastRawRH();
-          printf ("\n\r RH value=%d  %d",rh_value,iRHbrute );
+  */
+ 
 
-/*
+
     if (ds1820.begin()) {
         ds1820.startConversion();
         sensor_value = ds1820.read();
@@ -211,24 +205,14 @@
     } else {
         printf("\r\n No sensor found \r\n");
         return;
-    }*/
+    }
     
-  /*  packet_len = sprintf((char *) tx_buffer, "Dummy Sensor Value is %d",
-                         sensor_value);*/                       
+          
     Payload.reset();
     size = Payload.addTemperature(1, (float) sensor_value/100);    
-   // LORA_SEND(Payload.getBuffer(), Payload.getSize());       
-    // Payload.copy(tx_buffer);          
-    
-     // retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, Payload.getBuffer(), Payload.getSize(),
-                         //  MSG_UNCONFIRMED_FLAG);                
-  /*  retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, tx_buffer, packet_len,
-                           MSG_UNCONFIRMED_FLAG);*/
+   
 
 
-    size = size+Payload.addRelativeHumidity(2, (float) rh_value/100);    
-   // LORA_SEND(Payload.getBuffer(), Payload.getSize());       
-    // Payload.copy(tx_buffer);          
       retcode = lorawan.send(MBED_CONF_LORA_APP_PORT, Payload.getBuffer(), Payload.getSize(),
                            MSG_UNCONFIRMED_FLAG);                
 
@@ -265,33 +249,11 @@
 
     printf(" RX Data on port %u (%d bytes): ", port, retcode);
     for (uint8_t i = 0; i < retcode; i++) {
-        printf("%02x ", rx_buffer[i]);
+        printf("%02x", rx_buffer[i]);
     }
      printf("\n test value=%d", port); 
-   // printf("\r\n");
-  // num_port=port;
- /*  if (true)
-   {
-         printf("\n led=%d", (int)rx_buffer[0]); 
-            //Alarme.write((int) rx_buffer[0]);
-            }
-   if (port==2)
-   {
-         printf("\n servo=%d",(int) rx_buffer[0]); 
-      // Myservo.position ( rx_buffer[0]);
-     }   */      
-    switch (port){
-        case 1: // control led
-         printf("\n led=%d", (int)rx_buffer[0]); 
-            Alarme.write((int) rx_buffer[0]);
-        break;
-        case 2:// control servomotor
-        printf("\n servo=%d",(int) rx_buffer[0]); 
-      Myservo.position ( rx_buffer[0]);
-       break;
-       default: printf("\n port inconnu =%d",(int)port); 
-       break;
-        }
+ // code todo here
+   
         
     memset(rx_buffer, 0, sizeof(rx_buffer));
 }
@@ -336,6 +298,8 @@
             receive_message();
             break;
         case RX_TIMEOUT:
+         printf("\r\n timeout in reception - Code = %d \r\n", event);
+            break;
         case RX_ERROR:
             printf("\r\n Error in reception - Code = %d \r\n", event);
             break;
--- a/mbed_app.json	Tue Oct 22 08:45:41 2019 +0000
+++ b/mbed_app.json	Mon Jan 27 13:55:34 2020 +0000
@@ -31,16 +31,16 @@
             "platform.stdio-convert-newlines": true,
             "platform.stdio-baud-rate": 115200,
             "platform.default-serial-baud-rate": 115200,
-            "lora.over-the-air-activation": false,
+            "lora.over-the-air-activation": true,
             "lora.duty-cycle-on": true,
             "lora.phy": "EU868",
           
-            "lora.device-eui": " { 0x00, 0x01, 0x91, 0xE1, 0x38, 0xC2, 0x23, 0x01 }",
-            "lora.application-eui": "{ 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x02, 0x16, 0x8E }",
-            "lora.application-key": "{ 0x77, 0x8A, 0x26, 0xDF, 0x9D, 0x70, 0xDB, 0xEF, 0x43, 0x03, 0x0F, 0xD2, 0x5F, 0x47, 0x1D, 0xEC }",
-            "lora.appskey": "{ 0x25, 0x69, 0xD2, 0x16, 0xC6, 0x8F, 0x94, 0xC3, 0x04, 0xC5, 0x96, 0x7B, 0x69, 0xA0, 0x3A, 0x63 }",
-            "lora.nwkskey": "{ 0xE9, 0xCA, 0xC2, 0xA8, 0xDC, 0x06, 0x4F, 0x62, 0x4D, 0xAC, 0x06, 0x1D, 0x7C, 0x51, 0x2C, 0x0E }",
-            "lora.device-address": " 0x26011CB5"
+            "lora.device-eui": " { 0x00, 0x01, 0x91, 0xE1, 0x38, 0xC2, 0x23, 0x02 }",
+            "lora.application-eui": "{ 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x02, 0x16, 0x00 }",
+            "lora.application-key": "{ 0x77, 0x8A, 0x26, 0xDF, 0x9D, 0x70, 0xDB, 0xEF, 0x43, 0x03, 0x0F, 0xD2, 0x5F, 0x47, 0x1D, 0x00 }",
+            "lora.appskey": "{ 0x25, 0x69, 0xD2, 0x16, 0xC6, 0x8F, 0x94, 0xC3, 0x04, 0xC5, 0x96, 0x7B, 0x69, 0xA0, 0x3A, 0x00 }",
+            "lora.nwkskey": "{ 0xE9, 0xCA, 0xC2, 0xA8, 0xDC, 0x06, 0x4F, 0x62, 0x4D, 0xAC, 0x06, 0x1D, 0x7C, 0x51, 0x2C, 0x00 }",
+            "lora.device-address": " 0x26011C00"
             
         },