Library SX1272, initially created by C.Pham, University of Pau, France for Arduino. Suitable for MBED / NUCLEO / STM32

Dependents:   LOW_COAST_LORA_NODE

Committer:
cdupaty
Date:
Tue Feb 06 09:58:17 2018 +0000
Revision:
2:a5a72d30cb18
Parent:
1:5d57c6a92509
Version of C.Pham project (university of Pau, France) ; Originally for Arduino. Ported on NUCLEO L073RZ; Please read main.cpp

Who changed what in which revision?

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