armapi  v1.0
bĂȘta
arm.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 // Created date: 17.11.2015
3 // ---------------------------------------------------------------------
4 
5 /***********************************************************************
6 
7  Copyright (c) 2016 ATIM
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a copy
11  of this software and associated documentation files (the "Software"), to deal
12  in the Software without restriction, including without limitation the rights
13  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14  copies of the Software, and to permit persons to whom the Software is
15  furnished to do so, subject to the following conditions:
16 
17 
18  The above copyright notice and this permission notice shall be included in
19  all copies or substantial portions of the Software.
20 
21 
22  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28  THE SOFTWARE.
29 
30 ***********************************************************************/
31 
32 #ifndef ARM_H
33 #define ARM_H
34 
35 // ---------------------------------------------------------------------
36 // Include
37 // ---------------------------------------------------------------------
38 #include <stdbool.h>
39 
40 #include "armconfig.h"
41 #include "armconst.h"
42 #include "armport.h"
43 
44 // ---------------------------------------------------------------------
45 // Define
46 // ---------------------------------------------------------------------
47 
53 #define ARM_FSK_BROADCAST 255
54 
60 #define ARM_FSK_POWER_AUTO (-127)
61 
68 #define ARM_LW_UNCONFIRMED(val) ((-1)*(val))
69 
76 #define ARM_LW_IS_UNCONFIRMED(val) ((val)<=0)
77 
78 // ---------------------------------------------------------------------
79 // Enum
80 // ---------------------------------------------------------------------
81 
86 typedef enum armError_e
87 {
90 
97 
103 
110 }armError_t;
111 
116 typedef enum armBaudrate_e
117 {
128 
134 typedef enum armFskWor_e
135 {
141 }armFskWor_t;
143 
149 typedef enum armLed_e
150 {
154 }armLed_t;
155 
161 typedef enum armFskLbtAfa_e
162 {
168 
174 typedef enum armMode_e
175 {
179 }armMode_t;
180 
186 typedef enum armType_e
187 {
188  ARM_TYPE_NONE = 0x01,
189  ARM_TYPE_N8_LP = 0x02,
190  ARM_TYPE_N8_LD = 0x04,
191  ARM_TYPE_N8_LW = 0x08,
192 }armType_t;
193 
194 // ---------------------------------------------------------------------
195 // struct
196 // ---------------------------------------------------------------------
197 
198 #ifndef __DOXYGEN__
199 
202 typedef struct uint128_s
203 {
204  uint64_t lsb;
205  uint64_t msb;
206 }uint128_t;
207 
211 typedef struct armReg_s
212 {
213  uint8_t reg;
214  uint8_t val;
215  uint8_t newVal;
216 }armReg_t;
217 
221 typedef struct armN8LpLd_s
222 {
223  armReg_t regsH[_ARM_N8LPLD_REGH_SIZE];
224 }armN8LpLd_t;
225 
229 typedef struct armN8Lw_s
230 {
231  armReg_t regsM[_ARM_N8LW_REGM_SIZE];
232  armReg_t regsO[_ARM_N8LW_REGO_SIZE];
233 }armN8Lw_t;
234 
238 typedef struct arm_s
239 {
240  void* _port;
241  armType_t _type;
242  union
243  {
244  #ifdef ARM_WITH_N8_LPLD
245  armN8LpLd_t _N8LPLD;
246  #endif
247  #ifdef ARM_WITH_N8_LW
248  armN8Lw_t _N8LW;
249  #endif
250  };
251 }arm_t;
252 
253 #endif
254 
255 // ---------------------------------------------------------------------
256 // Prototypes functions
257 // ---------------------------------------------------------------------
258 
279 armError_t armInit(arm_t* arm, void* port);
280 
290 armError_t armDeInit(arm_t* arm);
291 
311 armError_t armReboot(arm_t* arm);
312 
336 armError_t armInfo(arm_t* arm, armType_t* armType, uint8_t* rev, uint64_t* sn, uint16_t* rfFreq, uint8_t* rfPower);
337 
355 armError_t armSetMode(arm_t* arm, armMode_t mode);
356 
368 armMode_t armGetMode(arm_t* arm);
369 
389 armError_t armSfxEnableDownlink(arm_t* arm, bool enable);
390 
404 bool armSfxIsEnableDownlink(arm_t* arm);
405 
418 int8_t armFskMaxPower(uint16_t radioChannel, armBaudrate_t radioBaud);
419 
465 armError_t armFskSetRadio(arm_t* arm, uint16_t channel, armBaudrate_t baud, int8_t power);
466 
485 void armFskGetRadio(arm_t* arm, uint16_t* channel, armBaudrate_t* baud, int8_t* power);
486 
509 armError_t armFskSetRemoteAdd(arm_t* arm, uint8_t add);
510 
525 uint8_t armFskGetRemoteAdd(arm_t* arm);
526 
548 armError_t armFskSetLocalAdd(arm_t* arm, uint8_t add);
549 
564 uint8_t armFskGetLocalAdd(arm_t* arm);
565 
582 void armFskEnableAddressing(arm_t* arm, bool enable);
583 
598 bool armFskIsEnableAddressing(arm_t* arm);
599 
618 void armFskEnableCrc(arm_t* arm, bool enable);
619 
634 bool armFskIsEnableCrc(arm_t* arm);
635 
658 armError_t armFskEnableInfinityMode(arm_t* arm, bool enable);
659 
674 bool armFskIsEnableInfinityMode(arm_t* arm);
675 
692 void armFskEnableWhitening(arm_t *arm, bool enable);
693 
708 bool armFskIsEnableWhitening(arm_t *arm);
709 
763 
782 void armGetSerial(arm_t* arm, armPortBaudrate_t* baud, armPortDatabits_t* databits, armPortParity_t* parity, armPortStopbit_t* stopbit);
783 
856 armError_t armFskSetWorMode(arm_t* arm, armFskWor_t mode, uint16_t periodTime, uint16_t postTime, int8_t rssiLevel, bool filterLongPreamble);
857 
882 void armFskGetWorMode(arm_t* arm, armFskWor_t* mode, uint16_t* periodTime, uint16_t* postTime, int8_t* rssiLevel, bool* filterLongPreamble);
883 
914 armError_t armEnableWakeUpUart(arm_t *arm, bool enable);
915 
930 bool armIsEnableWakeUpUart(arm_t *arm);
931 
932 #if defined ARMPORT_WITH_nSLEEP || defined __DOXYGEN__
933 
950 void armSleep(arm_t* arm, bool sleep);
951 #endif
952 
1006 armError_t armFskSetLbtAfaMode(arm_t* arm, armFskLbtAfa_t mode, int8_t rssiLevel, uint16_t nSamples, uint16_t channel2);
1007 
1030 void armFskGetLbtAfaMode(arm_t* arm, armFskLbtAfa_t* mode, int8_t* rssiLevel, uint16_t* nSamples, uint16_t* channel2);
1031 
1032 
1086 armError_t armLwSetRadio(arm_t* arm, uint8_t txChannel, uint8_t power, uint8_t txSf, uint8_t rx2Sf, uint8_t rx2Channel);
1087 
1107 void armLwGetRadio(arm_t* arm, uint8_t* txChannel, uint8_t* power, uint8_t* txSf, uint8_t* rx2Sf, uint8_t* rx2Channel);
1108 
1145 armError_t armLwSetConfirmedFrame(arm_t* arm, int8_t nbFrame);
1146 
1187 int8_t armLwGetConfirmedFrame(arm_t* arm);
1188 
1207 void armLwSetPortField(arm_t* arm, uint8_t port);
1208 
1222 uint8_t armLwGetPortField(arm_t* arm);
1223 
1240 void armLwEnableOtaa(arm_t* arm, bool enable);
1241 
1255 bool armLwIsEnableOtaa(arm_t* arm);
1256 
1274 void armLwEnableRxWindows(arm_t* arm, bool enable);
1275 
1289 bool armLwIsEnableRxWindows(arm_t* arm);
1290 
1308 void armLwEnableTxAdaptiveSpeed(arm_t* arm, bool enable);
1309 
1323 bool armLwIsEnableTxAdaptiveSpeed(arm_t* arm);
1324 
1341 void armLwEnableDutyCycle(arm_t* arm, bool enable);
1342 
1356 bool armLwIsEnableDutyCycle(arm_t* arm);
1357 
1375 void armLwEnableTxAdaptiveChannel(arm_t* arm, bool enable);
1376 
1390 bool armLwIsEnableTxAdaptiveChannel(arm_t* arm);
1391 
1409 void armLwEnableRx2Adaptive(arm_t* arm, bool enable);
1410 
1424 bool armLwIsEnableRx2Adaptive(arm_t* arm);
1425 
1451 armError_t armLwIds(arm_t* arm, uint32_t* devAddr,
1452  uint64_t* devEui,
1453  uint64_t* appEui,
1454  uint128_t* appKey,
1455  uint128_t* nwkSKey,
1456  uint128_t* appSKey);
1457 
1478 void armSetLed(arm_t* arm, armLed_t led);
1479 
1498 armLed_t armGetLed(arm_t* arm);
1499 
1521 armError_t armUpdateConfig(arm_t* arm);
1522 
1546 int armSend(arm_t* arm, const void* buf, size_t nbyte);
1547 
1567 int armReceive(arm_t* arm, void* buf, size_t nbyte, int timeout);
1568 
1569 #endif //ARM_H
armError_t armLwSetRadio(arm_t *arm, uint8_t txChannel, uint8_t power, uint8_t txSf, uint8_t rx2Sf, uint8_t rx2Channel)
Setup the LoraWan radio configuration.
115200 bps.
Definition: arm.h:126
armError_e
Constant to define the errors.
Definition: arm.h:86
bool armLwIsEnableOtaa(arm_t *arm)
Get if Over The Air Activation is enable.
Enable Adaptive Frequency Agility, is used to receive data on one channel of the two.
Definition: arm.h:165
armPortParity_t
Constant to define the parity type.
Definition: armport.h:91
The LED is &#39;off&#39; all the time.
Definition: arm.h:151
void armFskGetWorMode(arm_t *arm, armFskWor_t *mode, uint16_t *periodTime, uint16_t *postTime, int8_t *rssiLevel, bool *filterLongPreamble)
Get the wake on radio mode configuration.
Disable WOR mode.
Definition: arm.h:136
enum armBaudrate_e armBaudrate_t
Constant to define the baudrate value.
void armLwSetPortField(arm_t *arm, uint8_t port)
Set the port field.
That is probably a error.
Definition: arm.h:118
armError_t armSfxEnableDownlink(arm_t *arm, bool enable)
Enable/Disable the Sigfox downlink.
9600 bps.
Definition: arm.h:122
enum armFskLbtAfa_e armFskLbtAfa_t
Constant to define the LBT&AFA mode &#39;Listen before talk&#39; and &#39;Adaptive Frequency Agility&#39;.
uint8_t armFskGetRemoteAdd(arm_t *arm)
Get the remote address.
enum armType_e armType_t
Type of ARM.
Port Error, at the port reading.
Definition: arm.h:93
armError_t armInfo(arm_t *arm, armType_t *armType, uint8_t *rev, uint64_t *sn, uint16_t *rfFreq, uint8_t *rfPower)
Get information about the ARM.
ARM commend Error, from AT commend.
Definition: arm.h:107
armFskWor_e
Constant to define the WOR mode &#39;Wake On Radio&#39;.
Definition: arm.h:134
Mode for Fsk (local) radio.
Definition: arm.h:176
void armSetLed(arm_t *arm, armLed_t led)
Set the LED behavior.
void armFskEnableAddressing(arm_t *arm, bool enable)
Enable/Disable Addressing.
armBaudrate_e
Constant to define the baudrate value.
Definition: arm.h:116
void armLwEnableTxAdaptiveSpeed(arm_t *arm, bool enable)
Enable/Disable Tx Adaptive Speed.
Definition: arm.h:140
void armFskGetRadio(arm_t *arm, uint16_t *channel, armBaudrate_t *baud, int8_t *power)
Get the fsk (local) radio configuration.
enum armMode_e armMode_t
Constant to define the working mode.
Mode for Sigfox network.
Definition: arm.h:177
void armFskGetLbtAfaMode(arm_t *arm, armFskLbtAfa_t *mode, int8_t *rssiLevel, uint16_t *nSamples, uint16_t *channel2)
Get the wake up on mode configuration.
uint8_t armFskGetLocalAdd(arm_t *arm)
Get the local address.
Enable Listen Before Talk and adaptive Frequency Agility, listen on the tow channels and talk on the ...
Definition: arm.h:166
No error.
Definition: arm.h:88
armError_t armFskSetRadio(arm_t *arm, uint16_t channel, armBaudrate_t baud, int8_t power)
Setup the Fsk (local) radio configuration.
armLed_e
Constant to define the comportment of the LED.
Definition: arm.h:149
armType_e
Type of ARM.
Definition: arm.h:186
Error, the parameters is incompatible between them.
Definition: arm.h:99
void armLwEnableRx2Adaptive(arm_t *arm, bool enable)
Enable/Disable Rx2 windows Adaptive.
armError_t armLwSetConfirmedFrame(arm_t *arm, int8_t nbFrame)
Enable/Disable and set the confirmed frame.
armMode_e
Constant to define the working mode.
Definition: arm.h:174
void armLwEnableDutyCycle(arm_t *arm, bool enable)
Enable/Disable Duty Cycle.
enum armError_e armError_t
Constant to define the errors.
Port Error, at the port writing.
Definition: arm.h:94
The LED is &#39;off&#39; on RF activity and &#39;on&#39; other time.
Definition: arm.h:152
armLed_t armGetLed(arm_t *arm)
Get the LED behavior.
ARM Nano in 868MHz low power version (and Sigfox).
Definition: arm.h:189
19200 bps.
Definition: arm.h:123
armFskLbtAfa_e
Constant to define the LBT&AFA mode &#39;Listen before talk&#39; and &#39;Adaptive Frequency Agility&#39;.
Definition: arm.h:161
ARM commend Error, from set register.
Definition: arm.h:109
armError_t armReboot(arm_t *arm)
Reboot the ARM.
bool armFskIsEnableCrc(arm_t *arm)
Get enable CRC.
armError_t armLwIds(arm_t *arm, uint32_t *devAddr, uint64_t *devEui, uint64_t *appEui, uint128_t *appKey, uint128_t *nwkSKey, uint128_t *appSKey)
Get the IDs.
bool armIsEnableWakeUpUart(arm_t *arm)
Get if Wake Up Uart is enable.
void armSleep(arm_t *arm, bool sleep)
Enable/Disable sleep with pin.
armPortDatabits_t
Constant to define the data bits value.
Definition: armport.h:81
ARM Nano in 868MHz LoraWan version.
Definition: arm.h:191
void armLwEnableOtaa(arm_t *arm, bool enable)
Enable/Disable Over The Air Activation.
armPortBaudrate_t
Constant to define the baudrate value.
Definition: armport.h:63
armError_t armUpdateConfig(arm_t *arm)
Update the configuration in ARM.
ARM commend Error, can&#39;t switch to AT commend.
Definition: arm.h:105
ARM Nano in 868MHz long distance version.
Definition: arm.h:190
void armLwEnableTxAdaptiveChannel(arm_t *arm, bool enable)
Enable/Disable Tx Adaptive Channel.
Definition: arm.h:102
Definition: arm.h:100
bool armLwIsEnableRx2Adaptive(arm_t *arm)
Get if Rx2 windows Adaptive is enable.
int8_t armLwGetConfirmedFrame(arm_t *arm)
Get the setup of confirmed frame.
armError_t armFskEnableInfinityMode(arm_t *arm, bool enable)
Enable/Disable Infinity mode.
enum armLed_e armLed_t
Constant to define the comportment of the LED.
4800 bps.
Definition: arm.h:121
void armFskEnableWhitening(arm_t *arm, bool enable)
Enable/Disable Whitening.
armError_t armEnableWakeUpUart(arm_t *arm, bool enable)
Enable/Disable the Wake Up Uart.
armPortStopbit_t
Constant to define the number stop bits.
Definition: armport.h:102
Functionality no supported by theARM.
Definition: arm.h:89
void armGetSerial(arm_t *arm, armPortBaudrate_t *baud, armPortDatabits_t *databits, armPortParity_t *parity, armPortStopbit_t *stopbit)
Get the serial port configuration.
ARM commend Error, can&#39;t quit AT commend.
Definition: arm.h:106
bool armFskIsEnableAddressing(arm_t *arm)
Get enable Addressing.
int armReceive(arm_t *arm, void *buf, size_t nbyte, int timeout)
Receive data from ARM.
armError_t armSetSerial(arm_t *arm, armPortBaudrate_t baud, armPortDatabits_t databits, armPortParity_t parity, armPortStopbit_t stopbit)
Setup serial port configuration.
bool armLwIsEnableTxAdaptiveChannel(arm_t *arm)
Get if Tx Adaptive Channel is enable.
Error, one or more of parameters is out of range.
Definition: arm.h:98
armError_t armFskSetRemoteAdd(arm_t *arm, uint8_t add)
Set the radio remote address.
uint8_t armLwGetPortField(arm_t *arm)
Get the port field.
bool armLwIsEnableRxWindows(arm_t *arm)
Get if Rx windows is enable.
bool armLwIsEnableDutyCycle(arm_t *arm)
Get if Duty Cycle is enable.
Port Error, at the port closing.
Definition: arm.h:96
Port Error, at the port configuring.
Definition: arm.h:92
bool armFskIsEnableInfinityMode(arm_t *arm)
Get enable Infinity mode.
Disable all LBT&AFA mode.
Definition: arm.h:163
Port Error, at the port opening.
Definition: arm.h:91
The LED is &#39;on&#39; on RF activity and &#39;off&#39; other time.
Definition: arm.h:153
int8_t armFskMaxPower(uint16_t radioChannel, armBaudrate_t radioBaud)
Get The maximal possible power.
armMode_t armGetMode(arm_t *arm)
Get the mode.
armError_t armSetMode(arm_t *arm, armMode_t mode)
Set the mode.
enum armFskWor_e armFskWor_t
Constant to define the WOR mode &#39;Wake On Radio&#39;.
bool armLwIsEnableTxAdaptiveSpeed(arm_t *arm)
Get if Tx Adaptive Speed is enable.
Definition: arm.h:138
Enable long preamble for the transmitter, then wake up the receptor.
Definition: arm.h:137
2400 bps.
Definition: arm.h:120
38400 bps.
Definition: arm.h:124
57600 bps.
Definition: arm.h:125
Enable Listen Before Talk .
Definition: arm.h:164
Mode for Lora network (LoRaWan).
Definition: arm.h:178
armError_t armFskSetWorMode(arm_t *arm, armFskWor_t mode, uint16_t periodTime, uint16_t postTime, int8_t rssiLevel, bool filterLongPreamble)
Enable/Disable and configure the wake on radio mode.
Port Error, at the port reading/writing.
Definition: arm.h:95
No Arm type.
Definition: arm.h:188
void armFskEnableCrc(arm_t *arm, bool enable)
Enable/Disable CRC.
armError_t armDeInit(arm_t *arm)
De-initialize the port.
ARM commend Error, from get register.
Definition: arm.h:108
void armLwGetRadio(arm_t *arm, uint8_t *txChannel, uint8_t *power, uint8_t *txSf, uint8_t *rx2Sf, uint8_t *rx2Channel)
Get the LoraWan radio configuration.
void armLwEnableRxWindows(arm_t *arm, bool enable)
Enable/Disable Rx windows.
armError_t armFskSetLbtAfaMode(arm_t *arm, armFskLbtAfa_t mode, int8_t rssiLevel, uint16_t nSamples, uint16_t channel2)
Enable/Disable and configure the Lbt&Afa mode.
bool armSfxIsEnableDownlink(arm_t *arm)
Get if the Sigfox downlink is enable.
bool armFskIsEnableWhitening(arm_t *arm)
Get enable Whitening.
armError_t armInit(arm_t *arm, void *port)
Initialize the structure, port and ARM.
int armSend(arm_t *arm, const void *buf, size_t nbyte)
Send data to ARM.
armError_t armFskSetLocalAdd(arm_t *arm, uint8_t add)
Set the radio local address.
1200 bps.
Definition: arm.h:119