![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
EIoT LoRa node 2 - Working ok
Dependencies: BufferedSerial SX1276GenericLib-node1 mbed
Fork of DISCO-L072CZ-LRWAN1_LoRa_node by
SX1276GenericPingPong/GenericPingPong.cpp@12:a6a37ba1feff, 2018-08-08 (annotated)
- Committer:
- sagilar
- Date:
- Wed Aug 08 22:33:19 2018 +0000
- Revision:
- 12:a6a37ba1feff
- Parent:
- 11:9d7409ebfa57
- Child:
- 13:c2c91cc0467d
LoRa node acquiring analog input and sending to LoRa Server - Working ok
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Helmut64 | 0:c43b6919ae15 | 1 | /* |
Helmut64 | 0:c43b6919ae15 | 2 | * This file contains a copy of the master content sx1276PingPong |
Helmut64 | 0:c43b6919ae15 | 3 | * with adaption for the SX1276Generic environment |
Helmut64 | 0:c43b6919ae15 | 4 | * (c) 2017 Helmut Tschemernjak |
Helmut64 | 0:c43b6919ae15 | 5 | * 30826 Garbsen (Hannover) Germany |
Helmut64 | 0:c43b6919ae15 | 6 | */ |
sagilar | 12:a6a37ba1feff | 7 | |
Helmut64 | 0:c43b6919ae15 | 8 | #include "mbed.h" |
Helmut64 | 0:c43b6919ae15 | 9 | #include "PinMap.h" |
Helmut64 | 0:c43b6919ae15 | 10 | #include "GenericPingPong.h" |
Helmut64 | 0:c43b6919ae15 | 11 | #include "sx1276-mbed-hal.h" |
Helmut64 | 0:c43b6919ae15 | 12 | #include "main.h" |
sagilar | 12:a6a37ba1feff | 13 | #include <string> |
sagilar | 12:a6a37ba1feff | 14 | #include "rtos.h" |
Helmut64 | 0:c43b6919ae15 | 15 | |
Helmut64 | 0:c43b6919ae15 | 16 | #ifdef FEATURE_LORA |
Helmut64 | 0:c43b6919ae15 | 17 | |
Helmut64 | 0:c43b6919ae15 | 18 | /* Set this flag to '1' to display debug messages on the console */ |
Helmut64 | 0:c43b6919ae15 | 19 | #define DEBUG_MESSAGE 1 |
Helmut64 | 0:c43b6919ae15 | 20 | |
Helmut64 | 0:c43b6919ae15 | 21 | /* Set this flag to '1' to use the LoRa modulation or to '0' to use FSK modulation */ |
Helmut64 | 0:c43b6919ae15 | 22 | #define USE_MODEM_LORA 1 |
Helmut64 | 0:c43b6919ae15 | 23 | #define USE_MODEM_FSK !USE_MODEM_LORA |
sagilar | 12:a6a37ba1feff | 24 | #define RF_FREQUENCY RF_FREQUENCY_915_0 // Hz |
sagilar | 12:a6a37ba1feff | 25 | #define TX_OUTPUT_POWER 20 // 20 dBm |
Helmut64 | 0:c43b6919ae15 | 26 | |
Helmut64 | 0:c43b6919ae15 | 27 | #if USE_MODEM_LORA == 1 |
Helmut64 | 0:c43b6919ae15 | 28 | |
Helmut64 | 7:6a8a82bfb0c6 | 29 | #define LORA_BANDWIDTH 125000 // LoRa default, details in SX1276::BandwidthMap |
Helmut64 | 0:c43b6919ae15 | 30 | #define LORA_SPREADING_FACTOR LORA_SF7 |
Helmut64 | 0:c43b6919ae15 | 31 | #define LORA_CODINGRATE LORA_ERROR_CODING_RATE_4_5 |
Helmut64 | 0:c43b6919ae15 | 32 | |
Helmut64 | 0:c43b6919ae15 | 33 | #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx |
Helmut64 | 0:c43b6919ae15 | 34 | #define LORA_SYMBOL_TIMEOUT 5 // Symbols |
Helmut64 | 0:c43b6919ae15 | 35 | #define LORA_FIX_LENGTH_PAYLOAD_ON false |
sagilar | 12:a6a37ba1feff | 36 | #define LORA_FHSS_ENABLED true |
sagilar | 12:a6a37ba1feff | 37 | #define LORA_NB_SYMB_HOP 4 |
Helmut64 | 0:c43b6919ae15 | 38 | #define LORA_IQ_INVERSION_ON false |
Helmut64 | 0:c43b6919ae15 | 39 | #define LORA_CRC_ENABLED true |
sagilar | 12:a6a37ba1feff | 40 | |
Helmut64 | 0:c43b6919ae15 | 41 | #elif USE_MODEM_FSK == 1 |
Helmut64 | 0:c43b6919ae15 | 42 | |
Helmut64 | 0:c43b6919ae15 | 43 | #define FSK_FDEV 25000 // Hz |
Helmut64 | 0:c43b6919ae15 | 44 | #define FSK_DATARATE 19200 // bps |
Helmut64 | 0:c43b6919ae15 | 45 | #define FSK_BANDWIDTH 50000 // Hz |
Helmut64 | 0:c43b6919ae15 | 46 | #define FSK_AFC_BANDWIDTH 83333 // Hz |
Helmut64 | 0:c43b6919ae15 | 47 | #define FSK_PREAMBLE_LENGTH 5 // Same for Tx and Rx |
Helmut64 | 0:c43b6919ae15 | 48 | #define FSK_FIX_LENGTH_PAYLOAD_ON false |
Helmut64 | 0:c43b6919ae15 | 49 | #define FSK_CRC_ENABLED true |
sagilar | 12:a6a37ba1feff | 50 | |
Helmut64 | 0:c43b6919ae15 | 51 | #else |
sagilar | 12:a6a37ba1feff | 52 | #error "Please define a modem in the compiler options." |
sagilar | 12:a6a37ba1feff | 53 | #endif |
Helmut64 | 0:c43b6919ae15 | 54 | |
Helmut64 | 0:c43b6919ae15 | 55 | |
Helmut64 | 0:c43b6919ae15 | 56 | #define RX_TIMEOUT_VALUE 3500 // in ms |
Helmut64 | 0:c43b6919ae15 | 57 | |
Helmut64 | 0:c43b6919ae15 | 58 | //#define BUFFER_SIZE 32 // Define the payload size here |
Helmut64 | 0:c43b6919ae15 | 59 | #define BUFFER_SIZE 64 // Define the payload size here |
sagilar | 12:a6a37ba1feff | 60 | #define RETRIES 3 // Se define la cantidad de intentos de envio despues de recibir error |
Helmut64 | 0:c43b6919ae15 | 61 | /* |
Helmut64 | 0:c43b6919ae15 | 62 | * Global variables declarations |
Helmut64 | 0:c43b6919ae15 | 63 | */ |
sagilar | 12:a6a37ba1feff | 64 | typedef enum { |
Helmut64 | 0:c43b6919ae15 | 65 | LOWPOWER = 0, |
Helmut64 | 0:c43b6919ae15 | 66 | IDLE, |
sagilar | 12:a6a37ba1feff | 67 | |
Helmut64 | 0:c43b6919ae15 | 68 | RX, |
Helmut64 | 0:c43b6919ae15 | 69 | RX_TIMEOUT, |
Helmut64 | 0:c43b6919ae15 | 70 | RX_ERROR, |
sagilar | 12:a6a37ba1feff | 71 | |
Helmut64 | 0:c43b6919ae15 | 72 | TX, |
Helmut64 | 0:c43b6919ae15 | 73 | TX_TIMEOUT, |
sagilar | 12:a6a37ba1feff | 74 | |
Helmut64 | 0:c43b6919ae15 | 75 | CAD, |
Helmut64 | 0:c43b6919ae15 | 76 | CAD_DONE |
Helmut64 | 0:c43b6919ae15 | 77 | } AppStates_t; |
Helmut64 | 0:c43b6919ae15 | 78 | |
Helmut64 | 0:c43b6919ae15 | 79 | volatile AppStates_t State = LOWPOWER; |
Helmut64 | 0:c43b6919ae15 | 80 | |
Helmut64 | 0:c43b6919ae15 | 81 | /*! |
Helmut64 | 0:c43b6919ae15 | 82 | * Radio events function pointer |
Helmut64 | 0:c43b6919ae15 | 83 | */ |
Helmut64 | 0:c43b6919ae15 | 84 | static RadioEvents_t RadioEvents; |
Helmut64 | 0:c43b6919ae15 | 85 | |
Helmut64 | 0:c43b6919ae15 | 86 | /* |
Helmut64 | 0:c43b6919ae15 | 87 | * Global variables declarations |
Helmut64 | 0:c43b6919ae15 | 88 | */ |
Helmut64 | 0:c43b6919ae15 | 89 | SX1276Generic *Radio; |
Helmut64 | 0:c43b6919ae15 | 90 | |
Helmut64 | 0:c43b6919ae15 | 91 | |
sagilar | 12:a6a37ba1feff | 92 | //const uint8_t PingMsg[] = { 0xff, 0xff, 0x00, 0x00, 'P', 'I', 'N', 'G'};// "PING"; |
sagilar | 12:a6a37ba1feff | 93 | //const uint8_t PongMsg[] = { 0xff, 0xff, 0x00, 0x00, 'P', 'O', 'N', 'G'};// "PONG"; |
sagilar | 12:a6a37ba1feff | 94 | //const uint8_t PingMsg[] = { 'M', 'S', 'J', ' ','G','I','L'};// "PING"; |
sagilar | 12:a6a37ba1feff | 95 | //const uint8_t PongMsg[] = { 'R', 'P', 'T', 'A',' ','G','I','L'};// "PONG"; |
sagilar | 12:a6a37ba1feff | 96 | const char EUI[] = "0A10";// 4 bytes que definen el identificador del dispositivo (copiar los bytes en string) |
sagilar | 12:a6a37ba1feff | 97 | const char AppEUI[] = "AAAA";// 4 bytes que definen el identificador de la aplicacion (copiar los bytes en string) |
sagilar | 12:a6a37ba1feff | 98 | const char AppKey[] = "1A1B";// 4 bytes que definen la clave de la aplicacion (copiar los bytes en string) - El protocolo LoRaWAN establece la clave de 16 bytes pero para efectos de prueba se hara de 4 |
sagilar | 12:a6a37ba1feff | 99 | char MsgTX[64] = "";// Mensaje de transmision, se pueden usar los 52 bytes faltantes para completar el payload de 64 bytes. Se puede poner directamente en string. |
sagilar | 12:a6a37ba1feff | 100 | char MsgRX[64] = "";// Mensaje de recepcion, carga el payload entrante a esta cadena. |
sagilar | 12:a6a37ba1feff | 101 | char MsgRet[] = "RECIBIDO";// Para verificar el resultado del envio |
sagilar | 12:a6a37ba1feff | 102 | char DestEUI[] = "0A01"; //Gateway Server |
sagilar | 12:a6a37ba1feff | 103 | string strRecepcion = ""; |
Helmut64 | 0:c43b6919ae15 | 104 | uint16_t BufferSize = BUFFER_SIZE; |
Helmut64 | 0:c43b6919ae15 | 105 | uint8_t *Buffer; |
sagilar | 12:a6a37ba1feff | 106 | int reintentos=0; |
sagilar | 12:a6a37ba1feff | 107 | string msjDeco=""; |
sagilar | 12:a6a37ba1feff | 108 | char *retParse; |
sagilar | 12:a6a37ba1feff | 109 | char *srcEUI; |
sagilar | 12:a6a37ba1feff | 110 | char *msjDestEUI; |
sagilar | 12:a6a37ba1feff | 111 | char *msjContent; |
sagilar | 12:a6a37ba1feff | 112 | AnalogIn analog_value(A0); |
sagilar | 12:a6a37ba1feff | 113 | //RtosTimer analog_read_timer(readAnalog, osTimerPeriodic); |
sagilar | 12:a6a37ba1feff | 114 | |
sagilar | 12:a6a37ba1feff | 115 | |
sagilar | 12:a6a37ba1feff | 116 | float meas_r; |
sagilar | 12:a6a37ba1feff | 117 | float meas_v; |
Helmut64 | 0:c43b6919ae15 | 118 | |
Helmut64 | 0:c43b6919ae15 | 119 | DigitalOut *led3; |
Helmut64 | 0:c43b6919ae15 | 120 | |
Helmut64 | 0:c43b6919ae15 | 121 | |
sagilar | 12:a6a37ba1feff | 122 | int SX1276PingPong() |
Helmut64 | 0:c43b6919ae15 | 123 | { |
sagilar | 12:a6a37ba1feff | 124 | Ticker tick; |
sagilar | 12:a6a37ba1feff | 125 | tick.attach(&readAnalog,10.0); |
sagilar | 12:a6a37ba1feff | 126 | |
sagilar | 12:a6a37ba1feff | 127 | uint8_t i; |
sagilar | 12:a6a37ba1feff | 128 | bool isMaster = true; |
sagilar | 12:a6a37ba1feff | 129 | |
sagilar | 12:a6a37ba1feff | 130 | |
sagilar | 12:a6a37ba1feff | 131 | |
Helmut64 | 0:c43b6919ae15 | 132 | #if( defined ( TARGET_KL25Z ) || defined ( TARGET_LPC11U6X ) ) |
Helmut64 | 0:c43b6919ae15 | 133 | DigitalOut *led = new DigitalOut(LED2); |
bcostm | 11:9d7409ebfa57 | 134 | #elif defined(TARGET_NUCLEO_L073RZ) || defined(TARGET_DISCO_L072CZ_LRWAN1) |
Helmut64 | 0:c43b6919ae15 | 135 | DigitalOut *led = new DigitalOut(LED4); // RX red |
Helmut64 | 0:c43b6919ae15 | 136 | led3 = new DigitalOut(LED3); // TX blue |
Helmut64 | 0:c43b6919ae15 | 137 | #else |
Helmut64 | 0:c43b6919ae15 | 138 | DigitalOut *led = new DigitalOut(LED1); |
Helmut64 | 0:c43b6919ae15 | 139 | led3 = led; |
Helmut64 | 0:c43b6919ae15 | 140 | #endif |
sagilar | 12:a6a37ba1feff | 141 | |
Helmut64 | 0:c43b6919ae15 | 142 | Buffer = new uint8_t[BUFFER_SIZE]; |
Helmut64 | 0:c43b6919ae15 | 143 | *led3 = 1; |
Helmut64 | 0:c43b6919ae15 | 144 | |
Helmut64 | 0:c43b6919ae15 | 145 | #ifdef B_L072Z_LRWAN1_LORA |
Helmut64 | 0:c43b6919ae15 | 146 | Radio = new SX1276Generic(NULL, MURATA_SX1276, |
sagilar | 12:a6a37ba1feff | 147 | LORA_SPI_MOSI, LORA_SPI_MISO, LORA_SPI_SCLK, LORA_CS, LORA_RESET, |
sagilar | 12:a6a37ba1feff | 148 | LORA_DIO0, LORA_DIO1, LORA_DIO2, LORA_DIO3, LORA_DIO4, LORA_DIO5, |
sagilar | 12:a6a37ba1feff | 149 | LORA_ANT_RX, LORA_ANT_TX, LORA_ANT_BOOST, LORA_TCXO); |
Helmut64 | 0:c43b6919ae15 | 150 | #else // RFM95 |
Helmut64 | 0:c43b6919ae15 | 151 | Radio = new SX1276Generic(NULL, RFM95_SX1276, |
sagilar | 12:a6a37ba1feff | 152 | LORA_SPI_MOSI, LORA_SPI_MISO, LORA_SPI_SCLK, LORA_CS, LORA_RESET, |
sagilar | 12:a6a37ba1feff | 153 | LORA_DIO0, LORA_DIO1, LORA_DIO2, LORA_DIO3, LORA_DIO4, LORA_DIO5); |
Helmut64 | 0:c43b6919ae15 | 154 | |
Helmut64 | 0:c43b6919ae15 | 155 | #endif |
sagilar | 12:a6a37ba1feff | 156 | |
sagilar | 12:a6a37ba1feff | 157 | dprintf("Aplicacion de comunicacion LoRa punto a punto" ); |
sagilar | 12:a6a37ba1feff | 158 | dprintf("Frecuencia: %.1f", (double)RF_FREQUENCY/1000000.0); |
Helmut64 | 0:c43b6919ae15 | 159 | dprintf("TXPower: %d dBm", TX_OUTPUT_POWER); |
Helmut64 | 0:c43b6919ae15 | 160 | #if USE_MODEM_LORA == 1 |
Helmut64 | 8:3b0d7b4ff28f | 161 | dprintf("Bandwidth: %d Hz", LORA_BANDWIDTH); |
Helmut64 | 0:c43b6919ae15 | 162 | dprintf("Spreading factor: SF%d", LORA_SPREADING_FACTOR); |
Helmut64 | 0:c43b6919ae15 | 163 | #elif USE_MODEM_FSK == 1 |
Helmut64 | 0:c43b6919ae15 | 164 | dprintf("Bandwidth: %d kHz", FSK_BANDWIDTH); |
Helmut64 | 0:c43b6919ae15 | 165 | dprintf("Baudrate: %d", FSK_DATARATE); |
Helmut64 | 0:c43b6919ae15 | 166 | #endif |
Helmut64 | 0:c43b6919ae15 | 167 | // Initialize Radio driver |
Helmut64 | 0:c43b6919ae15 | 168 | RadioEvents.TxDone = OnTxDone; |
Helmut64 | 0:c43b6919ae15 | 169 | RadioEvents.RxDone = OnRxDone; |
Helmut64 | 0:c43b6919ae15 | 170 | RadioEvents.RxError = OnRxError; |
Helmut64 | 0:c43b6919ae15 | 171 | RadioEvents.TxTimeout = OnTxTimeout; |
sagilar | 12:a6a37ba1feff | 172 | RadioEvents.RxTimeout = OnRxTimeout; |
Helmut64 | 6:1b598b0e52e4 | 173 | if (Radio->Init( &RadioEvents ) == false) { |
Helmut64 | 6:1b598b0e52e4 | 174 | while(1) { |
sagilar | 12:a6a37ba1feff | 175 | dprintf("Radio could not be detected!"); |
sagilar | 12:a6a37ba1feff | 176 | wait( 1 ); |
Helmut64 | 6:1b598b0e52e4 | 177 | } |
Helmut64 | 0:c43b6919ae15 | 178 | } |
Helmut64 | 6:1b598b0e52e4 | 179 | |
sagilar | 12:a6a37ba1feff | 180 | |
Helmut64 | 0:c43b6919ae15 | 181 | switch(Radio->DetectBoardType()) { |
Helmut64 | 0:c43b6919ae15 | 182 | case SX1276MB1LAS: |
Helmut64 | 0:c43b6919ae15 | 183 | if (DEBUG_MESSAGE) |
Helmut64 | 0:c43b6919ae15 | 184 | dprintf(" > Board Type: SX1276MB1LAS <"); |
Helmut64 | 0:c43b6919ae15 | 185 | break; |
Helmut64 | 0:c43b6919ae15 | 186 | case SX1276MB1MAS: |
Helmut64 | 0:c43b6919ae15 | 187 | if (DEBUG_MESSAGE) |
Helmut64 | 0:c43b6919ae15 | 188 | dprintf(" > Board Type: SX1276MB1LAS <"); |
Helmut64 | 0:c43b6919ae15 | 189 | case MURATA_SX1276: |
Helmut64 | 0:c43b6919ae15 | 190 | if (DEBUG_MESSAGE) |
sagilar | 12:a6a37ba1feff | 191 | dprintf(" > Board Type: MURATA_SX1276_STM32L0 <"); |
Helmut64 | 0:c43b6919ae15 | 192 | break; |
Helmut64 | 0:c43b6919ae15 | 193 | case RFM95_SX1276: |
Helmut64 | 0:c43b6919ae15 | 194 | if (DEBUG_MESSAGE) |
Helmut64 | 0:c43b6919ae15 | 195 | dprintf(" > HopeRF RFM95xx <"); |
Helmut64 | 0:c43b6919ae15 | 196 | break; |
Helmut64 | 0:c43b6919ae15 | 197 | default: |
Helmut64 | 0:c43b6919ae15 | 198 | dprintf(" > Board Type: unknown <"); |
Helmut64 | 0:c43b6919ae15 | 199 | } |
Helmut64 | 0:c43b6919ae15 | 200 | |
sagilar | 12:a6a37ba1feff | 201 | Radio->SetChannel(RF_FREQUENCY ); |
Helmut64 | 0:c43b6919ae15 | 202 | |
Helmut64 | 0:c43b6919ae15 | 203 | #if USE_MODEM_LORA == 1 |
sagilar | 12:a6a37ba1feff | 204 | |
Helmut64 | 0:c43b6919ae15 | 205 | if (LORA_FHSS_ENABLED) |
Helmut64 | 0:c43b6919ae15 | 206 | dprintf(" > LORA FHSS Mode <"); |
Helmut64 | 0:c43b6919ae15 | 207 | if (!LORA_FHSS_ENABLED) |
Helmut64 | 0:c43b6919ae15 | 208 | dprintf(" > LORA Mode <"); |
Helmut64 | 0:c43b6919ae15 | 209 | |
Helmut64 | 0:c43b6919ae15 | 210 | Radio->SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH, |
sagilar | 12:a6a37ba1feff | 211 | LORA_SPREADING_FACTOR, LORA_CODINGRATE, |
sagilar | 12:a6a37ba1feff | 212 | LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON, |
sagilar | 12:a6a37ba1feff | 213 | LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP, |
sagilar | 12:a6a37ba1feff | 214 | LORA_IQ_INVERSION_ON, 2000 ); |
sagilar | 12:a6a37ba1feff | 215 | |
Helmut64 | 0:c43b6919ae15 | 216 | Radio->SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR, |
sagilar | 12:a6a37ba1feff | 217 | LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH, |
sagilar | 12:a6a37ba1feff | 218 | LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON, 0, |
sagilar | 12:a6a37ba1feff | 219 | LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP, |
sagilar | 12:a6a37ba1feff | 220 | LORA_IQ_INVERSION_ON, true ); |
sagilar | 12:a6a37ba1feff | 221 | |
Helmut64 | 0:c43b6919ae15 | 222 | #elif USE_MODEM_FSK == 1 |
Helmut64 | 0:c43b6919ae15 | 223 | |
Helmut64 | 0:c43b6919ae15 | 224 | dprintf(" > FSK Mode <"); |
Helmut64 | 0:c43b6919ae15 | 225 | Radio->SetTxConfig( MODEM_FSK, TX_OUTPUT_POWER, FSK_FDEV, 0, |
sagilar | 12:a6a37ba1feff | 226 | FSK_DATARATE, 0, |
sagilar | 12:a6a37ba1feff | 227 | FSK_PREAMBLE_LENGTH, FSK_FIX_LENGTH_PAYLOAD_ON, |
sagilar | 12:a6a37ba1feff | 228 | FSK_CRC_ENABLED, 0, 0, 0, 2000 ); |
sagilar | 12:a6a37ba1feff | 229 | |
Helmut64 | 0:c43b6919ae15 | 230 | Radio->SetRxConfig( MODEM_FSK, FSK_BANDWIDTH, FSK_DATARATE, |
sagilar | 12:a6a37ba1feff | 231 | 0, FSK_AFC_BANDWIDTH, FSK_PREAMBLE_LENGTH, |
sagilar | 12:a6a37ba1feff | 232 | 0, FSK_FIX_LENGTH_PAYLOAD_ON, 0, FSK_CRC_ENABLED, |
sagilar | 12:a6a37ba1feff | 233 | 0, 0, false, true ); |
sagilar | 12:a6a37ba1feff | 234 | |
Helmut64 | 0:c43b6919ae15 | 235 | #else |
Helmut64 | 0:c43b6919ae15 | 236 | |
Helmut64 | 0:c43b6919ae15 | 237 | #error "Please define a modem in the compiler options." |
Helmut64 | 0:c43b6919ae15 | 238 | |
Helmut64 | 0:c43b6919ae15 | 239 | #endif |
Helmut64 | 0:c43b6919ae15 | 240 | |
sagilar | 12:a6a37ba1feff | 241 | if (DEBUG_MESSAGE) |
sagilar | 12:a6a37ba1feff | 242 | dprintf("Inicializando nodo"); |
sagilar | 12:a6a37ba1feff | 243 | dprintf("EUI (ID): %s",EUI); |
sagilar | 12:a6a37ba1feff | 244 | |
Helmut64 | 0:c43b6919ae15 | 245 | Radio->Rx( RX_TIMEOUT_VALUE ); |
sagilar | 12:a6a37ba1feff | 246 | |
sagilar | 12:a6a37ba1feff | 247 | while( 1 ) { |
Helmut64 | 0:c43b6919ae15 | 248 | #ifdef TARGET_STM32L4 |
Helmut64 | 0:c43b6919ae15 | 249 | WatchDogUpdate(); |
Helmut64 | 0:c43b6919ae15 | 250 | #endif |
sagilar | 12:a6a37ba1feff | 251 | /* |
sagilar | 12:a6a37ba1feff | 252 | const char EUI[] = "0A10";// 4 bytes que definen el identificador del dispositivo (copiar los bytes en string) |
sagilar | 12:a6a37ba1feff | 253 | const char AppEUI[] = "AAAA";// 4 bytes que definen el identificador de la aplicacion (copiar los bytes en string) |
sagilar | 12:a6a37ba1feff | 254 | const char AppKey[] = "1A1B";// 4 bytes que definen la clave de la aplicacion (copiar los bytes en string) - El protocolo LoRaWAN establece la clave de 16 bytes pero para efectos de prueba se hara de 4 |
sagilar | 12:a6a37ba1feff | 255 | char MsgTX[64] = "";// Mensaje de transmision, se pueden usar los 52 bytes faltantes para completar el payload de 64 bytes. Se puede poner directamente en string. |
sagilar | 12:a6a37ba1feff | 256 | char MsgRX[64] = "";// Mensaje de recepcion, carga el payload entrante a esta cadena. |
sagilar | 12:a6a37ba1feff | 257 | char MsgRet[] = "RECIBIDO";// Para verificar el resultado del envio |
sagilar | 12:a6a37ba1feff | 258 | char DestEUI[] = "0A01"; |
sagilar | 12:a6a37ba1feff | 259 | string strRecepcion = ""; |
sagilar | 12:a6a37ba1feff | 260 | uint16_t BufferSize = BUFFER_SIZE; |
sagilar | 12:a6a37ba1feff | 261 | uint8_t *Buffer; |
sagilar | 12:a6a37ba1feff | 262 | int reintentos=0; |
sagilar | 12:a6a37ba1feff | 263 | string msjDeco=""; |
sagilar | 12:a6a37ba1feff | 264 | char *retParse; |
sagilar | 12:a6a37ba1feff | 265 | char *srcEUI; |
sagilar | 12:a6a37ba1feff | 266 | char *msjDestEUI; |
sagilar | 12:a6a37ba1feff | 267 | char *msjContent;*/ |
sagilar | 12:a6a37ba1feff | 268 | |
sagilar | 12:a6a37ba1feff | 269 | switch( State ) { |
sagilar | 12:a6a37ba1feff | 270 | case RX: |
sagilar | 12:a6a37ba1feff | 271 | reintentos=0; |
sagilar | 12:a6a37ba1feff | 272 | *led = !*led; |
sagilar | 12:a6a37ba1feff | 273 | //dprintf("Mensaje para depurar: %s",MsgRX); |
sagilar | 12:a6a37ba1feff | 274 | msjDeco = MsgRX; |
sagilar | 12:a6a37ba1feff | 275 | splitOnPosition(MsgRX, 0); |
sagilar | 12:a6a37ba1feff | 276 | |
sagilar | 12:a6a37ba1feff | 277 | dprintf("Source EUI: %s, Destination EUI: %s, Content: %s",srcEUI,msjDestEUI,msjContent); |
sagilar | 12:a6a37ba1feff | 278 | strRecepcion = msjContent; |
sagilar | 12:a6a37ba1feff | 279 | if(strcmp(EUI,msjDestEUI) == 0) { |
sagilar | 12:a6a37ba1feff | 280 | dprintf("Mismo EUI, Soy el destinatario"); |
sagilar | 12:a6a37ba1feff | 281 | |
sagilar | 12:a6a37ba1feff | 282 | } else { |
sagilar | 12:a6a37ba1feff | 283 | dprintf("Diferente EUI, ignorar mensaje"); |
sagilar | 12:a6a37ba1feff | 284 | wait_ms( 500 ); |
sagilar | 12:a6a37ba1feff | 285 | *led = !*led; |
sagilar | 12:a6a37ba1feff | 286 | State = LOWPOWER; |
sagilar | 12:a6a37ba1feff | 287 | break; |
sagilar | 12:a6a37ba1feff | 288 | } |
sagilar | 12:a6a37ba1feff | 289 | |
sagilar | 12:a6a37ba1feff | 290 | |
sagilar | 12:a6a37ba1feff | 291 | if( BufferSize > 0 ) { |
sagilar | 12:a6a37ba1feff | 292 | |
sagilar | 12:a6a37ba1feff | 293 | if (strstr(msjContent, "RECIBIDO") != NULL) { |
sagilar | 12:a6a37ba1feff | 294 | dprintf( "Mensaje recibido por el servidor correctamente" ); |
sagilar | 12:a6a37ba1feff | 295 | } |
sagilar | 12:a6a37ba1feff | 296 | if (strstr(msjContent, "ERROR") != NULL) { |
sagilar | 12:a6a37ba1feff | 297 | dprintf( "Mensaje no fue recibido por el servidor correctamente" ); |
sagilar | 12:a6a37ba1feff | 298 | } |
sagilar | 12:a6a37ba1feff | 299 | if (strstr(msjContent, "DENIED") != NULL) { |
sagilar | 12:a6a37ba1feff | 300 | dprintf( "Mensaje rechazado por el servidor correctamente" ); |
Helmut64 | 0:c43b6919ae15 | 301 | } |
sagilar | 12:a6a37ba1feff | 302 | /*if( RecFound == true ) { |
sagilar | 12:a6a37ba1feff | 303 | |
sagilar | 12:a6a37ba1feff | 304 | dprintf( "Mensaje recibido por el servidor correctamente" ); |
sagilar | 12:a6a37ba1feff | 305 | } else if(ErrorFound == true) { // Error en la recepcion |
sagilar | 12:a6a37ba1feff | 306 | dprintf( "Mensaje no fue recibido por el servidor correctamente" ); |
sagilar | 12:a6a37ba1feff | 307 | |
sagilar | 12:a6a37ba1feff | 308 | } else if(DenFound == true) { // Negacion en la recepcion |
sagilar | 12:a6a37ba1feff | 309 | dprintf( "Mensaje rechazado por el servidor correctamente" ); |
sagilar | 12:a6a37ba1feff | 310 | |
sagilar | 12:a6a37ba1feff | 311 | }*/ |
sagilar | 12:a6a37ba1feff | 312 | } |
sagilar | 12:a6a37ba1feff | 313 | wait_ms( 500 ); |
sagilar | 12:a6a37ba1feff | 314 | *led = !*led; |
sagilar | 12:a6a37ba1feff | 315 | State = LOWPOWER; |
sagilar | 12:a6a37ba1feff | 316 | break; |
sagilar | 12:a6a37ba1feff | 317 | case TX: |
sagilar | 12:a6a37ba1feff | 318 | |
sagilar | 12:a6a37ba1feff | 319 | //dprintf("Mensaje a enviar: %s",MsgTX); |
sagilar | 12:a6a37ba1feff | 320 | *led3 = !*led3; |
sagilar | 12:a6a37ba1feff | 321 | |
sagilar | 12:a6a37ba1feff | 322 | if(reintentos<RETRIES) { |
sagilar | 12:a6a37ba1feff | 323 | Radio->Rx( RX_TIMEOUT_VALUE ); |
sagilar | 12:a6a37ba1feff | 324 | reintentos++; |
Helmut64 | 0:c43b6919ae15 | 325 | } |
sagilar | 12:a6a37ba1feff | 326 | wait_ms( 500 ); |
sagilar | 12:a6a37ba1feff | 327 | *led = !*led; |
sagilar | 12:a6a37ba1feff | 328 | State = LOWPOWER; |
sagilar | 12:a6a37ba1feff | 329 | break; |
sagilar | 12:a6a37ba1feff | 330 | case RX_TIMEOUT: |
sagilar | 12:a6a37ba1feff | 331 | if( isMaster == true ) { |
sagilar | 12:a6a37ba1feff | 332 | // Send the next PING frame |
sagilar | 12:a6a37ba1feff | 333 | memcpy(Buffer, MsgTX, sizeof(MsgTX)); |
sagilar | 12:a6a37ba1feff | 334 | for( i = sizeof(MsgTX); i < BufferSize; i++ ) { |
sagilar | 12:a6a37ba1feff | 335 | Buffer[i] = i - sizeof(MsgTX); |
Helmut64 | 0:c43b6919ae15 | 336 | } |
sagilar | 12:a6a37ba1feff | 337 | wait_ms( 1000 ); |
sagilar | 12:a6a37ba1feff | 338 | Radio->Send( Buffer, BufferSize ); |
sagilar | 12:a6a37ba1feff | 339 | } else { |
sagilar | 12:a6a37ba1feff | 340 | Radio->Rx( RX_TIMEOUT_VALUE ); |
sagilar | 12:a6a37ba1feff | 341 | } |
sagilar | 12:a6a37ba1feff | 342 | State = LOWPOWER; |
sagilar | 12:a6a37ba1feff | 343 | break; |
sagilar | 12:a6a37ba1feff | 344 | case RX_ERROR: |
sagilar | 12:a6a37ba1feff | 345 | // We have received a Packet with a CRC error, send reply as if packet was correct |
sagilar | 12:a6a37ba1feff | 346 | if( isMaster == true ) { |
sagilar | 12:a6a37ba1feff | 347 | // Send the next PING frame |
sagilar | 12:a6a37ba1feff | 348 | memcpy(Buffer, MsgTX, sizeof(MsgTX)); |
sagilar | 12:a6a37ba1feff | 349 | for( i = 4; i < BufferSize; i++ ) { |
sagilar | 12:a6a37ba1feff | 350 | Buffer[i] = i - 4; |
sagilar | 12:a6a37ba1feff | 351 | } |
sagilar | 12:a6a37ba1feff | 352 | wait_ms( 1000 ); |
sagilar | 12:a6a37ba1feff | 353 | Radio->Send( Buffer, BufferSize ); |
sagilar | 12:a6a37ba1feff | 354 | } else { |
sagilar | 12:a6a37ba1feff | 355 | // Send the next PONG frame |
sagilar | 12:a6a37ba1feff | 356 | memcpy(Buffer, MsgTX, sizeof(MsgTX)); |
sagilar | 12:a6a37ba1feff | 357 | for( i = sizeof(MsgTX); i < BufferSize; i++ ) { |
sagilar | 12:a6a37ba1feff | 358 | Buffer[i] = i - sizeof(MsgTX); |
sagilar | 12:a6a37ba1feff | 359 | } |
sagilar | 12:a6a37ba1feff | 360 | wait_ms( 1000 ); |
sagilar | 12:a6a37ba1feff | 361 | Radio->Send( Buffer, BufferSize ); |
Helmut64 | 0:c43b6919ae15 | 362 | } |
sagilar | 12:a6a37ba1feff | 363 | State = LOWPOWER; |
sagilar | 12:a6a37ba1feff | 364 | break; |
sagilar | 12:a6a37ba1feff | 365 | case TX_TIMEOUT: |
sagilar | 12:a6a37ba1feff | 366 | Radio->Rx( RX_TIMEOUT_VALUE ); |
sagilar | 12:a6a37ba1feff | 367 | State = LOWPOWER; |
sagilar | 12:a6a37ba1feff | 368 | break; |
sagilar | 12:a6a37ba1feff | 369 | case LOWPOWER: |
sagilar | 12:a6a37ba1feff | 370 | sleep(); |
sagilar | 12:a6a37ba1feff | 371 | break; |
sagilar | 12:a6a37ba1feff | 372 | default: |
sagilar | 12:a6a37ba1feff | 373 | State = LOWPOWER; |
sagilar | 12:a6a37ba1feff | 374 | break; |
sagilar | 12:a6a37ba1feff | 375 | } |
sagilar | 12:a6a37ba1feff | 376 | } |
sagilar | 12:a6a37ba1feff | 377 | } |
sagilar | 12:a6a37ba1feff | 378 | |
sagilar | 12:a6a37ba1feff | 379 | char *splitOnPosition(char *msj, int pos) |
sagilar | 12:a6a37ba1feff | 380 | { |
sagilar | 12:a6a37ba1feff | 381 | int i=0; |
sagilar | 12:a6a37ba1feff | 382 | char *substring = strtok (msj,"|"); |
sagilar | 12:a6a37ba1feff | 383 | char *strOutput=""; |
sagilar | 12:a6a37ba1feff | 384 | while (substring != NULL) { |
sagilar | 12:a6a37ba1feff | 385 | //dprintf ("substring: %s, index: %d",substring,i); |
sagilar | 12:a6a37ba1feff | 386 | |
sagilar | 12:a6a37ba1feff | 387 | if(i == 0) { |
sagilar | 12:a6a37ba1feff | 388 | srcEUI = substring; |
sagilar | 12:a6a37ba1feff | 389 | } else if(i == 3) { |
sagilar | 12:a6a37ba1feff | 390 | msjDestEUI = substring; |
sagilar | 12:a6a37ba1feff | 391 | } else if(i == 4) { |
sagilar | 12:a6a37ba1feff | 392 | msjContent = substring; |
sagilar | 12:a6a37ba1feff | 393 | } else if(i > 4) { |
sagilar | 12:a6a37ba1feff | 394 | strcat(msjContent," "); |
sagilar | 12:a6a37ba1feff | 395 | strcat(msjContent,substring); |
sagilar | 12:a6a37ba1feff | 396 | } |
sagilar | 12:a6a37ba1feff | 397 | |
sagilar | 12:a6a37ba1feff | 398 | if(i == pos) { |
sagilar | 12:a6a37ba1feff | 399 | strOutput = substring; |
sagilar | 12:a6a37ba1feff | 400 | } |
sagilar | 12:a6a37ba1feff | 401 | substring = strtok (NULL, "|"); |
sagilar | 12:a6a37ba1feff | 402 | i++; |
Helmut64 | 0:c43b6919ae15 | 403 | } |
sagilar | 12:a6a37ba1feff | 404 | return strOutput; |
sagilar | 12:a6a37ba1feff | 405 | } |
sagilar | 12:a6a37ba1feff | 406 | |
sagilar | 12:a6a37ba1feff | 407 | void onButtonEvent() |
sagilar | 12:a6a37ba1feff | 408 | { |
sagilar | 12:a6a37ba1feff | 409 | reintentos=0; |
sagilar | 12:a6a37ba1feff | 410 | float value = 3.478; |
sagilar | 12:a6a37ba1feff | 411 | char valueStr[]=""; |
sagilar | 12:a6a37ba1feff | 412 | sprintf(valueStr,"%.3f",value); |
sagilar | 12:a6a37ba1feff | 413 | char variable[] = "corriente"; |
sagilar | 12:a6a37ba1feff | 414 | char dispositivo[] = "extrusador"; |
sagilar | 12:a6a37ba1feff | 415 | strcpy(MsgTX, EUI); |
sagilar | 12:a6a37ba1feff | 416 | strcat(MsgTX, "|"); |
sagilar | 12:a6a37ba1feff | 417 | strcat(MsgTX, AppEUI); |
sagilar | 12:a6a37ba1feff | 418 | strcat(MsgTX, "|"); |
sagilar | 12:a6a37ba1feff | 419 | strcat(MsgTX, AppKey); |
sagilar | 12:a6a37ba1feff | 420 | strcat(MsgTX, "|"); |
sagilar | 12:a6a37ba1feff | 421 | strcat(MsgTX, DestEUI); |
sagilar | 12:a6a37ba1feff | 422 | strcat(MsgTX, "|"); |
sagilar | 12:a6a37ba1feff | 423 | strcat(MsgTX, valueStr); |
sagilar | 12:a6a37ba1feff | 424 | strcat(MsgTX, " "); |
sagilar | 12:a6a37ba1feff | 425 | strcat(MsgTX, variable); |
sagilar | 12:a6a37ba1feff | 426 | strcat(MsgTX, " "); |
sagilar | 12:a6a37ba1feff | 427 | strcat(MsgTX, dispositivo); |
sagilar | 12:a6a37ba1feff | 428 | //strcat(MsgTX, ";"); |
sagilar | 12:a6a37ba1feff | 429 | //*led = !*led; |
sagilar | 12:a6a37ba1feff | 430 | //dprintf( "Enviando contenido al server" ); |
sagilar | 12:a6a37ba1feff | 431 | memcpy(Buffer, MsgTX, sizeof(MsgTX)); |
sagilar | 12:a6a37ba1feff | 432 | // Se llena el buffer con la informacion a enviar |
sagilar | 12:a6a37ba1feff | 433 | for( int i = sizeof(MsgTX); i < BufferSize; i++ ) { |
sagilar | 12:a6a37ba1feff | 434 | Buffer[i] = i - sizeof(MsgTX); |
sagilar | 12:a6a37ba1feff | 435 | } |
sagilar | 12:a6a37ba1feff | 436 | //wait_ms( 100 ); |
sagilar | 12:a6a37ba1feff | 437 | Radio->Send( Buffer, BufferSize ); |
sagilar | 12:a6a37ba1feff | 438 | Radio->Rx( RX_TIMEOUT_VALUE ); |
sagilar | 12:a6a37ba1feff | 439 | |
sagilar | 12:a6a37ba1feff | 440 | } |
sagilar | 12:a6a37ba1feff | 441 | |
sagilar | 12:a6a37ba1feff | 442 | void readAnalog() |
sagilar | 12:a6a37ba1feff | 443 | { |
sagilar | 12:a6a37ba1feff | 444 | |
sagilar | 12:a6a37ba1feff | 445 | //wait(1); |
sagilar | 12:a6a37ba1feff | 446 | meas_r = analog_value.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) |
sagilar | 12:a6a37ba1feff | 447 | meas_v = meas_r * 3.3; // Converts value in the 0V-3.3V range |
sagilar | 12:a6a37ba1feff | 448 | reintentos=0; |
sagilar | 12:a6a37ba1feff | 449 | char valueStr[]=""; |
sagilar | 12:a6a37ba1feff | 450 | sprintf(valueStr,"%.2f",meas_v); |
sagilar | 12:a6a37ba1feff | 451 | char variable[] = "voltaje"; |
sagilar | 12:a6a37ba1feff | 452 | char dispositivo[] = "nodo1_prueba_LoRa"; |
sagilar | 12:a6a37ba1feff | 453 | //char MsgEnvio[64] = ""; |
sagilar | 12:a6a37ba1feff | 454 | strcpy(MsgTX, EUI); |
sagilar | 12:a6a37ba1feff | 455 | strcat(MsgTX, "|"); |
sagilar | 12:a6a37ba1feff | 456 | strcat(MsgTX, AppEUI); |
sagilar | 12:a6a37ba1feff | 457 | strcat(MsgTX, "|"); |
sagilar | 12:a6a37ba1feff | 458 | strcat(MsgTX, AppKey); |
sagilar | 12:a6a37ba1feff | 459 | strcat(MsgTX, "|"); |
sagilar | 12:a6a37ba1feff | 460 | strcat(MsgTX, DestEUI); |
sagilar | 12:a6a37ba1feff | 461 | strcat(MsgTX, "|"); |
sagilar | 12:a6a37ba1feff | 462 | strcat(MsgTX, valueStr); |
sagilar | 12:a6a37ba1feff | 463 | strcat(MsgTX, " "); |
sagilar | 12:a6a37ba1feff | 464 | strcat(MsgTX, variable); |
sagilar | 12:a6a37ba1feff | 465 | strcat(MsgTX, " "); |
sagilar | 12:a6a37ba1feff | 466 | strcat(MsgTX, dispositivo); |
sagilar | 12:a6a37ba1feff | 467 | //strcat(MsgTX, ";"); |
sagilar | 12:a6a37ba1feff | 468 | //*led = !*led; |
sagilar | 12:a6a37ba1feff | 469 | //dprintf( "Enviando contenido al server" ); |
sagilar | 12:a6a37ba1feff | 470 | memcpy(Buffer, MsgTX, sizeof(MsgTX)); |
sagilar | 12:a6a37ba1feff | 471 | // Se llena el buffer con la informacion a enviar |
sagilar | 12:a6a37ba1feff | 472 | for( int i = sizeof(MsgTX); i < BufferSize; i++ ) { |
sagilar | 12:a6a37ba1feff | 473 | Buffer[i] = i - sizeof(MsgTX); |
sagilar | 12:a6a37ba1feff | 474 | } |
sagilar | 12:a6a37ba1feff | 475 | //wait_ms( 100 ); |
sagilar | 12:a6a37ba1feff | 476 | Radio->Send( Buffer, BufferSize ); |
sagilar | 12:a6a37ba1feff | 477 | Radio->Rx( RX_TIMEOUT_VALUE ); |
sagilar | 12:a6a37ba1feff | 478 | |
sagilar | 12:a6a37ba1feff | 479 | //wait(10); |
Helmut64 | 0:c43b6919ae15 | 480 | } |
Helmut64 | 0:c43b6919ae15 | 481 | |
bcostm | 11:9d7409ebfa57 | 482 | void OnTxDone(void *radio, void *userThisPtr, void *userData) |
Helmut64 | 0:c43b6919ae15 | 483 | { |
Helmut64 | 0:c43b6919ae15 | 484 | Radio->Sleep( ); |
Helmut64 | 0:c43b6919ae15 | 485 | State = TX; |
Helmut64 | 0:c43b6919ae15 | 486 | if (DEBUG_MESSAGE) |
Helmut64 | 0:c43b6919ae15 | 487 | dprintf("> OnTxDone"); |
Helmut64 | 0:c43b6919ae15 | 488 | } |
Helmut64 | 0:c43b6919ae15 | 489 | |
bcostm | 11:9d7409ebfa57 | 490 | void OnRxDone(void *radio, void *userThisPtr, void *userData, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) |
Helmut64 | 0:c43b6919ae15 | 491 | { |
Helmut64 | 0:c43b6919ae15 | 492 | Radio->Sleep( ); |
Helmut64 | 0:c43b6919ae15 | 493 | BufferSize = size; |
Helmut64 | 0:c43b6919ae15 | 494 | memcpy( Buffer, payload, BufferSize ); |
Helmut64 | 0:c43b6919ae15 | 495 | State = RX; |
Helmut64 | 0:c43b6919ae15 | 496 | if (DEBUG_MESSAGE) |
Helmut64 | 0:c43b6919ae15 | 497 | dprintf("> OnRxDone: RssiValue=%d dBm, SnrValue=%d", rssi, snr); |
sagilar | 12:a6a37ba1feff | 498 | //dump("Data:", payload, size); |
sagilar | 12:a6a37ba1feff | 499 | strcpy(MsgRX,(char*)payload); |
sagilar | 12:a6a37ba1feff | 500 | //dprintf("Msj: %s", MsgRX); |
Helmut64 | 0:c43b6919ae15 | 501 | } |
Helmut64 | 0:c43b6919ae15 | 502 | |
bcostm | 11:9d7409ebfa57 | 503 | void OnTxTimeout(void *radio, void *userThisPtr, void *userData) |
Helmut64 | 0:c43b6919ae15 | 504 | { |
Helmut64 | 0:c43b6919ae15 | 505 | *led3 = 0; |
Helmut64 | 0:c43b6919ae15 | 506 | Radio->Sleep( ); |
Helmut64 | 0:c43b6919ae15 | 507 | State = TX_TIMEOUT; |
Helmut64 | 0:c43b6919ae15 | 508 | if(DEBUG_MESSAGE) |
Helmut64 | 0:c43b6919ae15 | 509 | dprintf("> OnTxTimeout"); |
Helmut64 | 0:c43b6919ae15 | 510 | } |
Helmut64 | 0:c43b6919ae15 | 511 | |
bcostm | 11:9d7409ebfa57 | 512 | void OnRxTimeout(void *radio, void *userThisPtr, void *userData) |
Helmut64 | 0:c43b6919ae15 | 513 | { |
Helmut64 | 0:c43b6919ae15 | 514 | *led3 = 0; |
Helmut64 | 0:c43b6919ae15 | 515 | Radio->Sleep( ); |
Helmut64 | 0:c43b6919ae15 | 516 | Buffer[BufferSize-1] = 0; |
Helmut64 | 0:c43b6919ae15 | 517 | State = RX_TIMEOUT; |
Helmut64 | 0:c43b6919ae15 | 518 | if (DEBUG_MESSAGE) |
Helmut64 | 0:c43b6919ae15 | 519 | dprintf("> OnRxTimeout"); |
Helmut64 | 0:c43b6919ae15 | 520 | } |
Helmut64 | 0:c43b6919ae15 | 521 | |
bcostm | 11:9d7409ebfa57 | 522 | void OnRxError(void *radio, void *userThisPtr, void *userData) |
Helmut64 | 0:c43b6919ae15 | 523 | { |
Helmut64 | 0:c43b6919ae15 | 524 | Radio->Sleep( ); |
Helmut64 | 0:c43b6919ae15 | 525 | State = RX_ERROR; |
Helmut64 | 0:c43b6919ae15 | 526 | if (DEBUG_MESSAGE) |
Helmut64 | 0:c43b6919ae15 | 527 | dprintf("> OnRxError"); |
Helmut64 | 0:c43b6919ae15 | 528 | } |
Helmut64 | 0:c43b6919ae15 | 529 | |
Helmut64 | 0:c43b6919ae15 | 530 | #endif |