Coragem update
Dependents: Coragem_all_sensors Lora_SX1272_Coragem
SX1272.h@1:5d57c6a92509, 2017-11-05 (annotated)
- Committer:
- cdupaty
- Date:
- Sun Nov 05 17:02:01 2017 +0000
- Revision:
- 1:5d57c6a92509
- Parent:
- 0:d974bcee4f69
- Child:
- 2:a5a72d30cb18
version OK
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cdupaty | 0:d974bcee4f69 | 1 | /* |
cdupaty | 0:d974bcee4f69 | 2 | * Library for LoRa 868 / 915MHz SX1272 LoRa module |
cdupaty | 0:d974bcee4f69 | 3 | * |
cdupaty | 0:d974bcee4f69 | 4 | * Copyright (C) Libelium Comunicaciones Distribuidas S.L. |
cdupaty | 0:d974bcee4f69 | 5 | * http://www.libelium.com |
cdupaty | 0:d974bcee4f69 | 6 | * |
cdupaty | 0:d974bcee4f69 | 7 | * This program is free software: you can redistribute it and/or modify |
cdupaty | 0:d974bcee4f69 | 8 | * it under the terms of the GNU General Public License as published by |
cdupaty | 0:d974bcee4f69 | 9 | * the Free Software Foundation, either version 3 of the License, or |
cdupaty | 0:d974bcee4f69 | 10 | * (at your option) any later version. |
cdupaty | 0:d974bcee4f69 | 11 | * |
cdupaty | 0:d974bcee4f69 | 12 | * This program is distributed in the hope that it will be useful, |
cdupaty | 0:d974bcee4f69 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
cdupaty | 0:d974bcee4f69 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cdupaty | 0:d974bcee4f69 | 15 | * GNU General Public License for more details. |
cdupaty | 0:d974bcee4f69 | 16 | * |
cdupaty | 0:d974bcee4f69 | 17 | * You should have received a copy of the GNU General Public License |
cdupaty | 0:d974bcee4f69 | 18 | * along with this program. If not, see http://www.gnu.org/licenses/. |
cdupaty | 0:d974bcee4f69 | 19 | * |
cdupaty | 0:d974bcee4f69 | 20 | * Version: 1.1 |
cdupaty | 0:d974bcee4f69 | 21 | * Design: David Gascón |
cdupaty | 0:d974bcee4f69 | 22 | * Implementation: Covadonga Albiñana & Victor Boria |
cdupaty | 0:d974bcee4f69 | 23 | */ |
cdupaty | 0:d974bcee4f69 | 24 | |
cdupaty | 0:d974bcee4f69 | 25 | #ifndef SX1272_h |
cdupaty | 0:d974bcee4f69 | 26 | #define SX1272_h |
cdupaty | 0:d974bcee4f69 | 27 | |
cdupaty | 0:d974bcee4f69 | 28 | /****************************************************************************** |
cdupaty | 0:d974bcee4f69 | 29 | * Includes |
cdupaty | 0:d974bcee4f69 | 30 | ******************************************************************************/ |
cdupaty | 0:d974bcee4f69 | 31 | |
cdupaty | 0:d974bcee4f69 | 32 | #include <stdlib.h> |
cdupaty | 0:d974bcee4f69 | 33 | #include <stdint.h> |
cdupaty | 0:d974bcee4f69 | 34 | #include <Arduino.h> |
cdupaty | 0:d974bcee4f69 | 35 | #include "mbed.h" |
cdupaty | 0:d974bcee4f69 | 36 | #include <SPI.h> |
cdupaty | 0:d974bcee4f69 | 37 | |
cdupaty | 0:d974bcee4f69 | 38 | #ifndef inttypes_h |
cdupaty | 0:d974bcee4f69 | 39 | #include <inttypes.h> |
cdupaty | 0:d974bcee4f69 | 40 | #endif |
cdupaty | 0:d974bcee4f69 | 41 | |
cdupaty | 0:d974bcee4f69 | 42 | /****************************************************************************** |
cdupaty | 0:d974bcee4f69 | 43 | * Definitions & Declarations |
cdupaty | 0:d974bcee4f69 | 44 | *****************************************************************************/ |
cdupaty | 0:d974bcee4f69 | 45 | |
cdupaty | 0:d974bcee4f69 | 46 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 47 | // do not remove! |
cdupaty | 0:d974bcee4f69 | 48 | #define W_REQUESTED_ACK |
cdupaty | 0:d974bcee4f69 | 49 | //#define W_NET_KEY |
cdupaty | 0:d974bcee4f69 | 50 | //#define W_INITIALIZATION |
cdupaty | 0:d974bcee4f69 | 51 | #define SX1272_RST 3 |
cdupaty | 0:d974bcee4f69 | 52 | |
cdupaty | 0:d974bcee4f69 | 53 | #if defined ARDUINO_AVR_PRO || defined ARDUINO_AVR_NANO || defined ARDUINO_AVR_MICRO || defined ARDUINO_AVR_MINI \ |
cdupaty | 0:d974bcee4f69 | 54 | || defined __MK20DX256__ || defined __MKL26Z64__ |
cdupaty | 0:d974bcee4f69 | 55 | #define SX1272_SS 10 |
cdupaty | 0:d974bcee4f69 | 56 | #elif defined ARDUINO_AVR_FEATHER32U4 || defined ARDUINO_SAMD_FEATHER_M0 |
cdupaty | 0:d974bcee4f69 | 57 | // on the Adafruit Feather, the RFM95W is embeded and CS pin is normally on pin 8 |
cdupaty | 0:d974bcee4f69 | 58 | #define SX1272_SS 8 |
cdupaty | 0:d974bcee4f69 | 59 | #undef SX1272_RST |
cdupaty | 0:d974bcee4f69 | 60 | #define SX1272_RST 4 |
cdupaty | 0:d974bcee4f69 | 61 | #else |
cdupaty | 0:d974bcee4f69 | 62 | #define SX1272_SS 2 |
cdupaty | 0:d974bcee4f69 | 63 | #endif |
cdupaty | 0:d974bcee4f69 | 64 | |
cdupaty | 0:d974bcee4f69 | 65 | #define SX1272Chip 0 |
cdupaty | 0:d974bcee4f69 | 66 | #define SX1276Chip 1 |
cdupaty | 0:d974bcee4f69 | 67 | // end |
cdupaty | 0:d974bcee4f69 | 68 | |
cdupaty | 1:5d57c6a92509 | 69 | #define SX1272_debug_mode 0 // 0 1 2 |
cdupaty | 0:d974bcee4f69 | 70 | //#define DEBUG_CAD // |
cdupaty | 0:d974bcee4f69 | 71 | |
cdupaty | 0:d974bcee4f69 | 72 | //! MACROS // |
cdupaty | 0:d974bcee4f69 | 73 | #define bitRead(value, bit) (((value) >> (bit)) & 0x01) // read a bit |
cdupaty | 0:d974bcee4f69 | 74 | #define bitSet(value, bit) ((value) |= (1UL << (bit))) // set bit to '1' |
cdupaty | 0:d974bcee4f69 | 75 | #define bitClear(value, bit) ((value) &= ~(1UL << (bit))) // set bit to '0' |
cdupaty | 0:d974bcee4f69 | 76 | |
cdupaty | 0:d974bcee4f69 | 77 | //! REGISTERS // |
cdupaty | 0:d974bcee4f69 | 78 | |
cdupaty | 0:d974bcee4f69 | 79 | #define REG_FIFO 0x00 |
cdupaty | 0:d974bcee4f69 | 80 | #define REG_OP_MODE 0x01 |
cdupaty | 0:d974bcee4f69 | 81 | #define REG_BITRATE_MSB 0x02 |
cdupaty | 0:d974bcee4f69 | 82 | #define REG_BITRATE_LSB 0x03 |
cdupaty | 0:d974bcee4f69 | 83 | #define REG_FDEV_MSB 0x04 |
cdupaty | 0:d974bcee4f69 | 84 | #define REG_FDEV_LSB 0x05 |
cdupaty | 0:d974bcee4f69 | 85 | #define REG_FRF_MSB 0x06 |
cdupaty | 0:d974bcee4f69 | 86 | #define REG_FRF_MID 0x07 |
cdupaty | 0:d974bcee4f69 | 87 | #define REG_FRF_LSB 0x08 |
cdupaty | 0:d974bcee4f69 | 88 | #define REG_PA_CONFIG 0x09 |
cdupaty | 0:d974bcee4f69 | 89 | #define REG_PA_RAMP 0x0A |
cdupaty | 0:d974bcee4f69 | 90 | #define REG_OCP 0x0B |
cdupaty | 0:d974bcee4f69 | 91 | #define REG_LNA 0x0C |
cdupaty | 0:d974bcee4f69 | 92 | #define REG_RX_CONFIG 0x0D |
cdupaty | 0:d974bcee4f69 | 93 | #define REG_FIFO_ADDR_PTR 0x0D |
cdupaty | 0:d974bcee4f69 | 94 | #define REG_RSSI_CONFIG 0x0E |
cdupaty | 0:d974bcee4f69 | 95 | #define REG_FIFO_TX_BASE_ADDR 0x0E |
cdupaty | 0:d974bcee4f69 | 96 | #define REG_RSSI_COLLISION 0x0F |
cdupaty | 0:d974bcee4f69 | 97 | #define REG_FIFO_RX_BASE_ADDR 0x0F |
cdupaty | 0:d974bcee4f69 | 98 | #define REG_RSSI_THRESH 0x10 |
cdupaty | 0:d974bcee4f69 | 99 | #define REG_FIFO_RX_CURRENT_ADDR 0x10 |
cdupaty | 0:d974bcee4f69 | 100 | #define REG_RSSI_VALUE_FSK 0x11 |
cdupaty | 0:d974bcee4f69 | 101 | #define REG_IRQ_FLAGS_MASK 0x11 |
cdupaty | 0:d974bcee4f69 | 102 | #define REG_RX_BW 0x12 |
cdupaty | 0:d974bcee4f69 | 103 | #define REG_IRQ_FLAGS 0x12 |
cdupaty | 0:d974bcee4f69 | 104 | #define REG_AFC_BW 0x13 |
cdupaty | 0:d974bcee4f69 | 105 | #define REG_RX_NB_BYTES 0x13 |
cdupaty | 0:d974bcee4f69 | 106 | #define REG_OOK_PEAK 0x14 |
cdupaty | 0:d974bcee4f69 | 107 | #define REG_RX_HEADER_CNT_VALUE_MSB 0x14 |
cdupaty | 0:d974bcee4f69 | 108 | #define REG_OOK_FIX 0x15 |
cdupaty | 0:d974bcee4f69 | 109 | #define REG_RX_HEADER_CNT_VALUE_LSB 0x15 |
cdupaty | 0:d974bcee4f69 | 110 | #define REG_OOK_AVG 0x16 |
cdupaty | 0:d974bcee4f69 | 111 | #define REG_RX_PACKET_CNT_VALUE_MSB 0x16 |
cdupaty | 0:d974bcee4f69 | 112 | #define REG_RX_PACKET_CNT_VALUE_LSB 0x17 |
cdupaty | 0:d974bcee4f69 | 113 | #define REG_MODEM_STAT 0x18 |
cdupaty | 0:d974bcee4f69 | 114 | #define REG_PKT_SNR_VALUE 0x19 |
cdupaty | 0:d974bcee4f69 | 115 | #define REG_AFC_FEI 0x1A |
cdupaty | 0:d974bcee4f69 | 116 | #define REG_PKT_RSSI_VALUE 0x1A |
cdupaty | 0:d974bcee4f69 | 117 | #define REG_AFC_MSB 0x1B |
cdupaty | 0:d974bcee4f69 | 118 | #define REG_RSSI_VALUE_LORA 0x1B |
cdupaty | 0:d974bcee4f69 | 119 | #define REG_AFC_LSB 0x1C |
cdupaty | 0:d974bcee4f69 | 120 | #define REG_HOP_CHANNEL 0x1C |
cdupaty | 0:d974bcee4f69 | 121 | #define REG_FEI_MSB 0x1D |
cdupaty | 0:d974bcee4f69 | 122 | #define REG_MODEM_CONFIG1 0x1D |
cdupaty | 0:d974bcee4f69 | 123 | #define REG_FEI_LSB 0x1E |
cdupaty | 0:d974bcee4f69 | 124 | #define REG_MODEM_CONFIG2 0x1E |
cdupaty | 0:d974bcee4f69 | 125 | #define REG_PREAMBLE_DETECT 0x1F |
cdupaty | 0:d974bcee4f69 | 126 | #define REG_SYMB_TIMEOUT_LSB 0x1F |
cdupaty | 0:d974bcee4f69 | 127 | #define REG_RX_TIMEOUT1 0x20 |
cdupaty | 0:d974bcee4f69 | 128 | #define REG_PREAMBLE_MSB_LORA 0x20 |
cdupaty | 0:d974bcee4f69 | 129 | #define REG_RX_TIMEOUT2 0x21 |
cdupaty | 0:d974bcee4f69 | 130 | #define REG_PREAMBLE_LSB_LORA 0x21 |
cdupaty | 0:d974bcee4f69 | 131 | #define REG_RX_TIMEOUT3 0x22 |
cdupaty | 0:d974bcee4f69 | 132 | #define REG_PAYLOAD_LENGTH_LORA 0x22 |
cdupaty | 0:d974bcee4f69 | 133 | #define REG_RX_DELAY 0x23 |
cdupaty | 0:d974bcee4f69 | 134 | #define REG_MAX_PAYLOAD_LENGTH 0x23 |
cdupaty | 0:d974bcee4f69 | 135 | #define REG_OSC 0x24 |
cdupaty | 0:d974bcee4f69 | 136 | #define REG_HOP_PERIOD 0x24 |
cdupaty | 0:d974bcee4f69 | 137 | #define REG_PREAMBLE_MSB_FSK 0x25 |
cdupaty | 0:d974bcee4f69 | 138 | #define REG_FIFO_RX_BYTE_ADDR 0x25 |
cdupaty | 0:d974bcee4f69 | 139 | #define REG_PREAMBLE_LSB_FSK 0x26 |
cdupaty | 0:d974bcee4f69 | 140 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 141 | #define REG_MODEM_CONFIG3 0x26 |
cdupaty | 0:d974bcee4f69 | 142 | // end |
cdupaty | 0:d974bcee4f69 | 143 | #define REG_SYNC_CONFIG 0x27 |
cdupaty | 0:d974bcee4f69 | 144 | #define REG_SYNC_VALUE1 0x28 |
cdupaty | 0:d974bcee4f69 | 145 | #define REG_SYNC_VALUE2 0x29 |
cdupaty | 0:d974bcee4f69 | 146 | #define REG_SYNC_VALUE3 0x2A |
cdupaty | 0:d974bcee4f69 | 147 | #define REG_SYNC_VALUE4 0x2B |
cdupaty | 0:d974bcee4f69 | 148 | #define REG_SYNC_VALUE5 0x2C |
cdupaty | 0:d974bcee4f69 | 149 | #define REG_SYNC_VALUE6 0x2D |
cdupaty | 0:d974bcee4f69 | 150 | #define REG_SYNC_VALUE7 0x2E |
cdupaty | 0:d974bcee4f69 | 151 | #define REG_SYNC_VALUE8 0x2F |
cdupaty | 0:d974bcee4f69 | 152 | #define REG_PACKET_CONFIG1 0x30 |
cdupaty | 0:d974bcee4f69 | 153 | #define REG_PACKET_CONFIG2 0x31 |
cdupaty | 0:d974bcee4f69 | 154 | #define REG_DETECT_OPTIMIZE 0x31 |
cdupaty | 0:d974bcee4f69 | 155 | #define REG_PAYLOAD_LENGTH_FSK 0x32 |
cdupaty | 0:d974bcee4f69 | 156 | #define REG_NODE_ADRS 0x33 |
cdupaty | 0:d974bcee4f69 | 157 | #define REG_BROADCAST_ADRS 0x34 |
cdupaty | 0:d974bcee4f69 | 158 | #define REG_FIFO_THRESH 0x35 |
cdupaty | 0:d974bcee4f69 | 159 | #define REG_SEQ_CONFIG1 0x36 |
cdupaty | 0:d974bcee4f69 | 160 | #define REG_SEQ_CONFIG2 0x37 |
cdupaty | 0:d974bcee4f69 | 161 | #define REG_DETECTION_THRESHOLD 0x37 |
cdupaty | 0:d974bcee4f69 | 162 | #define REG_TIMER_RESOL 0x38 |
cdupaty | 0:d974bcee4f69 | 163 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 164 | #define REG_SYNC_WORD 0x39 |
cdupaty | 0:d974bcee4f69 | 165 | //end |
cdupaty | 0:d974bcee4f69 | 166 | #define REG_TIMER1_COEF 0x39 |
cdupaty | 0:d974bcee4f69 | 167 | #define REG_TIMER2_COEF 0x3A |
cdupaty | 0:d974bcee4f69 | 168 | #define REG_IMAGE_CAL 0x3B |
cdupaty | 0:d974bcee4f69 | 169 | #define REG_TEMP 0x3C |
cdupaty | 0:d974bcee4f69 | 170 | #define REG_LOW_BAT 0x3D |
cdupaty | 0:d974bcee4f69 | 171 | #define REG_IRQ_FLAGS1 0x3E |
cdupaty | 0:d974bcee4f69 | 172 | #define REG_IRQ_FLAGS2 0x3F |
cdupaty | 0:d974bcee4f69 | 173 | #define REG_DIO_MAPPING1 0x40 |
cdupaty | 0:d974bcee4f69 | 174 | #define REG_DIO_MAPPING2 0x41 |
cdupaty | 0:d974bcee4f69 | 175 | #define REG_VERSION 0x42 |
cdupaty | 0:d974bcee4f69 | 176 | #define REG_AGC_REF 0x43 |
cdupaty | 0:d974bcee4f69 | 177 | #define REG_AGC_THRESH1 0x44 |
cdupaty | 0:d974bcee4f69 | 178 | #define REG_AGC_THRESH2 0x45 |
cdupaty | 0:d974bcee4f69 | 179 | #define REG_AGC_THRESH3 0x46 |
cdupaty | 0:d974bcee4f69 | 180 | #define REG_PLL_HOP 0x4B |
cdupaty | 0:d974bcee4f69 | 181 | #define REG_TCXO 0x58 |
cdupaty | 0:d974bcee4f69 | 182 | #define REG_PA_DAC 0x5A |
cdupaty | 0:d974bcee4f69 | 183 | #define REG_PLL 0x5C |
cdupaty | 0:d974bcee4f69 | 184 | #define REG_PLL_LOW_PN 0x5E |
cdupaty | 0:d974bcee4f69 | 185 | #define REG_FORMER_TEMP 0x6C |
cdupaty | 0:d974bcee4f69 | 186 | #define REG_BIT_RATE_FRAC 0x70 |
cdupaty | 0:d974bcee4f69 | 187 | |
cdupaty | 0:d974bcee4f69 | 188 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 189 | // copied from LoRaMAC-Node |
cdupaty | 0:d974bcee4f69 | 190 | /*! |
cdupaty | 0:d974bcee4f69 | 191 | * RegImageCal |
cdupaty | 0:d974bcee4f69 | 192 | */ |
cdupaty | 0:d974bcee4f69 | 193 | #define RF_IMAGECAL_AUTOIMAGECAL_MASK 0x7F |
cdupaty | 0:d974bcee4f69 | 194 | #define RF_IMAGECAL_AUTOIMAGECAL_ON 0x80 |
cdupaty | 0:d974bcee4f69 | 195 | #define RF_IMAGECAL_AUTOIMAGECAL_OFF 0x00 // Default |
cdupaty | 0:d974bcee4f69 | 196 | |
cdupaty | 0:d974bcee4f69 | 197 | #define RF_IMAGECAL_IMAGECAL_MASK 0xBF |
cdupaty | 0:d974bcee4f69 | 198 | #define RF_IMAGECAL_IMAGECAL_START 0x40 |
cdupaty | 0:d974bcee4f69 | 199 | |
cdupaty | 0:d974bcee4f69 | 200 | #define RF_IMAGECAL_IMAGECAL_RUNNING 0x20 |
cdupaty | 0:d974bcee4f69 | 201 | #define RF_IMAGECAL_IMAGECAL_DONE 0x00 // Default |
cdupaty | 0:d974bcee4f69 | 202 | |
cdupaty | 0:d974bcee4f69 | 203 | #define RF_IMAGECAL_TEMPCHANGE_HIGHER 0x08 |
cdupaty | 0:d974bcee4f69 | 204 | #define RF_IMAGECAL_TEMPCHANGE_LOWER 0x00 |
cdupaty | 0:d974bcee4f69 | 205 | |
cdupaty | 0:d974bcee4f69 | 206 | #define RF_IMAGECAL_TEMPTHRESHOLD_MASK 0xF9 |
cdupaty | 0:d974bcee4f69 | 207 | #define RF_IMAGECAL_TEMPTHRESHOLD_05 0x00 |
cdupaty | 0:d974bcee4f69 | 208 | #define RF_IMAGECAL_TEMPTHRESHOLD_10 0x02 // Default |
cdupaty | 0:d974bcee4f69 | 209 | #define RF_IMAGECAL_TEMPTHRESHOLD_15 0x04 |
cdupaty | 0:d974bcee4f69 | 210 | #define RF_IMAGECAL_TEMPTHRESHOLD_20 0x06 |
cdupaty | 0:d974bcee4f69 | 211 | |
cdupaty | 0:d974bcee4f69 | 212 | #define RF_IMAGECAL_TEMPMONITOR_MASK 0xFE |
cdupaty | 0:d974bcee4f69 | 213 | #define RF_IMAGECAL_TEMPMONITOR_ON 0x00 // Default |
cdupaty | 0:d974bcee4f69 | 214 | #define RF_IMAGECAL_TEMPMONITOR_OFF 0x01 |
cdupaty | 0:d974bcee4f69 | 215 | |
cdupaty | 0:d974bcee4f69 | 216 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 217 | // The crystal oscillator frequency of the module |
cdupaty | 0:d974bcee4f69 | 218 | #define RH_LORA_FXOSC 32000000.0 |
cdupaty | 0:d974bcee4f69 | 219 | |
cdupaty | 0:d974bcee4f69 | 220 | // The Frequency Synthesizer step = RH_LORA_FXOSC / 2^^19 |
cdupaty | 0:d974bcee4f69 | 221 | #define RH_LORA_FCONVERT (524288 / RH_LORA_FXOSC) |
cdupaty | 0:d974bcee4f69 | 222 | |
cdupaty | 0:d974bcee4f69 | 223 | // Frf = frf(Hz)*2^19/RH_LORA_FXOSC |
cdupaty | 0:d974bcee4f69 | 224 | |
cdupaty | 0:d974bcee4f69 | 225 | ///// |
cdupaty | 0:d974bcee4f69 | 226 | |
cdupaty | 0:d974bcee4f69 | 227 | //FREQUENCY CHANNELS: |
cdupaty | 0:d974bcee4f69 | 228 | // added by C. Pham for Senegal |
cdupaty | 0:d974bcee4f69 | 229 | const uint32_t CH_04_868 = 0xD7CCCC; // channel 04, central freq = 863.20MHz |
cdupaty | 0:d974bcee4f69 | 230 | const uint32_t CH_05_868 = 0xD7E000; // channel 05, central freq = 863.50MHz |
cdupaty | 0:d974bcee4f69 | 231 | const uint32_t CH_06_868 = 0xD7F333; // channel 06, central freq = 863.80MHz |
cdupaty | 0:d974bcee4f69 | 232 | const uint32_t CH_07_868 = 0xD80666; // channel 07, central freq = 864.10MHz |
cdupaty | 0:d974bcee4f69 | 233 | const uint32_t CH_08_868 = 0xD81999; // channel 08, central freq = 864.40MHz |
cdupaty | 0:d974bcee4f69 | 234 | const uint32_t CH_09_868 = 0xD82CCC; // channel 09, central freq = 864.70MHz |
cdupaty | 0:d974bcee4f69 | 235 | // |
cdupaty | 0:d974bcee4f69 | 236 | const uint32_t CH_10_868 = 0xD84CCC; // channel 10, central freq = 865.20MHz, = 865200000*RH_LORA_FCONVERT |
cdupaty | 0:d974bcee4f69 | 237 | const uint32_t CH_11_868 = 0xD86000; // channel 11, central freq = 865.50MHz |
cdupaty | 0:d974bcee4f69 | 238 | const uint32_t CH_12_868 = 0xD87333; // channel 12, central freq = 865.80MHz |
cdupaty | 0:d974bcee4f69 | 239 | const uint32_t CH_13_868 = 0xD88666; // channel 13, central freq = 866.10MHz |
cdupaty | 0:d974bcee4f69 | 240 | const uint32_t CH_14_868 = 0xD89999; // channel 14, central freq = 866.40MHz |
cdupaty | 0:d974bcee4f69 | 241 | const uint32_t CH_15_868 = 0xD8ACCC; // channel 15, central freq = 866.70MHz |
cdupaty | 0:d974bcee4f69 | 242 | const uint32_t CH_16_868 = 0xD8C000; // channel 16, central freq = 867.00MHz |
cdupaty | 0:d974bcee4f69 | 243 | const uint32_t CH_17_868 = 0xD90000; // channel 17, central freq = 868.00MHz |
cdupaty | 0:d974bcee4f69 | 244 | |
cdupaty | 0:d974bcee4f69 | 245 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 246 | const uint32_t CH_18_868 = 0xD90666; // 868.1MHz for LoRaWAN test |
cdupaty | 0:d974bcee4f69 | 247 | // end |
cdupaty | 0:d974bcee4f69 | 248 | const uint32_t CH_00_900 = 0xE1C51E; // channel 00, central freq = 903.08MHz |
cdupaty | 0:d974bcee4f69 | 249 | const uint32_t CH_01_900 = 0xE24F5C; // channel 01, central freq = 905.24MHz |
cdupaty | 0:d974bcee4f69 | 250 | const uint32_t CH_02_900 = 0xE2D999; // channel 02, central freq = 907.40MHz |
cdupaty | 0:d974bcee4f69 | 251 | const uint32_t CH_03_900 = 0xE363D7; // channel 03, central freq = 909.56MHz |
cdupaty | 0:d974bcee4f69 | 252 | const uint32_t CH_04_900 = 0xE3EE14; // channel 04, central freq = 911.72MHz |
cdupaty | 0:d974bcee4f69 | 253 | const uint32_t CH_05_900 = 0xE47851; // channel 05, central freq = 913.88MHz |
cdupaty | 0:d974bcee4f69 | 254 | const uint32_t CH_06_900 = 0xE5028F; // channel 06, central freq = 916.04MHz |
cdupaty | 0:d974bcee4f69 | 255 | const uint32_t CH_07_900 = 0xE58CCC; // channel 07, central freq = 918.20MHz |
cdupaty | 0:d974bcee4f69 | 256 | const uint32_t CH_08_900 = 0xE6170A; // channel 08, central freq = 920.36MHz |
cdupaty | 0:d974bcee4f69 | 257 | const uint32_t CH_09_900 = 0xE6A147; // channel 09, central freq = 922.52MHz |
cdupaty | 0:d974bcee4f69 | 258 | const uint32_t CH_10_900 = 0xE72B85; // channel 10, central freq = 924.68MHz |
cdupaty | 0:d974bcee4f69 | 259 | const uint32_t CH_11_900 = 0xE7B5C2; // channel 11, central freq = 926.84MHz |
cdupaty | 0:d974bcee4f69 | 260 | const uint32_t CH_12_900 = 0xE4C000; // default channel 915MHz, the module is configured with it |
cdupaty | 0:d974bcee4f69 | 261 | |
cdupaty | 0:d974bcee4f69 | 262 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 263 | const uint32_t CH_00_433 = 0x6C5333; // 433.3MHz |
cdupaty | 0:d974bcee4f69 | 264 | const uint32_t CH_01_433 = 0x6C6666; // 433.6MHz |
cdupaty | 0:d974bcee4f69 | 265 | const uint32_t CH_02_433 = 0x6C7999; // 433.9MHz |
cdupaty | 0:d974bcee4f69 | 266 | const uint32_t CH_03_433 = 0x6C9333; // 434.3MHz |
cdupaty | 0:d974bcee4f69 | 267 | // end |
cdupaty | 0:d974bcee4f69 | 268 | |
cdupaty | 0:d974bcee4f69 | 269 | //LORA BANDWIDTH: |
cdupaty | 0:d974bcee4f69 | 270 | // modified by C. Pham |
cdupaty | 0:d974bcee4f69 | 271 | const uint8_t SX1272_BW_125 = 0x00; |
cdupaty | 0:d974bcee4f69 | 272 | const uint8_t SX1272_BW_250 = 0x01; |
cdupaty | 0:d974bcee4f69 | 273 | const uint8_t SX1272_BW_500 = 0x02; |
cdupaty | 0:d974bcee4f69 | 274 | |
cdupaty | 0:d974bcee4f69 | 275 | // use the following constants with setBW() |
cdupaty | 0:d974bcee4f69 | 276 | const uint8_t BW_7_8 = 0x00; |
cdupaty | 0:d974bcee4f69 | 277 | const uint8_t BW_10_4 = 0x01; |
cdupaty | 0:d974bcee4f69 | 278 | const uint8_t BW_15_6 = 0x02; |
cdupaty | 0:d974bcee4f69 | 279 | const uint8_t BW_20_8 = 0x03; |
cdupaty | 0:d974bcee4f69 | 280 | const uint8_t BW_31_25 = 0x04; |
cdupaty | 0:d974bcee4f69 | 281 | const uint8_t BW_41_7 = 0x05; |
cdupaty | 0:d974bcee4f69 | 282 | const uint8_t BW_62_5 = 0x06; |
cdupaty | 0:d974bcee4f69 | 283 | const uint8_t BW_125 = 0x07; |
cdupaty | 0:d974bcee4f69 | 284 | const uint8_t BW_250 = 0x08; |
cdupaty | 0:d974bcee4f69 | 285 | const uint8_t BW_500 = 0x09; |
cdupaty | 0:d974bcee4f69 | 286 | // end |
cdupaty | 0:d974bcee4f69 | 287 | |
cdupaty | 0:d974bcee4f69 | 288 | const double SignalBwLog[] = |
cdupaty | 0:d974bcee4f69 | 289 | { |
cdupaty | 0:d974bcee4f69 | 290 | 5.0969100130080564143587833158265, |
cdupaty | 0:d974bcee4f69 | 291 | 5.397940008672037609572522210551, |
cdupaty | 0:d974bcee4f69 | 292 | 5.6989700043360188047862611052755 |
cdupaty | 0:d974bcee4f69 | 293 | }; |
cdupaty | 0:d974bcee4f69 | 294 | |
cdupaty | 0:d974bcee4f69 | 295 | //LORA CODING RATE: |
cdupaty | 0:d974bcee4f69 | 296 | const uint8_t CR_5 = 0x01; |
cdupaty | 0:d974bcee4f69 | 297 | const uint8_t CR_6 = 0x02; |
cdupaty | 0:d974bcee4f69 | 298 | const uint8_t CR_7 = 0x03; |
cdupaty | 0:d974bcee4f69 | 299 | const uint8_t CR_8 = 0x04; |
cdupaty | 0:d974bcee4f69 | 300 | |
cdupaty | 0:d974bcee4f69 | 301 | //LORA SPREADING FACTOR: |
cdupaty | 0:d974bcee4f69 | 302 | const uint8_t SF_6 = 0x06; |
cdupaty | 0:d974bcee4f69 | 303 | const uint8_t SF_7 = 0x07; |
cdupaty | 0:d974bcee4f69 | 304 | const uint8_t SF_8 = 0x08; |
cdupaty | 0:d974bcee4f69 | 305 | const uint8_t SF_9 = 0x09; |
cdupaty | 0:d974bcee4f69 | 306 | const uint8_t SF_10 = 0x0A; |
cdupaty | 0:d974bcee4f69 | 307 | const uint8_t SF_11 = 0x0B; |
cdupaty | 0:d974bcee4f69 | 308 | const uint8_t SF_12 = 0x0C; |
cdupaty | 0:d974bcee4f69 | 309 | |
cdupaty | 0:d974bcee4f69 | 310 | //LORA MODES: |
cdupaty | 0:d974bcee4f69 | 311 | const uint8_t LORA_SLEEP_MODE = 0x80; |
cdupaty | 0:d974bcee4f69 | 312 | const uint8_t LORA_STANDBY_MODE = 0x81; |
cdupaty | 0:d974bcee4f69 | 313 | const uint8_t LORA_TX_MODE = 0x83; |
cdupaty | 0:d974bcee4f69 | 314 | const uint8_t LORA_RX_MODE = 0x85; |
cdupaty | 0:d974bcee4f69 | 315 | |
cdupaty | 0:d974bcee4f69 | 316 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 317 | const uint8_t LORA_CAD_MODE = 0x87; |
cdupaty | 0:d974bcee4f69 | 318 | #define LNA_MAX_GAIN 0x23 |
cdupaty | 0:d974bcee4f69 | 319 | #define LNA_OFF_GAIN 0x00 |
cdupaty | 0:d974bcee4f69 | 320 | #define LNA_LOW_GAIN 0x20 |
cdupaty | 0:d974bcee4f69 | 321 | // end |
cdupaty | 0:d974bcee4f69 | 322 | |
cdupaty | 0:d974bcee4f69 | 323 | const uint8_t LORA_STANDBY_FSK_REGS_MODE = 0xC1; |
cdupaty | 0:d974bcee4f69 | 324 | |
cdupaty | 0:d974bcee4f69 | 325 | //FSK MODES: |
cdupaty | 0:d974bcee4f69 | 326 | const uint8_t FSK_SLEEP_MODE = 0x00; |
cdupaty | 0:d974bcee4f69 | 327 | const uint8_t FSK_STANDBY_MODE = 0x01; |
cdupaty | 0:d974bcee4f69 | 328 | const uint8_t FSK_TX_MODE = 0x03; |
cdupaty | 0:d974bcee4f69 | 329 | const uint8_t FSK_RX_MODE = 0x05; |
cdupaty | 0:d974bcee4f69 | 330 | |
cdupaty | 0:d974bcee4f69 | 331 | //OTHER CONSTANTS: |
cdupaty | 0:d974bcee4f69 | 332 | |
cdupaty | 0:d974bcee4f69 | 333 | const uint8_t HEADER_ON = 0; |
cdupaty | 0:d974bcee4f69 | 334 | const uint8_t HEADER_OFF = 1; |
cdupaty | 0:d974bcee4f69 | 335 | const uint8_t CRC_ON = 1; |
cdupaty | 0:d974bcee4f69 | 336 | const uint8_t CRC_OFF = 0; |
cdupaty | 0:d974bcee4f69 | 337 | const uint8_t LORA = 1; |
cdupaty | 0:d974bcee4f69 | 338 | const uint8_t FSK = 0; |
cdupaty | 0:d974bcee4f69 | 339 | const uint8_t BROADCAST_0 = 0x00; |
cdupaty | 0:d974bcee4f69 | 340 | const uint8_t MAX_LENGTH = 255; |
cdupaty | 0:d974bcee4f69 | 341 | const uint8_t MAX_PAYLOAD = 251; |
cdupaty | 0:d974bcee4f69 | 342 | const uint8_t MAX_LENGTH_FSK = 64; |
cdupaty | 0:d974bcee4f69 | 343 | const uint8_t MAX_PAYLOAD_FSK = 60; |
cdupaty | 0:d974bcee4f69 | 344 | //modified by C. Pham, 7 instead of 5 because we added a type field which should be PKT_TYPE_ACK and the SNR |
cdupaty | 0:d974bcee4f69 | 345 | const uint8_t ACK_LENGTH = 7; |
cdupaty | 0:d974bcee4f69 | 346 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 347 | #ifdef W_NET_KEY |
cdupaty | 0:d974bcee4f69 | 348 | const uint8_t NET_KEY_LENGTH=2; |
cdupaty | 0:d974bcee4f69 | 349 | const uint8_t OFFSET_PAYLOADLENGTH = 4+NET_KEY_LENGTH; |
cdupaty | 0:d974bcee4f69 | 350 | const uint8_t net_key_0 = 0x12; |
cdupaty | 0:d974bcee4f69 | 351 | const uint8_t net_key_1 = 0x34; |
cdupaty | 0:d974bcee4f69 | 352 | #else |
cdupaty | 0:d974bcee4f69 | 353 | // modified by C. Pham to remove the retry field and the length field |
cdupaty | 0:d974bcee4f69 | 354 | // which will be replaced by packet type field |
cdupaty | 0:d974bcee4f69 | 355 | const uint8_t OFFSET_PAYLOADLENGTH = 4; |
cdupaty | 0:d974bcee4f69 | 356 | #endif |
cdupaty | 0:d974bcee4f69 | 357 | const uint8_t OFFSET_RSSI = 139; |
cdupaty | 0:d974bcee4f69 | 358 | const uint8_t NOISE_FIGURE = 6.0; |
cdupaty | 0:d974bcee4f69 | 359 | const uint8_t NOISE_ABSOLUTE_ZERO = 174.0; |
cdupaty | 0:d974bcee4f69 | 360 | const uint16_t MAX_TIMEOUT = 10000; //10000 msec = 10.0 sec |
cdupaty | 0:d974bcee4f69 | 361 | const uint16_t MAX_WAIT = 12000; //12000 msec = 12.0 sec |
cdupaty | 0:d974bcee4f69 | 362 | const uint8_t MAX_RETRIES = 5; |
cdupaty | 0:d974bcee4f69 | 363 | const uint8_t CORRECT_PACKET = 0; |
cdupaty | 0:d974bcee4f69 | 364 | const uint8_t INCORRECT_PACKET = 1; |
cdupaty | 0:d974bcee4f69 | 365 | |
cdupaty | 0:d974bcee4f69 | 366 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 367 | // Packet type definition |
cdupaty | 0:d974bcee4f69 | 368 | |
cdupaty | 0:d974bcee4f69 | 369 | #define PKT_TYPE_MASK 0xF0 |
cdupaty | 0:d974bcee4f69 | 370 | #define PKT_FLAG_MASK 0x0F |
cdupaty | 0:d974bcee4f69 | 371 | |
cdupaty | 0:d974bcee4f69 | 372 | #define PKT_TYPE_DATA 0x10 |
cdupaty | 0:d974bcee4f69 | 373 | #define PKT_TYPE_ACK 0x20 |
cdupaty | 0:d974bcee4f69 | 374 | |
cdupaty | 0:d974bcee4f69 | 375 | #define PKT_FLAG_ACK_REQ 0x08 |
cdupaty | 0:d974bcee4f69 | 376 | #define PKT_FLAG_DATA_ENCRYPTED 0x04 |
cdupaty | 0:d974bcee4f69 | 377 | #define PKT_FLAG_DATA_WAPPKEY 0x02 |
cdupaty | 0:d974bcee4f69 | 378 | #define PKT_FLAG_DATA_ISBINARY 0x01 |
cdupaty | 0:d974bcee4f69 | 379 | |
cdupaty | 0:d974bcee4f69 | 380 | #define SX1272_ERROR_ACK 3 |
cdupaty | 0:d974bcee4f69 | 381 | #define SX1272_ERROR_TOA 4 |
cdupaty | 0:d974bcee4f69 | 382 | |
cdupaty | 0:d974bcee4f69 | 383 | //! Structure : |
cdupaty | 0:d974bcee4f69 | 384 | /*! |
cdupaty | 0:d974bcee4f69 | 385 | */ |
cdupaty | 0:d974bcee4f69 | 386 | struct pack |
cdupaty | 0:d974bcee4f69 | 387 | { |
cdupaty | 0:d974bcee4f69 | 388 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 389 | #ifdef W_NET_KEY |
cdupaty | 0:d974bcee4f69 | 390 | uint8_t netkey[NET_KEY_LENGTH]; |
cdupaty | 0:d974bcee4f69 | 391 | #endif |
cdupaty | 0:d974bcee4f69 | 392 | //! Structure Variable : Packet destination |
cdupaty | 0:d974bcee4f69 | 393 | /*! |
cdupaty | 0:d974bcee4f69 | 394 | */ |
cdupaty | 0:d974bcee4f69 | 395 | uint8_t dst; |
cdupaty | 0:d974bcee4f69 | 396 | |
cdupaty | 0:d974bcee4f69 | 397 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 398 | //! Structure Variable : Packet type |
cdupaty | 0:d974bcee4f69 | 399 | /*! |
cdupaty | 0:d974bcee4f69 | 400 | */ |
cdupaty | 0:d974bcee4f69 | 401 | uint8_t type; |
cdupaty | 0:d974bcee4f69 | 402 | |
cdupaty | 0:d974bcee4f69 | 403 | //! Structure Variable : Packet source |
cdupaty | 0:d974bcee4f69 | 404 | /*! |
cdupaty | 0:d974bcee4f69 | 405 | */ |
cdupaty | 0:d974bcee4f69 | 406 | uint8_t src; |
cdupaty | 0:d974bcee4f69 | 407 | |
cdupaty | 0:d974bcee4f69 | 408 | //! Structure Variable : Packet number |
cdupaty | 0:d974bcee4f69 | 409 | /*! |
cdupaty | 0:d974bcee4f69 | 410 | */ |
cdupaty | 0:d974bcee4f69 | 411 | uint8_t packnum; |
cdupaty | 0:d974bcee4f69 | 412 | |
cdupaty | 0:d974bcee4f69 | 413 | // modified by C. Pham |
cdupaty | 0:d974bcee4f69 | 414 | // will not be used in the transmitted packet |
cdupaty | 0:d974bcee4f69 | 415 | //! Structure Variable : Packet length |
cdupaty | 0:d974bcee4f69 | 416 | /*! |
cdupaty | 0:d974bcee4f69 | 417 | */ |
cdupaty | 0:d974bcee4f69 | 418 | uint8_t length; |
cdupaty | 0:d974bcee4f69 | 419 | |
cdupaty | 0:d974bcee4f69 | 420 | //! Structure Variable : Packet payload |
cdupaty | 0:d974bcee4f69 | 421 | /*! |
cdupaty | 0:d974bcee4f69 | 422 | */ |
cdupaty | 0:d974bcee4f69 | 423 | uint8_t data[MAX_PAYLOAD]; |
cdupaty | 0:d974bcee4f69 | 424 | |
cdupaty | 0:d974bcee4f69 | 425 | // modified by C. Pham |
cdupaty | 0:d974bcee4f69 | 426 | // will not be used in the transmitted packet |
cdupaty | 0:d974bcee4f69 | 427 | //! Structure Variable : Retry number |
cdupaty | 0:d974bcee4f69 | 428 | /*! |
cdupaty | 0:d974bcee4f69 | 429 | */ |
cdupaty | 0:d974bcee4f69 | 430 | uint8_t retry; |
cdupaty | 0:d974bcee4f69 | 431 | }; |
cdupaty | 0:d974bcee4f69 | 432 | |
cdupaty | 0:d974bcee4f69 | 433 | /****************************************************************************** |
cdupaty | 0:d974bcee4f69 | 434 | * Class |
cdupaty | 0:d974bcee4f69 | 435 | ******************************************************************************/ |
cdupaty | 0:d974bcee4f69 | 436 | |
cdupaty | 0:d974bcee4f69 | 437 | //! SX1272 Class |
cdupaty | 0:d974bcee4f69 | 438 | /*! |
cdupaty | 0:d974bcee4f69 | 439 | SX1272 Class defines all the variables and functions used to manage |
cdupaty | 0:d974bcee4f69 | 440 | SX1272 modules. |
cdupaty | 0:d974bcee4f69 | 441 | */ |
cdupaty | 0:d974bcee4f69 | 442 | class SX1272 |
cdupaty | 0:d974bcee4f69 | 443 | { |
cdupaty | 0:d974bcee4f69 | 444 | |
cdupaty | 0:d974bcee4f69 | 445 | public: |
cdupaty | 0:d974bcee4f69 | 446 | |
cdupaty | 0:d974bcee4f69 | 447 | //! class constructor |
cdupaty | 0:d974bcee4f69 | 448 | /*! |
cdupaty | 0:d974bcee4f69 | 449 | It does nothing |
cdupaty | 0:d974bcee4f69 | 450 | \param void |
cdupaty | 0:d974bcee4f69 | 451 | \return void |
cdupaty | 0:d974bcee4f69 | 452 | */ |
cdupaty | 0:d974bcee4f69 | 453 | SX1272(); |
cdupaty | 0:d974bcee4f69 | 454 | |
cdupaty | 0:d974bcee4f69 | 455 | //! It puts the module ON |
cdupaty | 0:d974bcee4f69 | 456 | /*! |
cdupaty | 0:d974bcee4f69 | 457 | \param void |
cdupaty | 0:d974bcee4f69 | 458 | \return uint8_t setLORA state |
cdupaty | 0:d974bcee4f69 | 459 | */ |
cdupaty | 0:d974bcee4f69 | 460 | uint8_t ON(); |
cdupaty | 0:d974bcee4f69 | 461 | |
cdupaty | 0:d974bcee4f69 | 462 | //! It puts the module OFF |
cdupaty | 0:d974bcee4f69 | 463 | /*! |
cdupaty | 0:d974bcee4f69 | 464 | \param void |
cdupaty | 0:d974bcee4f69 | 465 | \return void |
cdupaty | 0:d974bcee4f69 | 466 | */ |
cdupaty | 0:d974bcee4f69 | 467 | void OFF(); |
cdupaty | 0:d974bcee4f69 | 468 | |
cdupaty | 0:d974bcee4f69 | 469 | //! It reads an internal module register. |
cdupaty | 0:d974bcee4f69 | 470 | /*! |
cdupaty | 0:d974bcee4f69 | 471 | \param byte address : address register to read from. |
cdupaty | 0:d974bcee4f69 | 472 | \return the content of the register. |
cdupaty | 0:d974bcee4f69 | 473 | */ |
cdupaty | 0:d974bcee4f69 | 474 | byte readRegister(byte address); |
cdupaty | 0:d974bcee4f69 | 475 | |
cdupaty | 0:d974bcee4f69 | 476 | //! It writes in an internal module register. |
cdupaty | 0:d974bcee4f69 | 477 | /*! |
cdupaty | 0:d974bcee4f69 | 478 | \param byte address : address register to write in. |
cdupaty | 0:d974bcee4f69 | 479 | \param byte data : value to write in the register. |
cdupaty | 0:d974bcee4f69 | 480 | */ |
cdupaty | 0:d974bcee4f69 | 481 | void writeRegister(byte address, byte data); |
cdupaty | 0:d974bcee4f69 | 482 | |
cdupaty | 0:d974bcee4f69 | 483 | //! It clears the interruption flags. |
cdupaty | 0:d974bcee4f69 | 484 | /*! |
cdupaty | 0:d974bcee4f69 | 485 | \param void |
cdupaty | 0:d974bcee4f69 | 486 | \return void |
cdupaty | 0:d974bcee4f69 | 487 | */ |
cdupaty | 0:d974bcee4f69 | 488 | void clearFlags(); |
cdupaty | 0:d974bcee4f69 | 489 | |
cdupaty | 0:d974bcee4f69 | 490 | //! It sets the LoRa mode on. |
cdupaty | 0:d974bcee4f69 | 491 | /*! |
cdupaty | 0:d974bcee4f69 | 492 | It stores in global '_LORA' variable '1' when success |
cdupaty | 0:d974bcee4f69 | 493 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 494 | */ |
cdupaty | 0:d974bcee4f69 | 495 | uint8_t setLORA(); |
cdupaty | 0:d974bcee4f69 | 496 | |
cdupaty | 0:d974bcee4f69 | 497 | //! It sets the FSK mode on. |
cdupaty | 0:d974bcee4f69 | 498 | /*! |
cdupaty | 0:d974bcee4f69 | 499 | It stores in global '_FSK' variable '1' when success |
cdupaty | 0:d974bcee4f69 | 500 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 501 | */ |
cdupaty | 0:d974bcee4f69 | 502 | uint8_t setFSK(); |
cdupaty | 0:d974bcee4f69 | 503 | |
cdupaty | 0:d974bcee4f69 | 504 | //! It gets the BW, SF and CR of the module. |
cdupaty | 0:d974bcee4f69 | 505 | /*! |
cdupaty | 0:d974bcee4f69 | 506 | It stores in global '_bandwidth' variable the BW |
cdupaty | 0:d974bcee4f69 | 507 | It stores in global '_codingRate' variable the CR |
cdupaty | 0:d974bcee4f69 | 508 | It stores in global '_spreadingFactor' variable the SF |
cdupaty | 0:d974bcee4f69 | 509 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 510 | */ |
cdupaty | 0:d974bcee4f69 | 511 | uint8_t getMode(); |
cdupaty | 0:d974bcee4f69 | 512 | |
cdupaty | 0:d974bcee4f69 | 513 | //! It sets the BW, SF and CR of the module. |
cdupaty | 0:d974bcee4f69 | 514 | /*! |
cdupaty | 0:d974bcee4f69 | 515 | It stores in global '_bandwidth' variable the BW |
cdupaty | 0:d974bcee4f69 | 516 | It stores in global '_codingRate' variable the CR |
cdupaty | 0:d974bcee4f69 | 517 | It stores in global '_spreadingFactor' variable the SF |
cdupaty | 0:d974bcee4f69 | 518 | \param uint8_t mode : there is a mode number to different values of |
cdupaty | 0:d974bcee4f69 | 519 | the configured parameters with this function. |
cdupaty | 0:d974bcee4f69 | 520 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 521 | */ |
cdupaty | 0:d974bcee4f69 | 522 | int8_t setMode(uint8_t mode); |
cdupaty | 0:d974bcee4f69 | 523 | |
cdupaty | 0:d974bcee4f69 | 524 | //! It gets the header mode configured. |
cdupaty | 0:d974bcee4f69 | 525 | /*! |
cdupaty | 0:d974bcee4f69 | 526 | It stores in global '_header' variable '0' when header is sent |
cdupaty | 0:d974bcee4f69 | 527 | (explicit header mode) or '1' when is not sent (implicit header |
cdupaty | 0:d974bcee4f69 | 528 | mode). |
cdupaty | 0:d974bcee4f69 | 529 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 530 | */ |
cdupaty | 0:d974bcee4f69 | 531 | uint8_t getHeader(); |
cdupaty | 0:d974bcee4f69 | 532 | |
cdupaty | 0:d974bcee4f69 | 533 | //! It sets explicit header mode. |
cdupaty | 0:d974bcee4f69 | 534 | /*! |
cdupaty | 0:d974bcee4f69 | 535 | It stores in global '_header' variable '1' when success |
cdupaty | 0:d974bcee4f69 | 536 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 537 | */ |
cdupaty | 0:d974bcee4f69 | 538 | int8_t setHeaderON(); |
cdupaty | 0:d974bcee4f69 | 539 | |
cdupaty | 0:d974bcee4f69 | 540 | //! It sets implicit header mode. |
cdupaty | 0:d974bcee4f69 | 541 | /*! |
cdupaty | 0:d974bcee4f69 | 542 | It stores in global '_header' variable '0' when success |
cdupaty | 0:d974bcee4f69 | 543 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 544 | */ |
cdupaty | 0:d974bcee4f69 | 545 | int8_t setHeaderOFF(); |
cdupaty | 0:d974bcee4f69 | 546 | |
cdupaty | 0:d974bcee4f69 | 547 | //! It gets the CRC configured. |
cdupaty | 0:d974bcee4f69 | 548 | /*! |
cdupaty | 0:d974bcee4f69 | 549 | It stores in global '_CRC' variable '1' enabling CRC generation on |
cdupaty | 0:d974bcee4f69 | 550 | payload, or '0' disabling the CRC. |
cdupaty | 0:d974bcee4f69 | 551 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 552 | */ |
cdupaty | 0:d974bcee4f69 | 553 | uint8_t getCRC(); |
cdupaty | 0:d974bcee4f69 | 554 | |
cdupaty | 0:d974bcee4f69 | 555 | //! It sets CRC on. |
cdupaty | 0:d974bcee4f69 | 556 | /*! |
cdupaty | 0:d974bcee4f69 | 557 | It stores in global '_CRC' variable '1' when success |
cdupaty | 0:d974bcee4f69 | 558 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 559 | */ |
cdupaty | 0:d974bcee4f69 | 560 | uint8_t setCRC_ON(); |
cdupaty | 0:d974bcee4f69 | 561 | |
cdupaty | 0:d974bcee4f69 | 562 | //! It sets CRC off. |
cdupaty | 0:d974bcee4f69 | 563 | /*! |
cdupaty | 0:d974bcee4f69 | 564 | It stores in global '_CRC' variable '0' when success |
cdupaty | 0:d974bcee4f69 | 565 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 566 | */ |
cdupaty | 0:d974bcee4f69 | 567 | uint8_t setCRC_OFF(); |
cdupaty | 0:d974bcee4f69 | 568 | |
cdupaty | 0:d974bcee4f69 | 569 | //! It is true if the SF selected exists. |
cdupaty | 0:d974bcee4f69 | 570 | /*! |
cdupaty | 0:d974bcee4f69 | 571 | \param uint8_t spr : spreading factor value to check. |
cdupaty | 0:d974bcee4f69 | 572 | \return 'true' on success, 'false' otherwise |
cdupaty | 0:d974bcee4f69 | 573 | */ |
cdupaty | 0:d974bcee4f69 | 574 | boolean isSF(uint8_t spr); |
cdupaty | 0:d974bcee4f69 | 575 | |
cdupaty | 0:d974bcee4f69 | 576 | //! It gets the SF configured. |
cdupaty | 0:d974bcee4f69 | 577 | /*! |
cdupaty | 0:d974bcee4f69 | 578 | It stores in global '_spreadingFactor' variable the current value of SF |
cdupaty | 0:d974bcee4f69 | 579 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 580 | */ |
cdupaty | 0:d974bcee4f69 | 581 | int8_t getSF(); |
cdupaty | 0:d974bcee4f69 | 582 | |
cdupaty | 0:d974bcee4f69 | 583 | //! It sets the SF. |
cdupaty | 0:d974bcee4f69 | 584 | /*! |
cdupaty | 0:d974bcee4f69 | 585 | It stores in global '_spreadingFactor' variable the current value of SF |
cdupaty | 0:d974bcee4f69 | 586 | \param uint8_t spr : spreading factor value to set in the configuration. |
cdupaty | 0:d974bcee4f69 | 587 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 588 | */ |
cdupaty | 0:d974bcee4f69 | 589 | uint8_t setSF(uint8_t spr); |
cdupaty | 0:d974bcee4f69 | 590 | |
cdupaty | 0:d974bcee4f69 | 591 | //! It is true if the BW selected exists. |
cdupaty | 0:d974bcee4f69 | 592 | /*! |
cdupaty | 0:d974bcee4f69 | 593 | \param uint16_t band : bandwidth value to check. |
cdupaty | 0:d974bcee4f69 | 594 | \return 'true' on success, 'false' otherwise |
cdupaty | 0:d974bcee4f69 | 595 | */ |
cdupaty | 0:d974bcee4f69 | 596 | boolean isBW(uint16_t band); |
cdupaty | 0:d974bcee4f69 | 597 | |
cdupaty | 0:d974bcee4f69 | 598 | //! It gets the BW configured. |
cdupaty | 0:d974bcee4f69 | 599 | /*! |
cdupaty | 0:d974bcee4f69 | 600 | It stores in global '_bandwidth' variable the BW selected |
cdupaty | 0:d974bcee4f69 | 601 | in the configuration |
cdupaty | 0:d974bcee4f69 | 602 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 603 | */ |
cdupaty | 0:d974bcee4f69 | 604 | int8_t getBW(); |
cdupaty | 0:d974bcee4f69 | 605 | |
cdupaty | 0:d974bcee4f69 | 606 | //! It sets the BW. |
cdupaty | 0:d974bcee4f69 | 607 | /*! |
cdupaty | 0:d974bcee4f69 | 608 | It stores in global '_bandwidth' variable the BW selected |
cdupaty | 0:d974bcee4f69 | 609 | in the configuration |
cdupaty | 0:d974bcee4f69 | 610 | \param uint16_t band : bandwidth value to set in the configuration. |
cdupaty | 0:d974bcee4f69 | 611 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 612 | */ |
cdupaty | 0:d974bcee4f69 | 613 | int8_t setBW(uint16_t band); |
cdupaty | 0:d974bcee4f69 | 614 | |
cdupaty | 0:d974bcee4f69 | 615 | //! It is true if the CR selected exists. |
cdupaty | 0:d974bcee4f69 | 616 | /*! |
cdupaty | 0:d974bcee4f69 | 617 | \param uint8_t cod : the coding rate value to check. |
cdupaty | 0:d974bcee4f69 | 618 | \return 'true' on success, 'false' otherwise |
cdupaty | 0:d974bcee4f69 | 619 | */ |
cdupaty | 0:d974bcee4f69 | 620 | boolean isCR(uint8_t cod); |
cdupaty | 0:d974bcee4f69 | 621 | |
cdupaty | 0:d974bcee4f69 | 622 | //! It gets the CR configured. |
cdupaty | 0:d974bcee4f69 | 623 | /*! |
cdupaty | 0:d974bcee4f69 | 624 | It stores in global '_codingRate' variable the CR selected |
cdupaty | 0:d974bcee4f69 | 625 | in the configuration |
cdupaty | 0:d974bcee4f69 | 626 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 627 | */ |
cdupaty | 0:d974bcee4f69 | 628 | int8_t getCR(); |
cdupaty | 0:d974bcee4f69 | 629 | |
cdupaty | 0:d974bcee4f69 | 630 | //! It sets the CR. |
cdupaty | 0:d974bcee4f69 | 631 | /*! |
cdupaty | 0:d974bcee4f69 | 632 | It stores in global '_codingRate' variable the CR selected |
cdupaty | 0:d974bcee4f69 | 633 | in the configuration |
cdupaty | 0:d974bcee4f69 | 634 | \param uint8_t cod : coding rate value to set in the configuration. |
cdupaty | 0:d974bcee4f69 | 635 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 636 | */ |
cdupaty | 0:d974bcee4f69 | 637 | int8_t setCR(uint8_t cod); |
cdupaty | 0:d974bcee4f69 | 638 | |
cdupaty | 0:d974bcee4f69 | 639 | |
cdupaty | 0:d974bcee4f69 | 640 | //! It is true if the channel selected exists. |
cdupaty | 0:d974bcee4f69 | 641 | /*! |
cdupaty | 0:d974bcee4f69 | 642 | \param uint32_t ch : frequency channel value to check. |
cdupaty | 0:d974bcee4f69 | 643 | \return 'true' on success, 'false' otherwise |
cdupaty | 0:d974bcee4f69 | 644 | */ |
cdupaty | 0:d974bcee4f69 | 645 | boolean isChannel(uint32_t ch); |
cdupaty | 0:d974bcee4f69 | 646 | |
cdupaty | 0:d974bcee4f69 | 647 | //! It gets frequency channel the module is using. |
cdupaty | 0:d974bcee4f69 | 648 | /*! |
cdupaty | 0:d974bcee4f69 | 649 | It stores in global '_channel' variable the frequency channel |
cdupaty | 0:d974bcee4f69 | 650 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 651 | */ |
cdupaty | 0:d974bcee4f69 | 652 | uint8_t getChannel(); |
cdupaty | 0:d974bcee4f69 | 653 | |
cdupaty | 0:d974bcee4f69 | 654 | //! It sets frequency channel the module is using. |
cdupaty | 0:d974bcee4f69 | 655 | /*! |
cdupaty | 0:d974bcee4f69 | 656 | It stores in global '_channel' variable the frequency channel |
cdupaty | 0:d974bcee4f69 | 657 | \param uint32_t ch : frequency channel value to set in the configuration. |
cdupaty | 0:d974bcee4f69 | 658 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 659 | */ |
cdupaty | 0:d974bcee4f69 | 660 | int8_t setChannel(uint32_t ch); |
cdupaty | 0:d974bcee4f69 | 661 | |
cdupaty | 0:d974bcee4f69 | 662 | //! It gets the output power of the signal. |
cdupaty | 0:d974bcee4f69 | 663 | /*! |
cdupaty | 0:d974bcee4f69 | 664 | It stores in global '_power' variable the output power of the signal |
cdupaty | 0:d974bcee4f69 | 665 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 666 | */ |
cdupaty | 0:d974bcee4f69 | 667 | uint8_t getPower(); |
cdupaty | 0:d974bcee4f69 | 668 | |
cdupaty | 0:d974bcee4f69 | 669 | //! It sets the output power of the signal. |
cdupaty | 0:d974bcee4f69 | 670 | /*! |
cdupaty | 0:d974bcee4f69 | 671 | It stores in global '_power' variable the output power of the signal |
cdupaty | 0:d974bcee4f69 | 672 | \param char p : 'M', 'H' or 'L' if you want Maximum, High or Low |
cdupaty | 0:d974bcee4f69 | 673 | output power signal. |
cdupaty | 0:d974bcee4f69 | 674 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 675 | */ |
cdupaty | 0:d974bcee4f69 | 676 | int8_t setPower(char p); |
cdupaty | 0:d974bcee4f69 | 677 | |
cdupaty | 0:d974bcee4f69 | 678 | //! It sets the output power of the signal. |
cdupaty | 0:d974bcee4f69 | 679 | /*! |
cdupaty | 0:d974bcee4f69 | 680 | It stores in global '_power' variable the output power of the signal |
cdupaty | 0:d974bcee4f69 | 681 | \param uint8_t pow : value to set as output power. |
cdupaty | 0:d974bcee4f69 | 682 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 683 | */ |
cdupaty | 0:d974bcee4f69 | 684 | int8_t setPowerNum(uint8_t pow); |
cdupaty | 0:d974bcee4f69 | 685 | |
cdupaty | 0:d974bcee4f69 | 686 | //! It gets the preamble length configured. |
cdupaty | 0:d974bcee4f69 | 687 | /*! |
cdupaty | 0:d974bcee4f69 | 688 | It stores in global '_preamblelength' variable the preamble length |
cdupaty | 0:d974bcee4f69 | 689 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 690 | */ |
cdupaty | 0:d974bcee4f69 | 691 | uint8_t getPreambleLength(); |
cdupaty | 0:d974bcee4f69 | 692 | |
cdupaty | 0:d974bcee4f69 | 693 | //! It sets the preamble length. |
cdupaty | 0:d974bcee4f69 | 694 | /*! |
cdupaty | 0:d974bcee4f69 | 695 | It stores in global '_preamblelength' variable the preamble length |
cdupaty | 0:d974bcee4f69 | 696 | \param uint16_t l : preamble length to set in the configuration. |
cdupaty | 0:d974bcee4f69 | 697 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 698 | */ |
cdupaty | 0:d974bcee4f69 | 699 | uint8_t setPreambleLength(uint16_t l); |
cdupaty | 0:d974bcee4f69 | 700 | |
cdupaty | 0:d974bcee4f69 | 701 | //! It gets the payload length of the last packet to send/receive. |
cdupaty | 0:d974bcee4f69 | 702 | /*! |
cdupaty | 0:d974bcee4f69 | 703 | It stores in global '_payloadlength' variable the payload length of |
cdupaty | 0:d974bcee4f69 | 704 | the last packet to send/receive. |
cdupaty | 0:d974bcee4f69 | 705 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 706 | */ |
cdupaty | 0:d974bcee4f69 | 707 | uint8_t getPayloadLength(); |
cdupaty | 0:d974bcee4f69 | 708 | |
cdupaty | 0:d974bcee4f69 | 709 | //! It sets the packet length to send/receive. |
cdupaty | 0:d974bcee4f69 | 710 | /*! |
cdupaty | 0:d974bcee4f69 | 711 | It stores in global '_payloadlength' variable the payload length of |
cdupaty | 0:d974bcee4f69 | 712 | the last packet to send/receive. |
cdupaty | 0:d974bcee4f69 | 713 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 714 | */ |
cdupaty | 0:d974bcee4f69 | 715 | int8_t setPacketLength(); |
cdupaty | 0:d974bcee4f69 | 716 | |
cdupaty | 0:d974bcee4f69 | 717 | //! It sets the packet length to send/receive. |
cdupaty | 0:d974bcee4f69 | 718 | /*! |
cdupaty | 0:d974bcee4f69 | 719 | It stores in global '_payloadlength' variable the payload length of |
cdupaty | 0:d974bcee4f69 | 720 | the last packet to send/receive. |
cdupaty | 0:d974bcee4f69 | 721 | \param uint8_t l : payload length to set in the configuration. |
cdupaty | 0:d974bcee4f69 | 722 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 723 | */ |
cdupaty | 0:d974bcee4f69 | 724 | int8_t setPacketLength(uint8_t l); |
cdupaty | 0:d974bcee4f69 | 725 | |
cdupaty | 0:d974bcee4f69 | 726 | //! It gets the node address of the mote. |
cdupaty | 0:d974bcee4f69 | 727 | /*! |
cdupaty | 0:d974bcee4f69 | 728 | It stores in global '_nodeAddress' variable the node address |
cdupaty | 0:d974bcee4f69 | 729 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 730 | */ |
cdupaty | 0:d974bcee4f69 | 731 | uint8_t getNodeAddress(); |
cdupaty | 0:d974bcee4f69 | 732 | |
cdupaty | 0:d974bcee4f69 | 733 | //! It sets the node address of the mote. |
cdupaty | 0:d974bcee4f69 | 734 | /*! |
cdupaty | 0:d974bcee4f69 | 735 | It stores in global '_nodeAddress' variable the node address |
cdupaty | 0:d974bcee4f69 | 736 | \param uint8_t addr : address value to set as node address. |
cdupaty | 0:d974bcee4f69 | 737 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 738 | */ |
cdupaty | 0:d974bcee4f69 | 739 | int8_t setNodeAddress(uint8_t addr); |
cdupaty | 0:d974bcee4f69 | 740 | |
cdupaty | 0:d974bcee4f69 | 741 | //! It gets the SNR of the latest received packet. |
cdupaty | 0:d974bcee4f69 | 742 | /*! |
cdupaty | 0:d974bcee4f69 | 743 | It stores in global '_SNR' variable the SNR |
cdupaty | 0:d974bcee4f69 | 744 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 745 | */ |
cdupaty | 0:d974bcee4f69 | 746 | int8_t getSNR(); |
cdupaty | 0:d974bcee4f69 | 747 | |
cdupaty | 0:d974bcee4f69 | 748 | //! It gets the current value of RSSI. |
cdupaty | 0:d974bcee4f69 | 749 | /*! |
cdupaty | 0:d974bcee4f69 | 750 | It stores in global '_RSSI' variable the current value of RSSI |
cdupaty | 0:d974bcee4f69 | 751 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 752 | */ |
cdupaty | 0:d974bcee4f69 | 753 | uint8_t getRSSI(); |
cdupaty | 0:d974bcee4f69 | 754 | |
cdupaty | 0:d974bcee4f69 | 755 | //! It gets the RSSI of the latest received packet. |
cdupaty | 0:d974bcee4f69 | 756 | /*! |
cdupaty | 0:d974bcee4f69 | 757 | It stores in global '_RSSIpacket' variable the RSSI of the latest |
cdupaty | 0:d974bcee4f69 | 758 | packet received. |
cdupaty | 0:d974bcee4f69 | 759 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 760 | */ |
cdupaty | 0:d974bcee4f69 | 761 | int16_t getRSSIpacket(); |
cdupaty | 0:d974bcee4f69 | 762 | |
cdupaty | 0:d974bcee4f69 | 763 | //! It sets the total of retries when a packet is not correctly received. |
cdupaty | 0:d974bcee4f69 | 764 | /*! |
cdupaty | 0:d974bcee4f69 | 765 | It stores in global '_maxRetries' variable the number of retries. |
cdupaty | 0:d974bcee4f69 | 766 | \param uint8_t ret : number of retries. |
cdupaty | 0:d974bcee4f69 | 767 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 768 | */ |
cdupaty | 0:d974bcee4f69 | 769 | uint8_t setRetries(uint8_t ret); |
cdupaty | 0:d974bcee4f69 | 770 | |
cdupaty | 0:d974bcee4f69 | 771 | //! It gets the maximum current supply by the module. |
cdupaty | 0:d974bcee4f69 | 772 | /*! |
cdupaty | 0:d974bcee4f69 | 773 | * |
cdupaty | 0:d974bcee4f69 | 774 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 775 | */ |
cdupaty | 0:d974bcee4f69 | 776 | uint8_t getMaxCurrent(); |
cdupaty | 0:d974bcee4f69 | 777 | |
cdupaty | 0:d974bcee4f69 | 778 | //! It sets the maximum current supply by the module. |
cdupaty | 0:d974bcee4f69 | 779 | /*! |
cdupaty | 0:d974bcee4f69 | 780 | It stores in global '_maxCurrent' variable the maximum current supply. |
cdupaty | 0:d974bcee4f69 | 781 | \param uint8_t rate : maximum current supply. |
cdupaty | 0:d974bcee4f69 | 782 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 783 | */ |
cdupaty | 0:d974bcee4f69 | 784 | int8_t setMaxCurrent(uint8_t rate); |
cdupaty | 0:d974bcee4f69 | 785 | |
cdupaty | 0:d974bcee4f69 | 786 | //! It gets the content of the main configuration registers. |
cdupaty | 0:d974bcee4f69 | 787 | /*! |
cdupaty | 0:d974bcee4f69 | 788 | It stores in global '_bandwidth' variable the BW. |
cdupaty | 0:d974bcee4f69 | 789 | It stores in global '_codingRate' variable the CR. |
cdupaty | 0:d974bcee4f69 | 790 | It stores in global '_spreadingFactor' variable the SF. |
cdupaty | 0:d974bcee4f69 | 791 | It stores in global '_power' variable the output power of the signal. |
cdupaty | 0:d974bcee4f69 | 792 | It stores in global '_channel' variable the frequency channel. |
cdupaty | 0:d974bcee4f69 | 793 | It stores in global '_CRC' variable '1' enabling CRC generation on |
cdupaty | 0:d974bcee4f69 | 794 | payload, or '0' disabling the CRC. |
cdupaty | 0:d974bcee4f69 | 795 | It stores in global '_header' variable '0' when header is sent |
cdupaty | 0:d974bcee4f69 | 796 | (explicit header mode) or '1' when is not sent (implicit header |
cdupaty | 0:d974bcee4f69 | 797 | mode). |
cdupaty | 0:d974bcee4f69 | 798 | It stores in global '_preamblelength' variable the preamble length. |
cdupaty | 0:d974bcee4f69 | 799 | It stores in global '_payloadlength' variable the payload length of |
cdupaty | 0:d974bcee4f69 | 800 | the last packet to send/receive. |
cdupaty | 0:d974bcee4f69 | 801 | It stores in global '_nodeAddress' variable the node address. |
cdupaty | 0:d974bcee4f69 | 802 | It stores in global '_temp' variable the module temperature. |
cdupaty | 0:d974bcee4f69 | 803 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 804 | */ |
cdupaty | 0:d974bcee4f69 | 805 | uint8_t getRegs(); |
cdupaty | 0:d974bcee4f69 | 806 | |
cdupaty | 0:d974bcee4f69 | 807 | //! It sets the maximum number of bytes from a frame that fit in a packet structure. |
cdupaty | 0:d974bcee4f69 | 808 | /*! |
cdupaty | 0:d974bcee4f69 | 809 | It stores in global '_payloadlength' variable the maximum number of bytes. |
cdupaty | 0:d974bcee4f69 | 810 | \param uint16_t length16 : total frame length. |
cdupaty | 0:d974bcee4f69 | 811 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 812 | */ |
cdupaty | 0:d974bcee4f69 | 813 | uint8_t truncPayload(uint16_t length16); |
cdupaty | 0:d974bcee4f69 | 814 | |
cdupaty | 0:d974bcee4f69 | 815 | //! It writes an ACK in FIFO to send it. |
cdupaty | 0:d974bcee4f69 | 816 | /*! |
cdupaty | 0:d974bcee4f69 | 817 | * |
cdupaty | 0:d974bcee4f69 | 818 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 819 | */ |
cdupaty | 0:d974bcee4f69 | 820 | uint8_t setACK(); |
cdupaty | 0:d974bcee4f69 | 821 | |
cdupaty | 0:d974bcee4f69 | 822 | //! It puts the module in reception mode. |
cdupaty | 0:d974bcee4f69 | 823 | /*! |
cdupaty | 0:d974bcee4f69 | 824 | * |
cdupaty | 0:d974bcee4f69 | 825 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 826 | */ |
cdupaty | 0:d974bcee4f69 | 827 | uint8_t receive(); |
cdupaty | 0:d974bcee4f69 | 828 | |
cdupaty | 0:d974bcee4f69 | 829 | //! It receives a packet before MAX_TIMEOUT. |
cdupaty | 0:d974bcee4f69 | 830 | /*! |
cdupaty | 0:d974bcee4f69 | 831 | * |
cdupaty | 0:d974bcee4f69 | 832 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 833 | */ |
cdupaty | 0:d974bcee4f69 | 834 | uint8_t receivePacketMAXTimeout(); |
cdupaty | 0:d974bcee4f69 | 835 | |
cdupaty | 0:d974bcee4f69 | 836 | //! It receives a packet before a timeout. |
cdupaty | 0:d974bcee4f69 | 837 | /*! |
cdupaty | 0:d974bcee4f69 | 838 | * |
cdupaty | 0:d974bcee4f69 | 839 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 840 | */ |
cdupaty | 0:d974bcee4f69 | 841 | uint8_t receivePacketTimeout(); |
cdupaty | 0:d974bcee4f69 | 842 | |
cdupaty | 0:d974bcee4f69 | 843 | //! It receives a packet before a timeout. |
cdupaty | 0:d974bcee4f69 | 844 | /*! |
cdupaty | 0:d974bcee4f69 | 845 | \param uint16_t wait : time to wait to receive something. |
cdupaty | 0:d974bcee4f69 | 846 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 847 | */ |
cdupaty | 0:d974bcee4f69 | 848 | uint8_t receivePacketTimeout(uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 849 | |
cdupaty | 0:d974bcee4f69 | 850 | //! It receives a packet before MAX_TIMEOUT and reply with an ACK. |
cdupaty | 0:d974bcee4f69 | 851 | /*! |
cdupaty | 0:d974bcee4f69 | 852 | * |
cdupaty | 0:d974bcee4f69 | 853 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 854 | */ |
cdupaty | 0:d974bcee4f69 | 855 | uint8_t receivePacketMAXTimeoutACK(); |
cdupaty | 0:d974bcee4f69 | 856 | |
cdupaty | 0:d974bcee4f69 | 857 | //! It receives a packet before a timeout and reply with an ACK. |
cdupaty | 0:d974bcee4f69 | 858 | /*! |
cdupaty | 0:d974bcee4f69 | 859 | * |
cdupaty | 0:d974bcee4f69 | 860 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 861 | */ |
cdupaty | 0:d974bcee4f69 | 862 | uint8_t receivePacketTimeoutACK(); |
cdupaty | 0:d974bcee4f69 | 863 | |
cdupaty | 0:d974bcee4f69 | 864 | //! It receives a packet before a timeout and reply with an ACK. |
cdupaty | 0:d974bcee4f69 | 865 | /*! |
cdupaty | 0:d974bcee4f69 | 866 | \param uint16_t wait : time to wait to receive something. |
cdupaty | 0:d974bcee4f69 | 867 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 868 | */ |
cdupaty | 0:d974bcee4f69 | 869 | uint8_t receivePacketTimeoutACK(uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 870 | |
cdupaty | 0:d974bcee4f69 | 871 | //! It puts the module in 'promiscuous' reception mode. |
cdupaty | 0:d974bcee4f69 | 872 | /*! |
cdupaty | 0:d974bcee4f69 | 873 | * |
cdupaty | 0:d974bcee4f69 | 874 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 875 | */ |
cdupaty | 0:d974bcee4f69 | 876 | uint8_t receiveAll(); |
cdupaty | 0:d974bcee4f69 | 877 | |
cdupaty | 0:d974bcee4f69 | 878 | //! It puts the module in 'promiscuous' reception mode with a timeout. |
cdupaty | 0:d974bcee4f69 | 879 | /*! |
cdupaty | 0:d974bcee4f69 | 880 | \param uint16_t wait : time to wait to receive something. |
cdupaty | 0:d974bcee4f69 | 881 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 882 | */ |
cdupaty | 0:d974bcee4f69 | 883 | uint8_t receiveAll(uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 884 | |
cdupaty | 0:d974bcee4f69 | 885 | //! It checks if there is an available packet and its destination. |
cdupaty | 0:d974bcee4f69 | 886 | /*! |
cdupaty | 0:d974bcee4f69 | 887 | * |
cdupaty | 0:d974bcee4f69 | 888 | \return 'true' on success, 'false' otherwise |
cdupaty | 0:d974bcee4f69 | 889 | */ |
cdupaty | 0:d974bcee4f69 | 890 | boolean availableData(); |
cdupaty | 0:d974bcee4f69 | 891 | |
cdupaty | 0:d974bcee4f69 | 892 | //! It checks if there is an available packet and its destination before a timeout. |
cdupaty | 0:d974bcee4f69 | 893 | /*! |
cdupaty | 0:d974bcee4f69 | 894 | * |
cdupaty | 0:d974bcee4f69 | 895 | \param uint16_t wait : time to wait while there is no a valid header received. |
cdupaty | 0:d974bcee4f69 | 896 | \return 'true' on success, 'false' otherwise |
cdupaty | 0:d974bcee4f69 | 897 | */ |
cdupaty | 0:d974bcee4f69 | 898 | boolean availableData(uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 899 | |
cdupaty | 0:d974bcee4f69 | 900 | //! It writes a packet in FIFO in order to send it. |
cdupaty | 0:d974bcee4f69 | 901 | /*! |
cdupaty | 0:d974bcee4f69 | 902 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 903 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 904 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 905 | */ |
cdupaty | 0:d974bcee4f69 | 906 | uint8_t setPacket(uint8_t dest, char *payload); |
cdupaty | 0:d974bcee4f69 | 907 | |
cdupaty | 0:d974bcee4f69 | 908 | //! It writes a packet in FIFO in order to send it. |
cdupaty | 0:d974bcee4f69 | 909 | /*! |
cdupaty | 0:d974bcee4f69 | 910 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 911 | \param uint8_t *payload: packet payload. |
cdupaty | 0:d974bcee4f69 | 912 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 913 | */ |
cdupaty | 0:d974bcee4f69 | 914 | uint8_t setPacket(uint8_t dest, uint8_t *payload); |
cdupaty | 0:d974bcee4f69 | 915 | |
cdupaty | 0:d974bcee4f69 | 916 | //! It reads a received packet from the FIFO, if it arrives before ending MAX_TIMEOUT time. |
cdupaty | 0:d974bcee4f69 | 917 | /*! |
cdupaty | 0:d974bcee4f69 | 918 | * |
cdupaty | 0:d974bcee4f69 | 919 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 920 | */ |
cdupaty | 0:d974bcee4f69 | 921 | uint8_t getPacketMAXTimeout(); |
cdupaty | 0:d974bcee4f69 | 922 | |
cdupaty | 0:d974bcee4f69 | 923 | //! It reads a received packet from the FIFO, if it arrives before ending '_sendTime' time. |
cdupaty | 0:d974bcee4f69 | 924 | /*! |
cdupaty | 0:d974bcee4f69 | 925 | * |
cdupaty | 0:d974bcee4f69 | 926 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 927 | */ |
cdupaty | 0:d974bcee4f69 | 928 | int8_t getPacket(); |
cdupaty | 0:d974bcee4f69 | 929 | |
cdupaty | 0:d974bcee4f69 | 930 | //! It receives and gets a packet from FIFO, if it arrives before ending 'wait' time. |
cdupaty | 0:d974bcee4f69 | 931 | /*! |
cdupaty | 0:d974bcee4f69 | 932 | * |
cdupaty | 0:d974bcee4f69 | 933 | \param uint16_t wait : time to wait while there is no a complete packet received. |
cdupaty | 0:d974bcee4f69 | 934 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 935 | */ |
cdupaty | 0:d974bcee4f69 | 936 | int8_t getPacket(uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 937 | |
cdupaty | 0:d974bcee4f69 | 938 | //! It sends the packet stored in FIFO before ending MAX_TIMEOUT. |
cdupaty | 0:d974bcee4f69 | 939 | /*! |
cdupaty | 0:d974bcee4f69 | 940 | * |
cdupaty | 0:d974bcee4f69 | 941 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 942 | */ |
cdupaty | 0:d974bcee4f69 | 943 | uint8_t sendWithMAXTimeout(); |
cdupaty | 0:d974bcee4f69 | 944 | |
cdupaty | 0:d974bcee4f69 | 945 | //! It sends the packet stored in FIFO before ending _sendTime time. |
cdupaty | 0:d974bcee4f69 | 946 | /*! |
cdupaty | 0:d974bcee4f69 | 947 | * |
cdupaty | 0:d974bcee4f69 | 948 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 949 | */ |
cdupaty | 0:d974bcee4f69 | 950 | uint8_t sendWithTimeout(); |
cdupaty | 0:d974bcee4f69 | 951 | |
cdupaty | 0:d974bcee4f69 | 952 | //! It tries to send the packet stored in FIFO before ending 'wait' time. |
cdupaty | 0:d974bcee4f69 | 953 | /*! |
cdupaty | 0:d974bcee4f69 | 954 | \param uint16_t wait : time to wait to send the packet. |
cdupaty | 0:d974bcee4f69 | 955 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 956 | */ |
cdupaty | 0:d974bcee4f69 | 957 | uint8_t sendWithTimeout(uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 958 | |
cdupaty | 0:d974bcee4f69 | 959 | //! It tries to send the packet wich payload is a parameter before ending MAX_TIMEOUT. |
cdupaty | 0:d974bcee4f69 | 960 | /*! |
cdupaty | 0:d974bcee4f69 | 961 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 962 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 963 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 964 | */ |
cdupaty | 0:d974bcee4f69 | 965 | uint8_t sendPacketMAXTimeout(uint8_t dest, char *payload); |
cdupaty | 0:d974bcee4f69 | 966 | |
cdupaty | 0:d974bcee4f69 | 967 | //! It tries to send the packet wich payload is a parameter before ending MAX_TIMEOUT. |
cdupaty | 0:d974bcee4f69 | 968 | /*! |
cdupaty | 0:d974bcee4f69 | 969 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 970 | \param uint8_t *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 971 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 972 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 973 | */ |
cdupaty | 0:d974bcee4f69 | 974 | uint8_t sendPacketMAXTimeout(uint8_t dest, uint8_t *payload, uint16_t length); |
cdupaty | 0:d974bcee4f69 | 975 | |
cdupaty | 0:d974bcee4f69 | 976 | |
cdupaty | 0:d974bcee4f69 | 977 | //! It sends the packet wich payload is a parameter before ending MAX_TIMEOUT. |
cdupaty | 0:d974bcee4f69 | 978 | /*! |
cdupaty | 0:d974bcee4f69 | 979 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 980 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 981 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 982 | */ |
cdupaty | 0:d974bcee4f69 | 983 | uint8_t sendPacketTimeout(uint8_t dest, char *payload); |
cdupaty | 0:d974bcee4f69 | 984 | |
cdupaty | 0:d974bcee4f69 | 985 | //! It sends the packet wich payload is a parameter before ending MAX_TIMEOUT. |
cdupaty | 0:d974bcee4f69 | 986 | /*! |
cdupaty | 0:d974bcee4f69 | 987 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 988 | \param uint8_t *payload: packet payload. |
cdupaty | 0:d974bcee4f69 | 989 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 990 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 991 | */ |
cdupaty | 0:d974bcee4f69 | 992 | uint8_t sendPacketTimeout(uint8_t dest, uint8_t *payload, uint16_t length); |
cdupaty | 0:d974bcee4f69 | 993 | |
cdupaty | 0:d974bcee4f69 | 994 | //! It sends the packet wich payload is a parameter before ending 'wait' time. |
cdupaty | 0:d974bcee4f69 | 995 | /*! |
cdupaty | 0:d974bcee4f69 | 996 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 997 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 998 | \param uint16_t wait : time to wait. |
cdupaty | 0:d974bcee4f69 | 999 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1000 | */ |
cdupaty | 0:d974bcee4f69 | 1001 | uint8_t sendPacketTimeout(uint8_t dest, char *payload, uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 1002 | |
cdupaty | 0:d974bcee4f69 | 1003 | //! It sends the packet wich payload is a parameter before ending 'wait' time. |
cdupaty | 0:d974bcee4f69 | 1004 | /*! |
cdupaty | 0:d974bcee4f69 | 1005 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1006 | \param uint8_t *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1007 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 1008 | \param uint16_t wait : time to wait. |
cdupaty | 0:d974bcee4f69 | 1009 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1010 | */ |
cdupaty | 0:d974bcee4f69 | 1011 | uint8_t sendPacketTimeout(uint8_t dest, uint8_t *payload, uint16_t length, uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 1012 | |
cdupaty | 0:d974bcee4f69 | 1013 | //! It sends the packet wich payload is a parameter before MAX_TIMEOUT, and replies with ACK. |
cdupaty | 0:d974bcee4f69 | 1014 | /*! |
cdupaty | 0:d974bcee4f69 | 1015 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1016 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1017 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1018 | */ |
cdupaty | 0:d974bcee4f69 | 1019 | uint8_t sendPacketMAXTimeoutACK(uint8_t dest, char *payload); |
cdupaty | 0:d974bcee4f69 | 1020 | |
cdupaty | 0:d974bcee4f69 | 1021 | //! It sends the packet wich payload is a parameter before MAX_TIMEOUT, and replies with ACK. |
cdupaty | 0:d974bcee4f69 | 1022 | /*! |
cdupaty | 0:d974bcee4f69 | 1023 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1024 | \param uint8_t payload: packet payload. |
cdupaty | 0:d974bcee4f69 | 1025 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 1026 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1027 | */ |
cdupaty | 0:d974bcee4f69 | 1028 | uint8_t sendPacketMAXTimeoutACK(uint8_t dest, uint8_t *payload, uint16_t length); |
cdupaty | 0:d974bcee4f69 | 1029 | |
cdupaty | 0:d974bcee4f69 | 1030 | //! It sends the packet wich payload is a parameter before a timeout, and replies with ACK. |
cdupaty | 0:d974bcee4f69 | 1031 | /*! |
cdupaty | 0:d974bcee4f69 | 1032 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1033 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1034 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1035 | */ |
cdupaty | 0:d974bcee4f69 | 1036 | uint8_t sendPacketTimeoutACK(uint8_t dest, char *payload); |
cdupaty | 0:d974bcee4f69 | 1037 | |
cdupaty | 0:d974bcee4f69 | 1038 | //! It sends the packet wich payload is a parameter before a timeout, and replies with ACK. |
cdupaty | 0:d974bcee4f69 | 1039 | /*! |
cdupaty | 0:d974bcee4f69 | 1040 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1041 | \param uint8_t payload: packet payload. |
cdupaty | 0:d974bcee4f69 | 1042 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 1043 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1044 | */ |
cdupaty | 0:d974bcee4f69 | 1045 | uint8_t sendPacketTimeoutACK(uint8_t dest, uint8_t *payload, uint16_t length); |
cdupaty | 0:d974bcee4f69 | 1046 | |
cdupaty | 0:d974bcee4f69 | 1047 | //! It sends the packet wich payload is a parameter before 'wait' time, and replies with ACK. |
cdupaty | 0:d974bcee4f69 | 1048 | /*! |
cdupaty | 0:d974bcee4f69 | 1049 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1050 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1051 | \param uint16_t wait : time to wait to send the packet. |
cdupaty | 0:d974bcee4f69 | 1052 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1053 | */ |
cdupaty | 0:d974bcee4f69 | 1054 | uint8_t sendPacketTimeoutACK(uint8_t dest, char *payload, uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 1055 | |
cdupaty | 0:d974bcee4f69 | 1056 | //! It sends the packet wich payload is a parameter before 'wait' time, and replies with ACK. |
cdupaty | 0:d974bcee4f69 | 1057 | /*! |
cdupaty | 0:d974bcee4f69 | 1058 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1059 | \param uint8_t payload: packet payload. |
cdupaty | 0:d974bcee4f69 | 1060 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 1061 | \param uint16_t wait : time to wait to send the packet. |
cdupaty | 0:d974bcee4f69 | 1062 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1063 | */ |
cdupaty | 0:d974bcee4f69 | 1064 | uint8_t sendPacketTimeoutACK(uint8_t dest, uint8_t *payload, uint16_t length, uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 1065 | |
cdupaty | 0:d974bcee4f69 | 1066 | //! It sets the destination of a packet. |
cdupaty | 0:d974bcee4f69 | 1067 | /*! |
cdupaty | 0:d974bcee4f69 | 1068 | \param uint8_t dest : value to set as destination address. |
cdupaty | 0:d974bcee4f69 | 1069 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1070 | */ |
cdupaty | 0:d974bcee4f69 | 1071 | int8_t setDestination(uint8_t dest); |
cdupaty | 0:d974bcee4f69 | 1072 | |
cdupaty | 0:d974bcee4f69 | 1073 | //! It sets the waiting time to send a packet. |
cdupaty | 0:d974bcee4f69 | 1074 | /*! |
cdupaty | 0:d974bcee4f69 | 1075 | It stores in global '_sendTime' variable the time for each mode. |
cdupaty | 0:d974bcee4f69 | 1076 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1077 | */ |
cdupaty | 0:d974bcee4f69 | 1078 | uint8_t setTimeout(); |
cdupaty | 0:d974bcee4f69 | 1079 | |
cdupaty | 0:d974bcee4f69 | 1080 | //! It sets the payload of the packet that is going to be sent. |
cdupaty | 0:d974bcee4f69 | 1081 | /*! |
cdupaty | 0:d974bcee4f69 | 1082 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1083 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1084 | */ |
cdupaty | 0:d974bcee4f69 | 1085 | uint8_t setPayload(char *payload); |
cdupaty | 0:d974bcee4f69 | 1086 | |
cdupaty | 0:d974bcee4f69 | 1087 | //! It sets the payload of the packet that is going to be sent. |
cdupaty | 0:d974bcee4f69 | 1088 | /*! |
cdupaty | 0:d974bcee4f69 | 1089 | \param uint8_t payload: packet payload. |
cdupaty | 0:d974bcee4f69 | 1090 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1091 | */ |
cdupaty | 0:d974bcee4f69 | 1092 | uint8_t setPayload(uint8_t *payload); |
cdupaty | 0:d974bcee4f69 | 1093 | |
cdupaty | 0:d974bcee4f69 | 1094 | //! If an ACK is received, it gets it and checks its content. |
cdupaty | 0:d974bcee4f69 | 1095 | /*! |
cdupaty | 0:d974bcee4f69 | 1096 | * |
cdupaty | 0:d974bcee4f69 | 1097 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1098 | */ |
cdupaty | 0:d974bcee4f69 | 1099 | uint8_t getACK(); |
cdupaty | 0:d974bcee4f69 | 1100 | |
cdupaty | 0:d974bcee4f69 | 1101 | //! It receives and gets an ACK from FIFO, if it arrives before ending 'wait' time. |
cdupaty | 0:d974bcee4f69 | 1102 | /*! |
cdupaty | 0:d974bcee4f69 | 1103 | * |
cdupaty | 0:d974bcee4f69 | 1104 | \param uint16_t wait : time to wait while there is no an ACK received. |
cdupaty | 0:d974bcee4f69 | 1105 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1106 | */ |
cdupaty | 0:d974bcee4f69 | 1107 | uint8_t getACK(uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 1108 | |
cdupaty | 0:d974bcee4f69 | 1109 | //! It sends a packet, waits to receive an ACK and updates the _retries value, before ending MAX_TIMEOUT time. |
cdupaty | 0:d974bcee4f69 | 1110 | /*! |
cdupaty | 0:d974bcee4f69 | 1111 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1112 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1113 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1114 | */ |
cdupaty | 0:d974bcee4f69 | 1115 | uint8_t sendPacketMAXTimeoutACKRetries(uint8_t dest, char *payload); |
cdupaty | 0:d974bcee4f69 | 1116 | |
cdupaty | 0:d974bcee4f69 | 1117 | //! It sends a packet, waits to receive an ACK and updates the _retries value, before ending MAX_TIMEOUT time. |
cdupaty | 0:d974bcee4f69 | 1118 | /*! |
cdupaty | 0:d974bcee4f69 | 1119 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1120 | \param uint8_t *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1121 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 1122 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1123 | */ |
cdupaty | 0:d974bcee4f69 | 1124 | uint8_t sendPacketMAXTimeoutACKRetries(uint8_t dest, uint8_t *payload, uint16_t length); |
cdupaty | 0:d974bcee4f69 | 1125 | |
cdupaty | 0:d974bcee4f69 | 1126 | //! It sends a packet, waits to receive an ACK and updates the _retries value. |
cdupaty | 0:d974bcee4f69 | 1127 | /*! |
cdupaty | 0:d974bcee4f69 | 1128 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1129 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1130 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1131 | */ |
cdupaty | 0:d974bcee4f69 | 1132 | uint8_t sendPacketTimeoutACKRetries(uint8_t dest, char *payload); |
cdupaty | 0:d974bcee4f69 | 1133 | |
cdupaty | 0:d974bcee4f69 | 1134 | //! It sends a packet, waits to receive an ACK and updates the _retries value. |
cdupaty | 0:d974bcee4f69 | 1135 | /*! |
cdupaty | 0:d974bcee4f69 | 1136 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1137 | \param uint8_t *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1138 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 1139 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1140 | */ |
cdupaty | 0:d974bcee4f69 | 1141 | uint8_t sendPacketTimeoutACKRetries(uint8_t dest, uint8_t *payload, uint16_t length); |
cdupaty | 0:d974bcee4f69 | 1142 | |
cdupaty | 0:d974bcee4f69 | 1143 | //! It sends a packet, waits to receive an ACK and updates the _retries value, before ending 'wait' time. |
cdupaty | 0:d974bcee4f69 | 1144 | /*! |
cdupaty | 0:d974bcee4f69 | 1145 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1146 | \param char *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1147 | \param uint16_t wait : time to wait while trying to send the packet. |
cdupaty | 0:d974bcee4f69 | 1148 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1149 | */ |
cdupaty | 0:d974bcee4f69 | 1150 | uint8_t sendPacketTimeoutACKRetries(uint8_t dest, char *payload, uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 1151 | |
cdupaty | 0:d974bcee4f69 | 1152 | //! It sends a packet, waits to receive an ACK and updates the _retries value, before ending 'wait' time. |
cdupaty | 0:d974bcee4f69 | 1153 | /*! |
cdupaty | 0:d974bcee4f69 | 1154 | \param uint8_t dest : packet destination. |
cdupaty | 0:d974bcee4f69 | 1155 | \param uint8_t *payload : packet payload. |
cdupaty | 0:d974bcee4f69 | 1156 | \param uint16_t length : payload buffer length. |
cdupaty | 0:d974bcee4f69 | 1157 | \param uint16_t wait : time to wait while trying to send the packet. |
cdupaty | 0:d974bcee4f69 | 1158 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1159 | */ |
cdupaty | 0:d974bcee4f69 | 1160 | uint8_t sendPacketTimeoutACKRetries(uint8_t dest, uint8_t *payload, uint16_t length, uint16_t wait); |
cdupaty | 0:d974bcee4f69 | 1161 | |
cdupaty | 0:d974bcee4f69 | 1162 | //! It gets the internal temperature of the module. |
cdupaty | 0:d974bcee4f69 | 1163 | /*! |
cdupaty | 0:d974bcee4f69 | 1164 | It stores in global '_temp' variable the module temperature. |
cdupaty | 0:d974bcee4f69 | 1165 | \return '0' on success, '1' otherwise |
cdupaty | 0:d974bcee4f69 | 1166 | */ |
cdupaty | 0:d974bcee4f69 | 1167 | uint8_t getTemp(); |
cdupaty | 0:d974bcee4f69 | 1168 | |
cdupaty | 0:d974bcee4f69 | 1169 | // added by C. Pham |
cdupaty | 0:d974bcee4f69 | 1170 | void setPacketType(uint8_t type); |
cdupaty | 0:d974bcee4f69 | 1171 | void RxChainCalibration(); |
cdupaty | 0:d974bcee4f69 | 1172 | uint8_t doCAD(uint8_t counter); |
cdupaty | 0:d974bcee4f69 | 1173 | uint16_t getToA(uint8_t pl); |
cdupaty | 0:d974bcee4f69 | 1174 | void CarrierSense(); |
cdupaty | 0:d974bcee4f69 | 1175 | int8_t setSyncWord(uint8_t sw); |
cdupaty | 0:d974bcee4f69 | 1176 | int8_t getSyncWord(); |
cdupaty | 0:d974bcee4f69 | 1177 | int8_t setSleepMode(); |
cdupaty | 0:d974bcee4f69 | 1178 | int8_t setPowerDBM(uint8_t dbm); |
cdupaty | 0:d974bcee4f69 | 1179 | long limitToA(); |
cdupaty | 0:d974bcee4f69 | 1180 | long getRemainingToA(); |
cdupaty | 0:d974bcee4f69 | 1181 | long removeToA(uint16_t toa); |
cdupaty | 0:d974bcee4f69 | 1182 | |
cdupaty | 0:d974bcee4f69 | 1183 | // SX1272 or SX1276? |
cdupaty | 0:d974bcee4f69 | 1184 | uint8_t _board; |
cdupaty | 0:d974bcee4f69 | 1185 | uint8_t _syncWord; |
cdupaty | 0:d974bcee4f69 | 1186 | uint8_t _defaultSyncWord; |
cdupaty | 0:d974bcee4f69 | 1187 | unsigned long _starttime; |
cdupaty | 0:d974bcee4f69 | 1188 | unsigned long _stoptime; |
cdupaty | 0:d974bcee4f69 | 1189 | unsigned long _startDoCad; |
cdupaty | 0:d974bcee4f69 | 1190 | unsigned long _endDoCad; |
cdupaty | 0:d974bcee4f69 | 1191 | uint8_t _loraMode; |
cdupaty | 0:d974bcee4f69 | 1192 | uint8_t _send_cad_number; |
cdupaty | 0:d974bcee4f69 | 1193 | bool _extendedIFS; |
cdupaty | 0:d974bcee4f69 | 1194 | bool _RSSIonSend; |
cdupaty | 0:d974bcee4f69 | 1195 | bool _enableCarrierSense; |
cdupaty | 0:d974bcee4f69 | 1196 | bool _rawFormat; |
cdupaty | 0:d974bcee4f69 | 1197 | int8_t _rcv_snr_in_ack; |
cdupaty | 0:d974bcee4f69 | 1198 | bool _needPABOOST; |
cdupaty | 0:d974bcee4f69 | 1199 | uint8_t _rawSNR; |
cdupaty | 0:d974bcee4f69 | 1200 | |
cdupaty | 0:d974bcee4f69 | 1201 | #ifdef W_REQUESTED_ACK |
cdupaty | 0:d974bcee4f69 | 1202 | uint8_t _requestACK; |
cdupaty | 0:d974bcee4f69 | 1203 | uint8_t _requestACK_indicator; |
cdupaty | 0:d974bcee4f69 | 1204 | #endif |
cdupaty | 0:d974bcee4f69 | 1205 | |
cdupaty | 0:d974bcee4f69 | 1206 | #ifdef W_NET_KEY |
cdupaty | 0:d974bcee4f69 | 1207 | uint8_t _my_netkey[NET_KEY_LENGTH]; |
cdupaty | 0:d974bcee4f69 | 1208 | uint8_t _the_net_key_0; |
cdupaty | 0:d974bcee4f69 | 1209 | uint8_t _the_net_key_1; |
cdupaty | 0:d974bcee4f69 | 1210 | #endif |
cdupaty | 0:d974bcee4f69 | 1211 | // end |
cdupaty | 0:d974bcee4f69 | 1212 | |
cdupaty | 0:d974bcee4f69 | 1213 | /// Variables ///////////////////////////////////////////////////////////// |
cdupaty | 0:d974bcee4f69 | 1214 | |
cdupaty | 0:d974bcee4f69 | 1215 | //! Variable : bandwidth configured in LoRa mode. |
cdupaty | 0:d974bcee4f69 | 1216 | //! bandwidth = 00 --> BW = 125KHz |
cdupaty | 0:d974bcee4f69 | 1217 | //! bandwidth = 01 --> BW = 250KHz |
cdupaty | 0:d974bcee4f69 | 1218 | //! bandwidth = 10 --> BW = 500KHz |
cdupaty | 0:d974bcee4f69 | 1219 | /*! |
cdupaty | 0:d974bcee4f69 | 1220 | */ |
cdupaty | 0:d974bcee4f69 | 1221 | uint8_t _bandwidth; |
cdupaty | 0:d974bcee4f69 | 1222 | |
cdupaty | 0:d974bcee4f69 | 1223 | //! Variable : coding rate configured in LoRa mode. |
cdupaty | 0:d974bcee4f69 | 1224 | //! codingRate = 001 --> CR = 4/5 |
cdupaty | 0:d974bcee4f69 | 1225 | //! codingRate = 010 --> CR = 4/6 |
cdupaty | 0:d974bcee4f69 | 1226 | //! codingRate = 011 --> CR = 4/7 |
cdupaty | 0:d974bcee4f69 | 1227 | //! codingRate = 100 --> CR = 4/8 |
cdupaty | 0:d974bcee4f69 | 1228 | /*! |
cdupaty | 0:d974bcee4f69 | 1229 | */ |
cdupaty | 0:d974bcee4f69 | 1230 | uint8_t _codingRate; |
cdupaty | 0:d974bcee4f69 | 1231 | |
cdupaty | 0:d974bcee4f69 | 1232 | //! Variable : spreading factor configured in LoRa mode. |
cdupaty | 0:d974bcee4f69 | 1233 | //! spreadingFactor = 6 --> SF = 6, 64 chips/symbol |
cdupaty | 0:d974bcee4f69 | 1234 | //! spreadingFactor = 7 --> SF = 7, 128 chips/symbol |
cdupaty | 0:d974bcee4f69 | 1235 | //! spreadingFactor = 8 --> SF = 8, 256 chips/symbol |
cdupaty | 0:d974bcee4f69 | 1236 | //! spreadingFactor = 9 --> SF = 9, 512 chips/symbol |
cdupaty | 0:d974bcee4f69 | 1237 | //! spreadingFactor = 10 --> SF = 10, 1024 chips/symbol |
cdupaty | 0:d974bcee4f69 | 1238 | //! spreadingFactor = 11 --> SF = 11, 2048 chips/symbol |
cdupaty | 0:d974bcee4f69 | 1239 | //! spreadingFactor = 12 --> SF = 12, 4096 chips/symbol |
cdupaty | 0:d974bcee4f69 | 1240 | /*! |
cdupaty | 0:d974bcee4f69 | 1241 | */ |
cdupaty | 0:d974bcee4f69 | 1242 | uint8_t _spreadingFactor; |
cdupaty | 0:d974bcee4f69 | 1243 | |
cdupaty | 0:d974bcee4f69 | 1244 | //! Variable : frequency channel. |
cdupaty | 0:d974bcee4f69 | 1245 | //! channel = 0xD84CCC --> CH = 10_868, 865.20MHz |
cdupaty | 0:d974bcee4f69 | 1246 | //! channel = 0xD86000 --> CH = 11_868, 865.50MHz |
cdupaty | 0:d974bcee4f69 | 1247 | //! channel = 0xD87333 --> CH = 12_868, 865.80MHz |
cdupaty | 0:d974bcee4f69 | 1248 | //! channel = 0xD88666 --> CH = 13_868, 866.10MHz |
cdupaty | 0:d974bcee4f69 | 1249 | //! channel = 0xD89999 --> CH = 14_868, 866.40MHz |
cdupaty | 0:d974bcee4f69 | 1250 | //! channel = 0xD8ACCC --> CH = 15_868, 866.70MHz |
cdupaty | 0:d974bcee4f69 | 1251 | //! channel = 0xD8C000 --> CH = 16_868, 867.00MHz |
cdupaty | 0:d974bcee4f69 | 1252 | //! channel = 0xE1C51E --> CH = 00_900, 903.08MHz |
cdupaty | 0:d974bcee4f69 | 1253 | //! channel = 0xE24F5C --> CH = 01_900, 905.24MHz |
cdupaty | 0:d974bcee4f69 | 1254 | //! channel = 0xE2D999 --> CH = 02_900, 907.40MHz |
cdupaty | 0:d974bcee4f69 | 1255 | //! channel = 0xE363D7 --> CH = 03_900, 909.56MHz |
cdupaty | 0:d974bcee4f69 | 1256 | //! channel = 0xE3EE14 --> CH = 04_900, 911.72MHz |
cdupaty | 0:d974bcee4f69 | 1257 | //! channel = 0xE47851 --> CH = 05_900, 913.88MHz |
cdupaty | 0:d974bcee4f69 | 1258 | //! channel = 0xE5028F --> CH = 06_900, 916.04MHz |
cdupaty | 0:d974bcee4f69 | 1259 | //! channel = 0xE58CCC --> CH = 07_900, 918.20MHz |
cdupaty | 0:d974bcee4f69 | 1260 | //! channel = 0xE6170A --> CH = 08_900, 920.36MHz |
cdupaty | 0:d974bcee4f69 | 1261 | //! channel = 0xE6A147 --> CH = 09_900, 922.52MHz |
cdupaty | 0:d974bcee4f69 | 1262 | //! channel = 0xE72B85 --> CH = 10_900, 924.68MHz |
cdupaty | 0:d974bcee4f69 | 1263 | //! channel = 0xE7B5C2 --> CH = 11_900, 926.84MHz |
cdupaty | 0:d974bcee4f69 | 1264 | /*! |
cdupaty | 0:d974bcee4f69 | 1265 | */ |
cdupaty | 0:d974bcee4f69 | 1266 | uint32_t _channel; |
cdupaty | 0:d974bcee4f69 | 1267 | |
cdupaty | 0:d974bcee4f69 | 1268 | //! Variable : output power. |
cdupaty | 0:d974bcee4f69 | 1269 | //! |
cdupaty | 0:d974bcee4f69 | 1270 | /*! |
cdupaty | 0:d974bcee4f69 | 1271 | */ |
cdupaty | 0:d974bcee4f69 | 1272 | uint8_t _power; |
cdupaty | 0:d974bcee4f69 | 1273 | |
cdupaty | 0:d974bcee4f69 | 1274 | //! Variable : SNR from the last packet received in LoRa mode. |
cdupaty | 0:d974bcee4f69 | 1275 | //! |
cdupaty | 0:d974bcee4f69 | 1276 | /*! |
cdupaty | 0:d974bcee4f69 | 1277 | */ |
cdupaty | 0:d974bcee4f69 | 1278 | int8_t _SNR; |
cdupaty | 0:d974bcee4f69 | 1279 | |
cdupaty | 0:d974bcee4f69 | 1280 | //! Variable : RSSI current value. |
cdupaty | 0:d974bcee4f69 | 1281 | //! |
cdupaty | 0:d974bcee4f69 | 1282 | /*! |
cdupaty | 0:d974bcee4f69 | 1283 | */ |
cdupaty | 0:d974bcee4f69 | 1284 | int8_t _RSSI; |
cdupaty | 0:d974bcee4f69 | 1285 | |
cdupaty | 0:d974bcee4f69 | 1286 | //! Variable : RSSI from the last packet received in LoRa mode. |
cdupaty | 0:d974bcee4f69 | 1287 | //! |
cdupaty | 0:d974bcee4f69 | 1288 | /*! |
cdupaty | 0:d974bcee4f69 | 1289 | */ |
cdupaty | 0:d974bcee4f69 | 1290 | int16_t _RSSIpacket; |
cdupaty | 0:d974bcee4f69 | 1291 | |
cdupaty | 0:d974bcee4f69 | 1292 | //! Variable : preamble length sent/received. |
cdupaty | 0:d974bcee4f69 | 1293 | //! |
cdupaty | 0:d974bcee4f69 | 1294 | /*! |
cdupaty | 0:d974bcee4f69 | 1295 | */ |
cdupaty | 0:d974bcee4f69 | 1296 | uint16_t _preamblelength; |
cdupaty | 0:d974bcee4f69 | 1297 | |
cdupaty | 0:d974bcee4f69 | 1298 | //! Variable : payload length sent/received. |
cdupaty | 0:d974bcee4f69 | 1299 | //! |
cdupaty | 0:d974bcee4f69 | 1300 | /*! |
cdupaty | 0:d974bcee4f69 | 1301 | */ |
cdupaty | 0:d974bcee4f69 | 1302 | uint16_t _payloadlength; |
cdupaty | 0:d974bcee4f69 | 1303 | |
cdupaty | 0:d974bcee4f69 | 1304 | //! Variable : node address. |
cdupaty | 0:d974bcee4f69 | 1305 | //! |
cdupaty | 0:d974bcee4f69 | 1306 | /*! |
cdupaty | 0:d974bcee4f69 | 1307 | */ |
cdupaty | 0:d974bcee4f69 | 1308 | uint8_t _nodeAddress; |
cdupaty | 0:d974bcee4f69 | 1309 | |
cdupaty | 0:d974bcee4f69 | 1310 | //! Variable : implicit or explicit header in LoRa mode. |
cdupaty | 0:d974bcee4f69 | 1311 | //! |
cdupaty | 0:d974bcee4f69 | 1312 | /*! |
cdupaty | 0:d974bcee4f69 | 1313 | */ |
cdupaty | 0:d974bcee4f69 | 1314 | uint8_t _header; |
cdupaty | 0:d974bcee4f69 | 1315 | |
cdupaty | 0:d974bcee4f69 | 1316 | //! Variable : header received while waiting a packet to arrive. |
cdupaty | 0:d974bcee4f69 | 1317 | //! |
cdupaty | 0:d974bcee4f69 | 1318 | /*! |
cdupaty | 0:d974bcee4f69 | 1319 | */ |
cdupaty | 0:d974bcee4f69 | 1320 | uint8_t _hreceived; |
cdupaty | 0:d974bcee4f69 | 1321 | |
cdupaty | 0:d974bcee4f69 | 1322 | //! Variable : presence or absence of CRC calculation. |
cdupaty | 0:d974bcee4f69 | 1323 | //! |
cdupaty | 0:d974bcee4f69 | 1324 | /*! |
cdupaty | 0:d974bcee4f69 | 1325 | */ |
cdupaty | 0:d974bcee4f69 | 1326 | uint8_t _CRC; |
cdupaty | 0:d974bcee4f69 | 1327 | |
cdupaty | 0:d974bcee4f69 | 1328 | //! Variable : packet destination. |
cdupaty | 0:d974bcee4f69 | 1329 | //! |
cdupaty | 0:d974bcee4f69 | 1330 | /*! |
cdupaty | 0:d974bcee4f69 | 1331 | */ |
cdupaty | 0:d974bcee4f69 | 1332 | uint8_t _destination; |
cdupaty | 0:d974bcee4f69 | 1333 | |
cdupaty | 0:d974bcee4f69 | 1334 | //! Variable : packet number. |
cdupaty | 0:d974bcee4f69 | 1335 | //! |
cdupaty | 0:d974bcee4f69 | 1336 | /*! |
cdupaty | 0:d974bcee4f69 | 1337 | */ |
cdupaty | 0:d974bcee4f69 | 1338 | uint8_t _packetNumber; |
cdupaty | 0:d974bcee4f69 | 1339 | |
cdupaty | 0:d974bcee4f69 | 1340 | //! Variable : indicates if received packet is correct or incorrect. |
cdupaty | 0:d974bcee4f69 | 1341 | //! |
cdupaty | 0:d974bcee4f69 | 1342 | /*! |
cdupaty | 0:d974bcee4f69 | 1343 | */ |
cdupaty | 0:d974bcee4f69 | 1344 | uint8_t _reception; |
cdupaty | 0:d974bcee4f69 | 1345 | |
cdupaty | 0:d974bcee4f69 | 1346 | //! Variable : number of current retry. |
cdupaty | 0:d974bcee4f69 | 1347 | //! |
cdupaty | 0:d974bcee4f69 | 1348 | /*! |
cdupaty | 0:d974bcee4f69 | 1349 | */ |
cdupaty | 0:d974bcee4f69 | 1350 | uint8_t _retries; |
cdupaty | 0:d974bcee4f69 | 1351 | |
cdupaty | 0:d974bcee4f69 | 1352 | //! Variable : maximum number of retries. |
cdupaty | 0:d974bcee4f69 | 1353 | //! |
cdupaty | 0:d974bcee4f69 | 1354 | /*! |
cdupaty | 0:d974bcee4f69 | 1355 | */ |
cdupaty | 0:d974bcee4f69 | 1356 | uint8_t _maxRetries; |
cdupaty | 0:d974bcee4f69 | 1357 | |
cdupaty | 0:d974bcee4f69 | 1358 | //! Variable : maximum current supply. |
cdupaty | 0:d974bcee4f69 | 1359 | //! |
cdupaty | 0:d974bcee4f69 | 1360 | /*! |
cdupaty | 0:d974bcee4f69 | 1361 | */ |
cdupaty | 0:d974bcee4f69 | 1362 | uint8_t _maxCurrent; |
cdupaty | 0:d974bcee4f69 | 1363 | |
cdupaty | 0:d974bcee4f69 | 1364 | //! Variable : indicates FSK or LoRa 'modem'. |
cdupaty | 0:d974bcee4f69 | 1365 | //! |
cdupaty | 0:d974bcee4f69 | 1366 | /*! |
cdupaty | 0:d974bcee4f69 | 1367 | */ |
cdupaty | 0:d974bcee4f69 | 1368 | uint8_t _modem; |
cdupaty | 0:d974bcee4f69 | 1369 | |
cdupaty | 0:d974bcee4f69 | 1370 | //! Variable : array with all the information about a sent packet. |
cdupaty | 0:d974bcee4f69 | 1371 | //! |
cdupaty | 0:d974bcee4f69 | 1372 | /*! |
cdupaty | 0:d974bcee4f69 | 1373 | */ |
cdupaty | 0:d974bcee4f69 | 1374 | pack packet_sent; |
cdupaty | 0:d974bcee4f69 | 1375 | |
cdupaty | 0:d974bcee4f69 | 1376 | //! Variable : array with all the information about a received packet. |
cdupaty | 0:d974bcee4f69 | 1377 | //! |
cdupaty | 0:d974bcee4f69 | 1378 | /*! |
cdupaty | 0:d974bcee4f69 | 1379 | */ |
cdupaty | 0:d974bcee4f69 | 1380 | pack packet_received; |
cdupaty | 0:d974bcee4f69 | 1381 | |
cdupaty | 0:d974bcee4f69 | 1382 | //! Variable : array with all the information about a sent/received ack. |
cdupaty | 0:d974bcee4f69 | 1383 | //! |
cdupaty | 0:d974bcee4f69 | 1384 | /*! |
cdupaty | 0:d974bcee4f69 | 1385 | */ |
cdupaty | 0:d974bcee4f69 | 1386 | pack ACK; |
cdupaty | 0:d974bcee4f69 | 1387 | |
cdupaty | 0:d974bcee4f69 | 1388 | //! Variable : temperature module. |
cdupaty | 0:d974bcee4f69 | 1389 | //! |
cdupaty | 0:d974bcee4f69 | 1390 | /*! |
cdupaty | 0:d974bcee4f69 | 1391 | */ |
cdupaty | 0:d974bcee4f69 | 1392 | int _temp; |
cdupaty | 0:d974bcee4f69 | 1393 | |
cdupaty | 0:d974bcee4f69 | 1394 | //! Variable : current timeout to send a packet. |
cdupaty | 0:d974bcee4f69 | 1395 | //! |
cdupaty | 0:d974bcee4f69 | 1396 | /*! |
cdupaty | 0:d974bcee4f69 | 1397 | */ |
cdupaty | 0:d974bcee4f69 | 1398 | uint16_t _sendTime; |
cdupaty | 0:d974bcee4f69 | 1399 | |
cdupaty | 0:d974bcee4f69 | 1400 | // added by C. Pham for ToA management |
cdupaty | 0:d974bcee4f69 | 1401 | // |
cdupaty | 0:d974bcee4f69 | 1402 | private: |
cdupaty | 0:d974bcee4f69 | 1403 | |
cdupaty | 0:d974bcee4f69 | 1404 | bool _limitToA; |
cdupaty | 0:d974bcee4f69 | 1405 | long _remainingToA; |
cdupaty | 0:d974bcee4f69 | 1406 | unsigned long _startToAcycle; |
cdupaty | 0:d974bcee4f69 | 1407 | unsigned long _endToAcycle; |
cdupaty | 0:d974bcee4f69 | 1408 | uint16_t _currentToA; |
cdupaty | 0:d974bcee4f69 | 1409 | }; |
cdupaty | 0:d974bcee4f69 | 1410 | |
cdupaty | 0:d974bcee4f69 | 1411 | extern SX1272 sx1272; |
cdupaty | 0:d974bcee4f69 | 1412 | |
cdupaty | 0:d974bcee4f69 | 1413 | #endif |