L3STIC / Mbed 2 deprecated LoRaWAN-MULTI_RTC_heure-V04

Dependencies:   mbed LoRaWAN-lib SX1272Lib

Files at this revision

API Documentation at this revision

Comitter:
MGstic
Date:
Wed Feb 06 19:16:44 2019 +0000
Parent:
10:1a85ff06be1a
Commit message:
V04;

Changed in this revision

app/SerialDisplay.cpp Show annotated file Show diff for this revision Revisions of this file
app/SerialDisplay.h Show annotated file Show diff for this revision Revisions of this file
app/main.cpp Show annotated file Show diff for this revision Revisions of this file
app/unixtimestamp.cpp Show annotated file Show diff for this revision Revisions of this file
app/unixtimestamp.h Show annotated file Show diff for this revision Revisions of this file
--- a/app/SerialDisplay.cpp	Wed Jan 23 16:28:51 2019 +0000
+++ b/app/SerialDisplay.cpp	Wed Feb 06 19:16:44 2019 +0000
@@ -208,7 +208,7 @@
     // Data
     SerialDisplayUpdateData( 28, buffer, bufferSize );
     // Help message
-    vt.SetCursorPos( 42, 1 );
+    vt.SetCursorPos( 52, 1 );
     vt.printf( "To refresh screen please hit 'r' key." );
 }
 
@@ -271,6 +271,14 @@
     }
 
 }
+void SerialDisplaytest( int p,int i )
+{
+    
+        vt.SetCursorPos( (42+i), 58 );
+        vt.printf( "%2d", p );
+    
+
+}
 
 void SerialDisplayDrawFirstLine( void )
 {
@@ -461,7 +469,7 @@
     SerialDisplayDrawLine( "            ", " 4. Jour    [  ]                                                 " );
     SerialDisplayDrawLine( "            ", " 5. Mois    [  ]                                                 " );
     SerialDisplayDrawLine( "            ", " 6. Annee   [    ]                                               " );
-    SerialDisplayDrawLine( "            ", " Selection  [__]                  Valeur  [    ]                 " );
+    SerialDisplayDrawLine( "            ", " Selection  [__]                  Valeur                         " );
     SerialDisplayDrawBottomLine( );
     vt.printf( "To refresh screen please hit 'r' key.\r\n" );
 }
