lalallaa

Dependencies:   MMA8452 mbed

Files at this revision

API Documentation at this revision

Comitter:
EtienneB
Date:
Tue Oct 03 01:28:03 2017 +0000
Parent:
0:4a3d5d86258c
Commit message:
Version semi-finale et commentee de la version a valider

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
xbee_command.h Show annotated file Show diff for this revision Revisions of this file
diff -r 4a3d5d86258c -r 6738a65b699f main.cpp
--- a/main.cpp	Tue Oct 03 01:13:51 2017 +0000
+++ b/main.cpp	Tue Oct 03 01:28:03 2017 +0000
@@ -134,7 +134,9 @@
         
     } 
 }
-
+/**
+    Analyse des trames recues par le xbee
+*/
 bool message_received(uint8_t* message_recu){
     uint8_t frame_id = message_recu[3];
     //pc.printf("\n\r frame id = %02X\r\n", frame_id);
@@ -146,7 +148,10 @@
     }
     return true;
 }
-
+/**
+    Envoie de la valeur du pan id lu dans le fichier vers le registre 
+    correspondant du xbee
+*/
 bool xbee_init(uint16_t pan_id){      
     uint8_t MSB_pan_id = get_MSB(PAN_ID);
     uint8_t LSB_pan_id = get_LSB(PAN_ID);
@@ -187,7 +192,9 @@
     
     return true;
 }
-
+/**
+    Envoie de la trame vers le xbee
+*/
 bool send_frame_2xbee(uint8_t* frame, uint8_t frame_length){
     for(uint8_t i = 0; i < frame_length; i++){
         led2 = !led2;
@@ -199,7 +206,9 @@
     return true;
  
 }
-
+/**
+    Mise dans un tableau de la trame recue par le xbee
+*/
 uint8_t receive_Xbee(uint8_t* message_recu){
     uint8_t caratere_recu;
     uint8_t message_length = 0;
@@ -220,7 +229,9 @@
     pc.printf("\r\n"); 
     return message_length;
 }
-
+/**
+    Construit la trame pour envoie de commande AT 
+*/
 uint8_t build_AT_cmd_frame(uint8_t frame_id, uint16_t p_AT_cmd, uint8_t* p_value, uint8_t p_value_length, uint8_t* p_at_cmd_frame){  
     uint8_t at_cmd_char1 = get_MSB(p_AT_cmd);
     uint8_t at_cmd_char2 = get_LSB(p_AT_cmd);
@@ -259,7 +270,9 @@
     
     return frame_index + 1;
 }
-
+/**
+    Construit la trame pour envoie de commande AT a un xbee distant
+*/
 uint8_t build_remote_cmd_request_frame(uint8_t p_frame_id,  uint16_t p_pan_id, uint16_t p_AT_cmd, uint8_t* p_remote_cmd_request_frame){  
     uint64_t mask_mac_id = 0x00000000000000FF;
     
@@ -309,7 +322,9 @@
     
     return frame_index + 1;
 }
-
+/**
+    Construit la trame pour envoie de de trame vers un xbee distant
+*/
 uint8_t build_tx_request_frame(uint8_t* p_mac_address, uint16_t p_pan_id, uint8_t* p_tx_request_frame, uint8_t *data, uint8_t data_length){ //{ST, MSB, LSB, 0x08, frameID, AT_cmd_1, AT_cmd_2, parameter_value (optional), checksum}   
     uint64_t mask_mac_id = 0x00000000000000FF;
     
@@ -326,17 +341,11 @@
     p_tx_request_frame[2] = LSB;           // LSB
     p_tx_request_frame[3] = TX_REQUEST;    // frame type 0x10
     p_tx_request_frame[4] = FRAME_ID01;    // frame id
-    // 64b destination address 5 a 12
+
     for(frame_index = 5; frame_index < 5 + 8; frame_index++){       
         p_tx_request_frame[frame_index]  = p_mac_address[frame_index - 5];
     }    
-    /*
-    for(frame_index = 5; frame_index < 5 + 8; frame_index++){       
-        p_tx_request_frame[frame_index]  = (p_mac_address >> mac_bit_shift) & mask_mac_id;
-        mac_bit_shift = mac_bit_shift - 8;
-    }
-    */
-    // 16b destination network address 13 et 14
+
     p_tx_request_frame[13] = (p_pan_id >> 8) & 0x00FF;    // MSB pan_id 
     p_tx_request_frame[14] = p_pan_id & 0x00FF;   // LSB_pan_id 
     
@@ -359,19 +368,25 @@
     
     return frame_index + 1;
 }
-
+/**
+    Isole les 4 bits les plus significatif dune valeur short et la renvoie 
+    en char
+*/
 uint8_t get_MSB(uint16_t info){
     uint8_t MSB = (info >> 8) & 0x00FF;    
     
     return MSB;
 }
-
+/**
+    Isole les 4 bits les moins significatif dune valeur short et la renvoie 
+    en char
+*/
 uint8_t get_LSB(uint16_t info){
     uint8_t LSB =  info & 0x00FF;
     
     return LSB;
 }
-// Lecture du contact seche (bouton)
+
 uint16_t read_button(){
     if(button){
         return 1;    
@@ -380,25 +395,34 @@
         return 0;
     }
 }
-// Lecture acceleration grav. en x
+
+/**
+    Lecture acceleration grav. en x
+*/
 uint16_t read_acc_x(){
     int x;
     acc.readXCount(&x);
     return (uint16_t)x;
 }
-// Lecture acceleration grav. en y
+/**
+    Lecture acceleration grav. en y
+*/
 uint16_t read_acc_y(){
     int y;
     acc.readYCount(&y);
     return (uint16_t)y;
 }
-// Lecture acceleration grav. en z
+/**
+    Lecture acceleration grav. en z
+*/
 uint16_t read_acc_z(){
     int z;
     acc.readZCount(&z);
     return (uint16_t)z;
 }
-// Lecture de tout les capteurs
+/**
+    Lecture periodique de tout les capteurs
+*/
 void read_capteurs(int frequence, uint16_t* capteurs_value){    
     p_fonction[0] = &read_button;
     p_fonction[1] = &read_acc_x; 
@@ -412,6 +436,10 @@
     
     wait(frequence);
 }
+/**
+    Lecture du fichier de configuration pour etablir la valeur
+    du temps de lecture des capteur et du pan_id (en decimal dans le fichier)
+*/
 void read_config_file(uint16_t *config_variables){    
     char    ch;
     char    valeur[10];
diff -r 4a3d5d86258c -r 6738a65b699f xbee_command.h
--- a/xbee_command.h	Tue Oct 03 01:13:51 2017 +0000
+++ b/xbee_command.h	Tue Oct 03 01:28:03 2017 +0000
@@ -43,6 +43,7 @@
 uint16_t FREQ_LECTURE_CAPTEURS = 0; 
 
 // Fonctions communication entre LPC1768 et XBee
+
 uint8_t build_AT_cmd_frame(uint8_t frame_id, uint16_t p_AT_cmd, uint8_t* p_value, uint8_t p_value_length, uint8_t* p_at_cmd_frame);
 uint8_t build_tx_request_frame(uint8_t* p_mac_address, uint16_t p_pan_id, uint8_t* p_tx_request_frame, uint8_t *data, uint8_t data_length);
 bool    send_frame_2xbee(uint8_t* frame, uint8_t frame_length);