Commit f766505cd77353733233b4b839471548a6c0ee96
1 parent
64abd45d
création d'une trame début envoi ok
Showing
2 changed files
with
24 additions
and
13 deletions
Show diff stats
No preview for this file type
emetteur/emetteur.cpp
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | #include "sx1276-hal.h" |
6 | 6 | #include "debug.h" |
7 | 7 | //////////////////////////////////////////////////////////////////////////////// |
8 | -#define DEBUG_MESSAGE 1 | |
8 | +#define DEBUG_MESSAGE 0 | |
9 | 9 | //////////////////////////////////////////////////////////////////////////////// |
10 | 10 | //Modulation LoRa active |
11 | 11 | #define USE_MODEM_LORA 1 |
... | ... | @@ -49,7 +49,17 @@ uint16_t BufferSize = BUFFER_SIZE; |
49 | 49 | uint8_t Buffer[BUFFER_SIZE]; |
50 | 50 | int16_t RssiValue = 0.0; |
51 | 51 | int8_t SnrValue = 0.0; |
52 | -const uint8_t TestMsg[] = "TEST"; | |
52 | +const uint8_t TestMsg[] = "37"; | |
53 | +//////////////////////////////////////////////////////////////////////////////// | |
54 | + | |
55 | +//////////////////////////////////////////////////////////////////////////////// | |
56 | +//Création d'une trame | |
57 | +/* | |
58 | +[1...] : ID de l'emetteur | |
59 | +[...] : ID du recepteur cible | |
60 | +[...] : Température communiquée | |
61 | +[...] : Bit de parité pour sécurité | |
62 | +*/ | |
53 | 63 | //////////////////////////////////////////////////////////////////////////////// |
54 | 64 | |
55 | 65 | //////////////////////////////////////////////////////////////////////////////// |
... | ... | @@ -61,7 +71,7 @@ void OnTxDone( void ) |
61 | 71 | Radio.SetChannel( HoppingFrequencies[0] ); |
62 | 72 | Radio.Sleep( ); |
63 | 73 | State = TX; |
64 | - debug_if( DEBUG_MESSAGE, "Envoye\n\r" ); | |
74 | + debug_if( DEBUG_MESSAGE, "\nEnvoye \n\r" ); | |
65 | 75 | } |
66 | 76 | |
67 | 77 | //Time out de transmission. Échec de l'envoi |
... | ... | @@ -70,7 +80,7 @@ void OnTxTimeout( void ) |
70 | 80 | Radio.SetChannel(HoppingFrequencies[0]); |
71 | 81 | Radio.Sleep( ); |
72 | 82 | State = TX_TIMEOUT; |
73 | - debug_if( DEBUG_MESSAGE, "Echec de l'envoi\n\r" ); | |
83 | + debug_if( DEBUG_MESSAGE, "Echec de l'envoi \n\r"); | |
74 | 84 | } |
75 | 85 | |
76 | 86 | //Modification du canal d'emission |
... | ... | @@ -86,7 +96,7 @@ void OnFhssChangeChannel( uint8_t channelIndex ) |
86 | 96 | int main( void ) |
87 | 97 | { |
88 | 98 | uint8_t i; |
89 | - debug("\n\n\rEmetteur SX1276\n\n\r"); | |
99 | + debug("\nEmetteur SX1276 \n\n\r"); | |
90 | 100 | |
91 | 101 | // Initialize Radio driver |
92 | 102 | RadioEvents.TxDone = OnTxDone; |
... | ... | @@ -102,16 +112,16 @@ int main( void ) |
102 | 112 | } |
103 | 113 | |
104 | 114 | //Checking du matériel connecté |
105 | - debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1276MB1LAS ) ), "\n\rMateriel detecte : SX1276MB1LAS < \n\r" ); | |
106 | - debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1276MB1MAS ) ), "\n\rMateriel detecte : SX1276MB1MAS < \n\r" ); | |
115 | + debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1276MB1LAS ) ), "\n\r Materiel detecte : SX1276MB1LAS \n\r" ); | |
116 | + debug_if( ( DEBUG_MESSAGE & ( Radio.DetectBoardType( ) == SX1276MB1MAS ) ), "\n\r Materiel detecte : SX1276MB1MAS \n\r" ); | |
107 | 117 | |
108 | 118 | //Paramétrage du canal |
109 | 119 | Radio.SetChannel( HoppingFrequencies[0] ); |
110 | 120 | |
111 | 121 | #if USE_MODEM_LORA == 1 |
112 | 122 | |
113 | - debug_if( LORA_FHSS_ENABLED, "\n\n\rLORA FHSS Mode\n\n\r" ); | |
114 | - debug_if( !LORA_FHSS_ENABLED, "\n\n\rLORA Mode\n\n\r" ); | |
123 | + debug_if( LORA_FHSS_ENABLED, "\n\n\r LORA FHSS Mode \n\n\r" ); | |
124 | + debug_if( !LORA_FHSS_ENABLED, "\n\n\r LORA Mode \n\n\r" ); | |
115 | 125 | |
116 | 126 | //Configuration du modem transmission |
117 | 127 | Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH, |
... | ... | @@ -128,15 +138,16 @@ int main( void ) |
128 | 138 | //Boucle d'émission infinie |
129 | 139 | while(1) |
130 | 140 | { |
131 | - debug( "Tentative d'envoi :\r\n" ); | |
141 | + debug("\nTentative d'envoi : \r\n"); | |
132 | 142 | strcpy((char*)Buffer, (char*)TestMsg); |
133 | - // We fill the buffer with numbers for the payload | |
134 | 143 | for(i=4; i<BufferSize; i++) |
135 | 144 | { |
136 | 145 | Buffer[i] = i - 4; |
137 | 146 | } |
138 | - debug( "Message envoye\r\n" ); | |
139 | - wait_ms(1000); | |
147 | + debug("Temperature : %s",(char*)Buffer); | |
140 | 148 | Radio.Send(Buffer, BufferSize); |
149 | + debug("\nMessage envoye \r\n"); | |
150 | + wait_ms(2000); | |
141 | 151 | } |
142 | 152 | } |
153 | +//////////////////////////////////////////////////////////////////////////////// | ... | ... |