@@ -480,54 +488,133 @@
 void saisie_serie(int tab[6])
 {
     int inter=9;
+    int a;
     while( inter != 0) {
 
-        scanf("%d",&inter); //lecture saisie clavier
+        //scanf("%d",&inter); //lecture saisie clavier
+        inter=((int)vt.getc())-48;
         vt.SetCursorPos( 50, 28 );
         vt.printf( "%2d", inter );
-        vt.SetCursorPos( 50, 58 );
-        vt.printf( "    ");                
-        SerialDisplayTIME(tab);
+        vt.SetCursorPos( 50, 56 );
+        vt.printf( "             ");                
+        
         switch (inter) {
             case 1:
-                vt.SetCursorPos( 50, 58 );   
-                scanf("%d",&tab[0]);
-                vt.printf( "%2d", tab[0] );
+
+                vt.SetCursorPos( 50, 61 );
+                vt.printf("HEURE");
+                vt.SetCursorPos( 50, 56 );    
+                a=(((int)vt.getc())-48);
+                tab[0]=a*10;
+                vt.printf( "%2d", a);
+                vt.SetCursorPos( 50, 57 );
+                a=((int)vt.getc())-48;
+                tab[0]=tab[0]+a;
+                vt.printf( "%2d", tab[0]);
+                SerialDisplayTIME(tab);
+                vt.SetCursorPos( 50, 28 );
+                vt.printf( "  ");
                 break;
 
             case 2:
-                vt.SetCursorPos( 50, 58 );
-                scanf("%d",&tab[1]);
-                vt.printf( "%2d", tab[1] );              
+                
+                vt.SetCursorPos( 50, 61 );
+                vt.printf("MINUTE");
+                vt.SetCursorPos( 50, 56 );    
+                a=(((int)vt.getc())-48);
+                tab[1]=a*10;
+                vt.printf( "%2d", a);
+                vt.SetCursorPos( 50, 57 );
+                a=((int)vt.getc())-48;
+                tab[1]=tab[1]+a;
+                vt.printf( "%2d", tab[1]);
+                SerialDisplayTIME(tab);
+                vt.SetCursorPos( 50, 28 );
+                vt.printf( "  ");           
                 break;
 
             case 3:
-                vt.SetCursorPos( 50, 58 );
-                scanf("%d",&tab[2]);
-                vt.printf( "%2d", tab[2] );
+                
+                vt.SetCursorPos( 50, 61 );
+                vt.printf("SECONDE");
+                vt.SetCursorPos( 50, 56 );    
+                a=(((int)vt.getc())-48);
+                tab[2]=a*10;
+                vt.printf( "%2d", a);
+                vt.SetCursorPos( 50, 57 );
+                a=((int)vt.getc())-48;
+                tab[2]=tab[2]+a;
+                vt.printf( "%2d", tab[2]);
+                SerialDisplayTIME(tab);
+                vt.SetCursorPos( 50, 28 );
+                vt.printf( "  ");
                 break;
 
             case 4:
-                vt.SetCursorPos( 50, 58 );
-                scanf("%d",&tab[3]);
-                vt.printf( "%2d", tab[3] );
+                
+                vt.SetCursorPos( 50, 61 );
+                vt.printf("JOUR");
+                vt.SetCursorPos( 50, 56 );    
+                a=(((int)vt.getc())-48);
+                tab[3]=a*10;
+                vt.printf( "%2d", a);
+                vt.SetCursorPos( 50, 57 );
+                a=((int)vt.getc())-48;
+                tab[3]=tab[3]+a;
+                vt.printf( "%2d", tab[3]);
+                SerialDisplayTIME(tab);
+                vt.SetCursorPos( 50, 28 );
+                vt.printf( "  ");
                 break;
 
             case 5:
-                vt.SetCursorPos( 50, 58 );
-                scanf("%d",&tab[4]);
-                vt.printf( "%2d", tab[4] );
+                
+                vt.SetCursorPos( 50, 61 );
+                vt.printf("MOIS");
+                vt.SetCursorPos( 50, 56 );    
+                a=(((int)vt.getc())-48);
+                tab[4]=a*10;
+                vt.printf( "%2d", a);
+                vt.SetCursorPos( 50, 57 );
+                a=((int)vt.getc())-48;
+                tab[4]=tab[4]+a;
+                vt.printf( "%2d", tab[4]);
+                SerialDisplayTIME(tab);
+                vt.SetCursorPos( 50, 28 );
+                vt.printf( "  ");
                 break;
 
             case 6:
-                vt.SetCursorPos( 50, 58 );
-                scanf("%d",&tab[5]);
-                vt.printf( "%2d", tab[5] );
+                
+                vt.SetCursorPos( 50, 63 );
+                vt.printf("ANNEE");
+                vt.SetCursorPos( 50, 56 );    
+                a=(((int)vt.getc())-48);
+                tab[5]=a*1000;
+                vt.printf( "%d", a);
+                vt.SetCursorPos( 50, 57 );    
+                a=(((int)vt.getc())-48);
+                tab[5]=tab[5]+a*100;
+                vt.printf( "%d", a);
+                vt.SetCursorPos( 50, 58 );    
+                a=(((int)vt.getc())-48);
+                tab[5]=tab[5]+a*10;
+                vt.printf( "%d", a);
+                vt.SetCursorPos( 50, 59 );
+                a=((int)vt.getc())-48;
+                tab[5]=tab[5]+a;
+                vt.printf( "%d", a);
+                SerialDisplayTIME(tab);
+                vt.SetCursorPos( 50, 28 );
+                vt.printf( "  ");
                 break;
 
             default:
-                vt.SetCursorPos( 50, 58 );
-                vt.printf( "    ");
+                vt.SetCursorPos( 50, 56 );
+                vt.printf( "              ");
+                vt.SetCursorPos( 50, 28 );
+                vt.printf( "  ");
+                SerialDisplayTIME(tab);
                 break;
         }
     }  
--- a/app/SerialDisplay.h	Wed Jan 23 16:28:51 2019 +0000
+++ b/app/SerialDisplay.h	Wed Feb 06 19:16:44 2019 +0000
@@ -38,6 +38,7 @@
 void SerialDisplayRTCactive( bool etat );
 void SerialDisplayTIME( int tab[6] );
 void saisie_serie(int tab[6]);
+void SerialDisplaytest( int p,int i );
 
 
 
--- a/app/main.cpp	Wed Jan 23 16:28:51 2019 +0000
+++ b/app/main.cpp	Wed Feb 06 19:16:44 2019 +0000
@@ -12,9 +12,9 @@
 /*!
  * Defines the application data transmission duty cycle. 1s, value in [ms].
  */
-#define APP_TX_DUTYCYCLE                            1000
-#define TAB_MAX                                       10 
-#define APP_TX_DUTYCYCLE_RND                        250
+#define APP_TX_DUTYCYCLE                            500
+#define TAB_MAX                                     20
+#define APP_TX_DUTYCYCLE_RND                        5
 
 #define LORAWAN_DEFAULT_DATARATE                    DR_5
 #define LORAWAN_CONFIRMED_MSG_ON                    true
@@ -40,8 +40,8 @@
 //############INITIALISATION LIAISON SERIE####################
 
 void saisie_serie(int tab[6]);
-int tabd[6]= {0,0,0,1,1,2018};
-
+//int tabd[6]= {0,0,0,1,1,2018};
+    int tabd[6];
 
 InterruptIn bouton(USER_BUTTON); // Déclaration de l'interruption extern activée par le bouton utilisateur bleu
 //Serial pc(USBTX, USBRX); // tx, rx//Serial pc(SERIAL_TX, SERIAL_RX); // Déclaration de entrées pour la liaison série
@@ -184,7 +184,7 @@
 }LoRaMacDownlinkStatus;
 volatile bool DownlinkStatusUpdated = false;
 
-void SerialDisplayRefresh( void )
+void SerialDisplayRefresh( int tabd[6] )
 {
     MibRequestConfirm_t mibReq;
 
@@ -221,7 +221,7 @@
             case 'R':
             case 'r':
                 // Refresh Serial screen
-                SerialDisplayRefresh( );
+                SerialDisplayRefresh(tabd);
                 break;
             default:
                 break;
@@ -233,12 +233,12 @@
  * \brief   Prepares the payload of the frame
  */
  
-uint8_t poidstest=34;
-uint8_t heuretest=0;
+int poidstest=34;
+
 
 typedef struct {
-    uint8_t heure;//[8]; // Augmentation taille prog. Solution : heure = pointeur vers malloc (26 ou sizeof ctime)=1bit
-    uint8_t masse;//[8];
+    int heure[8]; // Augmentation taille prog. Solution : heure = pointeur vers malloc (26 ou sizeof ctime)=1bit
+    int masse[8];
 } data;
 data data_packet[TAB_MAX];
 
@@ -256,33 +256,19 @@
 }
 //##################################
 
-static void PrepareTxFrame( uint8_t port,data datat )//, 2EME PARAMETRE TABLEAU DONNEE INIT=>APPDATA DANS FONCION fournir 1 case tableau data_packet
-{
-    int  dpacket[8];
-    time_t seconds=time(NULL);
+static void PrepareTxFrame( uint8_t port,data datat[TAB_MAX],int compt )//, 2EME PARAMETRE TABLEAU DONNEE INIT=>APPDATA DANS FONCION fournir 1 case tableau data_packet
+{        
     switch( port )
     {
     case 15:
         {
-            //printf("%d\r\n",seconds);
-            copy_time(dpacket,seconds);
-                /*for(int k=0;k<8;k++)
-                {
-                    printf("%X",dpacket[k]);
-                }
-                printf("\n\r");*/
+           
             for(int h=0;h<8;h++)
             {
-
-                
-                AppData[h]=dpacket[h];
-                //AppData[h]=datat.heure;
-                //printf("    ||H:%d|\n\r",AppData[0]);
-                
-                //printf("    ||P:%d|\n\r",AppData[16]);
+                AppData[h]=datat[compt].heure[h];
             } 
 
-           AppData[16]=datat.masse;        
+           AppData[16]=datat[compt].masse[0];        
         }
         break;
     case 224:
@@ -368,9 +354,11 @@
 
     if( LoRaMacMcpsRequest( &mcpsReq ) == LORAMAC_STATUS_OK )
     {
+
         return false;
     }
     return true;
+
 }
 
 /*!
@@ -454,6 +442,7 @@
  * \param   [IN] mcpsIndication - Pointer to the indication structure,
  *               containing indication attributes.
  */
+uint8_t c_send=TAB_MAX;
 static void McpsIndication( McpsIndication_t *mcpsIndication )
 {
     if( mcpsIndication->Status != LORAMAC_EVENT_INFO_STATUS_OK )
@@ -505,6 +494,7 @@
         LoRaMacDownlinkStatus.Snr = ( mcpsIndication->Snr & 0xFF ) >> 2;
     }
     LoRaMacDownlinkStatus.DownlinkCounter++;
+    c_send--;
     LoRaMacDownlinkStatus.RxData = mcpsIndication->RxData;
     LoRaMacDownlinkStatus.Port = mcpsIndication->Port;
     LoRaMacDownlinkStatus.Buffer = mcpsIndication->Buffer;
@@ -710,13 +700,29 @@
     NextTx = true;
     UplinkStatusUpdated = true;
 }
+ void fil (int tabd[6],time_t seconde)
+ {
+        char buffer[8];
+        strftime(buffer, 8, "%Y\n", localtime(&seconde));
+        tabd[5]=atoi(buffer);
+        strftime(buffer, 8, "%m\n", localtime(&seconde));
+        tabd[4]=atoi(buffer);
+        strftime(buffer, 8, "%d\n", localtime(&seconde));
+        tabd[3]=atoi(buffer);
+        strftime(buffer, 8, "%S\n", localtime(&seconde));
+        tabd[2]=atoi(buffer);
+        strftime(buffer, 8, "%M\n", localtime(&seconde));
+        tabd[1]=atoi(buffer);
+        strftime(buffer, 8, "%H\n", localtime(&seconde));
+        tabd[0]=atoi(buffer);
+
+}
 
 /*######################################################################
  * Main application entry point.
  */
 
 
-
 int main( void )
 {
     //####### INITIALISATION MODULE LORA ############
@@ -741,12 +747,12 @@
     bouton.rise(&interruption_extern_bouton); //initialisation de l'interruption extern sur le bouton user
     
     //####### RTC INIT ########
-    set_time(1514764800);
+    //set_time(1514764800);
     int config_s=0;
 
     //####### VARIABLES ########
     uint8_t compt=0;
-    uint8_t c_send=TAB_MAX;
+
 
     while( 1 )
     {
@@ -772,155 +778,183 @@
                 //SerialDisplayUpdateLedState( 2, Led2State );
                 SerialDisplayUpdateDownlink( LoRaMacDownlinkStatus.RxData, LoRaMacDownlinkStatus.Rssi, LoRaMacDownlinkStatus.Snr, LoRaMacDownlinkStatus.DownlinkCounter, LoRaMacDownlinkStatus.Port, LoRaMacDownlinkStatus.Buffer, LoRaMacDownlinkStatus.BufferSize );
             }
+
+
             
         }
-
-                //time_t seconds = time(NULL);
-                //sprintf(data_packet[compt].heure,"%s",ctime(&seconds));// copie de la valeur de la RTC en cours dans le tableau de structure data_packet
-                
-                data_packet[0].heure=heuretest;
-                data_packet[0].masse=poidstest;
+                data_packet[compt].masse[0]=poidstest;              
                 poidstest++;
-                heuretest++;
-                
-                //printf("%d\r\n",compt);
-
-                wait(1);
                 switch (etat) 
                 {
                     
                     case 0:  //bouton non enclenché
-                    {
+                    {            
+                        time_t seconds=time(NULL);
+                        fil (tabd,seconds);
+                        SerialDisplaytest( compt,0 );
+                        SerialDisplaytest( c_send,1 );
                         SerialDisplayRTCactive(etat);
                         SerialDisplayTIME(tabd);
-                        time_t seconds = time(NULL);
-                        switch( DeviceState )
+                        //time_t seconds = time(NULL)
+                        if (compt<=(TAB_MAX-1)||(c_send==0))
                         {
+                            if( c_send==0)
+                            {
+                                compt=0;
+                                c_send=TAB_MAX;
+                            }
+                            wait(3); 
+                            //time_t seconds=time(NULL);
+                            copy_time(data_packet[compt].heure,seconds); 
+                            compt++;                  
+                        }
 
-                            case DEVICE_STATE_INIT:
+                        else  
+                        {  //SerialDisplaytest( compt+1,8 );
+                            switch( DeviceState )
                             {
-                                LoRaMacPrimitives.MacMcpsConfirm = McpsConfirm;
-                                LoRaMacPrimitives.MacMcpsIndication = McpsIndication;
-                                LoRaMacPrimitives.MacMlmeConfirm = MlmeConfirm;
-                                LoRaMacCallbacks.GetBatteryLevel = BoardGetBatteryLevel;
-                                LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks );
-                                TimerInit( &TxNextPacketTimer, OnTxNextPacketTimerEvent );
+                                case DEVICE_STATE_INIT:
+                                {
+                                    LoRaMacPrimitives.MacMcpsConfirm = McpsConfirm;
+                                    LoRaMacPrimitives.MacMcpsIndication = McpsIndication;
+                                    LoRaMacPrimitives.MacMlmeConfirm = MlmeConfirm;
+                                    LoRaMacCallbacks.GetBatteryLevel = BoardGetBatteryLevel;
+                                    LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks );
+                                    TimerInit( &TxNextPacketTimer, OnTxNextPacketTimerEvent );
 
-                                mibReq.Type = MIB_ADR;
-                                mibReq.Param.AdrEnable = LORAWAN_ADR_ON;
-                                LoRaMacMibSetRequestConfirm( &mibReq );
-                                mibReq.Type = MIB_PUBLIC_NETWORK;
-                                mibReq.Param.EnablePublicNetwork = LORAWAN_PUBLIC_NETWORK;
-                                LoRaMacMibSetRequestConfirm( &mibReq );
-                                LoRaMacTestSetDutyCycleOn( LORAWAN_DUTYCYCLE_ON );
-                                SerialDisplayUpdateDutyCycle( LORAWAN_DUTYCYCLE_ON );
+                                    mibReq.Type = MIB_ADR;
+                                    mibReq.Param.AdrEnable = LORAWAN_ADR_ON;
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
+                                    mibReq.Type = MIB_PUBLIC_NETWORK;
+                                    mibReq.Param.EnablePublicNetwork = LORAWAN_PUBLIC_NETWORK;
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
+                                    LoRaMacTestSetDutyCycleOn( LORAWAN_DUTYCYCLE_ON );
+                                    SerialDisplayUpdateDutyCycle( LORAWAN_DUTYCYCLE_ON );
 
 
-                                LoRaMacChannelAdd( 3, ( ChannelParams_t )LC4 );
-                                LoRaMacChannelAdd( 4, ( ChannelParams_t )LC5 );
-                                LoRaMacChannelAdd( 5, ( ChannelParams_t )LC6 );
-                                LoRaMacChannelAdd( 6, ( ChannelParams_t )LC7 );
-                                LoRaMacChannelAdd( 7, ( ChannelParams_t )LC8 );
-                                LoRaMacChannelAdd( 8, ( ChannelParams_t )LC9 );
-                                LoRaMacChannelAdd( 9, ( ChannelParams_t )LC10 );
+                                    LoRaMacChannelAdd( 3, ( ChannelParams_t )LC4 );
+                                    LoRaMacChannelAdd( 4, ( ChannelParams_t )LC5 );
+                                    LoRaMacChannelAdd( 5, ( ChannelParams_t )LC6 );
+                                    LoRaMacChannelAdd( 6, ( ChannelParams_t )LC7 );
+                                    LoRaMacChannelAdd( 7, ( ChannelParams_t )LC8 );
+                                    LoRaMacChannelAdd( 8, ( ChannelParams_t )LC9 );
+                                    LoRaMacChannelAdd( 9, ( ChannelParams_t )LC10 );
 
-                                mibReq.Type = MIB_RX2_DEFAULT_CHANNEL;
-                                mibReq.Param.Rx2DefaultChannel = ( Rx2ChannelParams_t ){ 869525000, DR_3 };
-                                LoRaMacMibSetRequestConfirm( &mibReq );
+                                    mibReq.Type = MIB_RX2_DEFAULT_CHANNEL;
+                                    mibReq.Param.Rx2DefaultChannel = ( Rx2ChannelParams_t ){ 869525000, DR_3 };
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
 
-                                mibReq.Type = MIB_RX2_CHANNEL;
-                                mibReq.Param.Rx2Channel = ( Rx2ChannelParams_t ){ 869525000, DR_3 };
-                                LoRaMacMibSetRequestConfirm( &mibReq );
+                                    mibReq.Type = MIB_RX2_CHANNEL;
+                                    mibReq.Param.Rx2Channel = ( Rx2ChannelParams_t ){ 869525000, DR_3 };
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
 
-                                SerialDisplayUpdateActivationMode( OVER_THE_AIR_ACTIVATION );
-                                SerialDisplayUpdateAdr( LORAWAN_ADR_ON );
-                                SerialDisplayUpdatePublicNetwork( LORAWAN_PUBLIC_NETWORK );
+                                    SerialDisplayUpdateActivationMode( OVER_THE_AIR_ACTIVATION );
+                                    SerialDisplayUpdateAdr( LORAWAN_ADR_ON );
+                                    SerialDisplayUpdatePublicNetwork( LORAWAN_PUBLIC_NETWORK );
 
-                                LoRaMacDownlinkStatus.DownlinkCounter = 0;
+                                    LoRaMacDownlinkStatus.DownlinkCounter = 0;
 
-                                DeviceState = DEVICE_STATE_JOIN;
-                                break;
-                            }
-                            case DEVICE_STATE_JOIN:
-                            {
-                                mibReq.Type = MIB_NET_ID;
-                                mibReq.Param.NetID = LORAWAN_NETWORK_ID;
-                                LoRaMacMibSetRequestConfirm( &mibReq );
+                                    DeviceState = DEVICE_STATE_JOIN;
+                                    
+                                    break;
+                                }
+                                case DEVICE_STATE_JOIN:
+                                {
+                                    mibReq.Type = MIB_NET_ID;
+                                    mibReq.Param.NetID = LORAWAN_NETWORK_ID;
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
 
-                                mibReq.Type = MIB_DEV_ADDR;
-                                mibReq.Param.DevAddr = DevAddr;
-                                LoRaMacMibSetRequestConfirm( &mibReq );
-
-                                mibReq.Type = MIB_NWK_SKEY;
-                                mibReq.Param.NwkSKey = NwkSKey;
-                                LoRaMacMibSetRequestConfirm( &mibReq );
+                                    mibReq.Type = MIB_DEV_ADDR;
+                                    mibReq.Param.DevAddr = DevAddr;
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
 
-                                mibReq.Type = MIB_APP_SKEY;
-                                mibReq.Param.AppSKey = AppSKey;
-                                LoRaMacMibSetRequestConfirm( &mibReq );
+                                    mibReq.Type = MIB_NWK_SKEY;
+                                    mibReq.Param.NwkSKey = NwkSKey;
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
 
-                                mibReq.Type = MIB_NETWORK_JOINED;
-                                mibReq.Param.IsNetworkJoined = true;
-                                LoRaMacMibSetRequestConfirm( &mibReq );
+                                    mibReq.Type = MIB_APP_SKEY;
+                                    mibReq.Param.AppSKey = AppSKey;
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
 
-                                DeviceState = DEVICE_STATE_SEND;
-                                IsNetworkJoinedStatusUpdate = true;
-                                break;
-                            }
-                            case DEVICE_STATE_SEND:
-                            {
-                                if( NextTx == true )
+                                    mibReq.Type = MIB_NETWORK_JOINED;
+                                    mibReq.Param.IsNetworkJoined = true;
+                                    LoRaMacMibSetRequestConfirm( &mibReq );
+                                   //c_send--;
+                                  // SerialDisplaytest( c_send,3 ); 
+                                    DeviceState = DEVICE_STATE_SEND;
+                                    IsNetworkJoinedStatusUpdate = true;
+                                    break;
+                                }
+                                case DEVICE_STATE_SEND:
+                                {   
+                                    if(NextTx == true )
+                                    {
+                                        SerialDisplayUpdateUplinkAcked( false );
+                                        SerialDisplayUpdateDonwlinkRxData( false );
+                              
+                                                         ///prepare tx                                               
+                                                        PrepareTxFrame( AppPort,data_packet,compt-c_send);
+                                                        NextTx = SendFrame( );
+                                                        SerialDisplaytest( compt-c_send,6 );
+                                                        
+                                          
+                                                    
+                                    }
+                                  
+                                    if( ComplianceTest.Running == true )
+                                    {
+                                        // Schedule next packet transmission
+                                        TxDutyCycleTime = 500; // 5000 ms
+                                        
+                                       
+                                        
+                                    }
+                                    else
+                                    {
+                                                                               
+                                        // Schedule next packet transmission
+                                        TxDutyCycleTime = 75;//APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
+                                    }
+
+                                    DeviceState = DEVICE_STATE_CYCLE;
+                                    
+                                  
+                                   
+                                    break;
+                                }
+                                case DEVICE_STATE_CYCLE:
                                 {
-                                    SerialDisplayUpdateUplinkAcked( false );
-                                    SerialDisplayUpdateDonwlinkRxData( false );
-                          
-                                                     ///prepare tx 
-                                                    PrepareTxFrame( AppPort,data_packet[0] );
-                                                    NextTx = SendFrame( );
-                                       
-                                                
-                                }
-                                if( ComplianceTest.Running == true )
-                                {
-                                    // Schedule next packet transmission
-                                    TxDutyCycleTime = 1000; // 5000 ms
-                                }
-                                else
-                                {
+                                    //
+                                    
+                                    
                                     // Schedule next packet transmission
-                                    TxDutyCycleTime = APP_TX_DUTYCYCLE + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND );
+                                    TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
+                                    TimerStart( &TxNextPacketTimer );
+                                    DeviceState = DEVICE_STATE_SLEEP;
+                                    break;
                                 }
-                                DeviceState = DEVICE_STATE_CYCLE;
-                                break;
-                            }
-                            case DEVICE_STATE_CYCLE:
-                            {
-                                DeviceState = DEVICE_STATE_SLEEP;
-                                // Schedule next packet transmission
-                                TimerSetValue( &TxNextPacketTimer, TxDutyCycleTime );
-                                TimerStart( &TxNextPacketTimer );
-                                break;
+                                case DEVICE_STATE_SLEEP:
+                                {
+                                    // Wake up through events
+                                    break;
+                                }
+                                default:
+                                {
+                                    DeviceState = DEVICE_STATE_INIT;
+                                    break;
+                                }
+                                          
                             }
-                            case DEVICE_STATE_SLEEP:
-                            {
-                               
-                                // Wake up through events
-                                break;
-                            }
-                            default:
-                            {
-                                DeviceState = DEVICE_STATE_INIT;
-                                break;
-                            }
-                                      
+                            
                         }
-                        break; 
+                    break; 
                     } 
                     case 1 : //bouton enclenché
                     {
                         SerialDisplayRTCactive(etat);
                         saisie_serie(tabd);
                         SerialDisplayTIME(tabd);
+                        //chk_and_set_time(tabd);
                         config_s=unix_timestamp(tabd);
                         set_time(config_s);
                         //printf( "%d\r\n",etat);
@@ -933,4 +967,3 @@
                    
     }
 }
-
--- a/app/unixtimestamp.cpp	Wed Jan 23 16:28:51 2019 +0000
+++ b/app/unixtimestamp.cpp	Wed Feb 06 19:16:44 2019 +0000
@@ -11,6 +11,35 @@
     return seconde;
 }
 
+/*
+void chk_and_set_time(int date[6])
+{
+    
+    struct tm t;
+    time_t seconds;
+
+
+        t.tm_year       = date[5];
+
+        t.tm_mon        = date[4];
+
+        t.tm_mday       = date[3];
+
+        t.tm_hour       = date[0];
+
+        t.tm_min        = date[1];
+
+        t.tm_sec        = date[2];
+
+
+    seconds = mktime(&t);
+    set_time(seconds);
+     printf(
+        "Date: %04d/%02d/%02d, %02d:%02d:%02d\r\n",
+        t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec
+    );
+}*/
+
 int bissextile (int an)
 {
     int bi = 0;
--- a/app/unixtimestamp.h	Wed Jan 23 16:28:51 2019 +0000
+++ b/app/unixtimestamp.h	Wed Feb 06 19:16:44 2019 +0000
@@ -13,6 +13,7 @@
 int an_to_s (int an);
 void Whex_buffer(int deb,int tab[8]);
 void saisie_serie(int tab[6]);
+//void chk_and_set_time(int date[6]);
 
 
 #endif
\ No newline at end of file