|
Arduino LMIC 6.0.1
Arduino LoRaWAN(r) MAC in C
|
LMIC API. More...
Go to the source code of this file.
Data Structures | |
| struct | bcninfo_t |
| Information about the last and previous beacons. More... | |
| struct | lmic_channel_info_s |
| description of one channel, filled in by LMIC_queryChannel(). More... | |
| struct | lmic_class_c_flags_u::lmic_class_c_flags_s |
| the Class C operating flags More... | |
| union | lmic_class_c_flags_u |
| details of lmic_class_c_flags_t. More... | |
| struct | lmic_class_c_requests_u::lmic_class_c_requests_s |
| the Class C request flags More... | |
| union | lmic_class_c_requests_u |
| details of lmic_class_c_requests_t More... | |
| struct | lmic_class_c_s |
| details of class C state More... | |
| struct | lmic_client_data_s |
| contents of lmic_client_data_t More... | |
| struct | lmic_radio_data_s |
| Details of instance data for LMIC radio driver. More... | |
| struct | lmic_t |
| Instance data for the LMIC. More... | |
| struct | lmic_time_reference_s |
| struct | rxsched_t |
Macros | |
| #define | DR_RANGE_MAP(drlo, drhi) |
| Construct a bit map of allowed datarates from drlo to drhi (both included). | |
| #define | LMIC_ERROR_NAME__INIT |
| Macro to initalize a normal table of error name strings. | |
| #define | LMIC_ERROR_NAME_MULTISZ__INIT |
| Macro to initialize a compressed string of error name strings. | |
| #define | LMIC_EVENT_NAME_MULTISZ__INIT |
| Macro to initialize a compressed string of event strings. | |
| #define | LMIC_EVENT_NAME_TABLE__INIT |
| Macro to initialize a normal table of event strings. | |
Typedefs | |
| typedef s1_t | lmic_beacon_error_t |
| Error codes returned for beacon operations. | |
| typedef enum lmic_channel_bandwidth_e | lmic_channel_bandwidth_t |
| the bandwidth of a channel, as reported by LMIC_queryChannel(). | |
| typedef struct lmic_channel_info_s | lmic_channel_info_t |
| description of one channel, filled in by LMIC_queryChannel(). | |
| typedef struct lmic_client_data_s | lmic_client_data_t |
| abstract type for collection of client data that survives LMIC_reset(). | |
| typedef u4_t | lmic_gpstime_t |
| how the network represents time. | |
| typedef struct lmic_radio_data_s | lmic_radio_data_t |
| Instance data for LMIC radio driver. | |
| typedef u1_t | lmic_radio_flags_t |
| container type for radio request flags | |
| typedef u1_t | lmic_radio_state_t |
| concrete type for holding the radio state mask. | |
| typedef void LMIC_ABI_STD | lmic_request_network_time_cb_t(void *pUserData, int flagSuccess) |
| network time request callback function type | |
| typedef int | lmic_tx_error_t |
| LMIC result codes, as an integer type. | |
| typedef union lmic_class_c_flags_u | lmic_class_c_flags_t |
| internal state flacs for class C operation | |
| typedef union lmic_class_c_requests_u | lmic_class_c_requests_t |
| requests from outside the LMIC to inside the LMIC, for class C | |
| typedef struct lmic_class_c_s | lmic_class_c_t |
| the structure containing class C state | |
Functions | |
| bit_t | LMIC_disableChannel (u1_t channel) |
| disable a channel. | |
| bit_t | LMIC_disableSubBand (u1_t band) |
| disable the eight 125 kHz channels and one 500 kHz channel of a sub-band (fixed-channel regions). | |
| bit_t | LMIC_enableChannel (u1_t channel) |
| enable a channel. | |
| bit_t | LMIC_enableSubBand (u1_t band) |
| enable the eight 125 kHz channels and one 500 kHz channel of a sub-band (fixed-channel regions). | |
| u1_t | LMIC_getBatteryLevel (void) |
| get battery level that is to be returned by DevStatusAns. | |
| bit_t | LMIC_queryChannel (u1_t channel, lmic_channel_info_t *pInfo) |
| describe a channel. | |
| u1_t | LMIC_queryChannelCount (void) |
| return the number of channel indices in the active region (16, 72 or 96). | |
| u1_t | LMIC_queryNumDefaultChannels (void) |
| get the number of (fixed) default channels before the programmable channels. | |
| bit_t | LMIC_queryTxReady (void) |
| check whether the LMIC is ready for a transmit packet | |
| bit_t | LMIC_selectSubBand (u1_t band) |
| enable one sub-band and disable all others (fixed-channel regions). | |
| u1_t | LMIC_setBatteryLevel (u1_t) |
| set battery level to be returned by DevStatusAns. | |
| void | LMIC_setSession (u4_t netid, devaddr_t devaddr, xref2u1_t nwkKey, xref2u1_t artKey) |
| Set up keys for ABP. | |
| bit_t | LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t group) |
| define or redefine a channel (configurable-channel regions). | |
| bit_t | LMIC_setupChannelGroup (u1_t group, s1_t txpow, u2_t txcap) |
| set the duty-cycle limit and maximum power of a channel group (configurable-channel regions). | |
LMIC API.
| #define LMIC_ERROR_NAME_MULTISZ__INIT |
Macro to initialize a compressed string of error name strings.
If compling for an AVR (or worried about it), you can use this multi-zero string and put this in a single const F() string. Index through this counting up from 0, until you get to the entry you want or to an entry that begins with a \0.
| #define LMIC_EVENT_NAME_MULTISZ__INIT |
Macro to initialize a compressed string of event strings.
iIf compiling for an AVR (or worried about it), you can use this multi-zero string and put this in a single const F() string. Index through this counting up from 0, until you get to the entry you want or to an
| typedef s1_t lmic_beacon_error_t |
Error codes returned for beacon operations.
| typedef union lmic_class_c_flags_u lmic_class_c_flags_t |
internal state flacs for class C operation
| typedef union lmic_class_c_requests_u lmic_class_c_requests_t |
requests from outside the LMIC to inside the LMIC, for class C
Enabling and disabling Class C operation can happen from outside the LMIC, or as the result of processing a callback. It's very fragile to require users to understand the LMIC state, so (at least for Class C), we provide APIs that are safe to call at any time. The tradeoff is that the operation is asynchronous – it doesn't complete until the LMIC gets scheduled. An object of this type is used to represent these requests.
| typedef struct lmic_class_c_s lmic_class_c_t |
the structure containing class C state
State for class C operations are incapsulated in a single object, so that conditional compiles are easier to read.
| typedef struct lmic_client_data_s lmic_client_data_t |
abstract type for collection of client data that survives LMIC_reset().
There are a variety of client registration linkage items that must live through LMIC_reset(), because LMIC_reset() is called at frame-rollover time. We group them together into a structure to make copies easy.
| typedef struct lmic_radio_data_s lmic_radio_data_t |
Instance data for LMIC radio driver.
Eventually this will be used for all portable things for the radio driver, but for now it's where we can start to add things.
| typedef u1_t lmic_radio_flags_t |
container type for radio request flags
| typedef u1_t lmic_radio_state_t |
concrete type for holding the radio state mask.
container type for radio driver state mask
Must be wide enough to hold values of type lmic_radio_state_e.
| typedef void LMIC_ABI_STD lmic_request_network_time_cb_t(void *pUserData, int flagSuccess) |
network time request callback function type
| pUserData | [in] value passed to corresponding network time request. |
| flagSuccess | [in] true if a network time was received, otherwise false. |
A function of this type is called when a time-request succeeds or when we get a downlink without time request, "completing" the pending time request.
| typedef int lmic_tx_error_t |
LMIC result codes, as an integer type.
| anonymous enum |
| anonymous enum |
| anonymous enum |
| anonymous enum |
| anonymous enum |
| enum lmic_beacon_error_e |
Error codes returned for beacon operations.
the bandwidth of a channel, as reported by LMIC_queryChannel().
| Enumerator | |
|---|---|
| LMIC_CHANNEL_BW_BY_DATARATE | varies with the data rate; see |
| enum lmic_radio_flags_e |
| enum lmic_radio_state_e |
radio driver state mask
| enum lmic_tx_error_e |
LMIC error codes.
| bit_t LMIC_disableChannel | ( | u1_t | channel | ) |
disable a channel.
channel was valid (and, in fixed-channel regions, was enabled before the call). References LMIC_disableChannel().
Referenced by LMIC_disableChannel().
| bit_t LMIC_enableChannel | ( | u1_t | channel | ) |
enable a channel.
channel was valid (and, in fixed-channel regions, was disabled before the call). References LMIC_enableChannel().
Referenced by LMIC_enableChannel().
| u1_t LMIC_getBatteryLevel | ( | void | ) |
get battery level that is to be returned by DevStatusAns.
References LMIC_getBatteryLevel().
Referenced by LMIC_getBatteryLevel(), and LMIC_queryChannel().
| bit_t LMIC_queryChannel | ( | u1_t | channel, |
| lmic_channel_info_t * | pInfo ) |
describe a channel.
| channel | channel index, 0..LMIC_queryChannelCount()-1. |
| pInfo | receives the description. |
channel is a valid index for the active region; zero otherwise, and *pInfo is not changed. References LMIC_getBatteryLevel(), LMIC_queryChannel(), LMIC_queryTxReady(), LMIC_setBatteryLevel(), and LMIC_setSession().
Referenced by LMIC_queryChannel().
| u1_t LMIC_queryNumDefaultChannels | ( | void | ) |
get the number of (fixed) default channels before the programmable channels.
query number of default channels.
get the number of (fixed) default channels before the programmable channels.
References LMIC_queryNumDefaultChannels().
Referenced by LMIC_queryNumDefaultChannels(), and LMIC_selectSubBand().
| u1_t LMIC_setBatteryLevel | ( | u1_t | uBattLevel | ) |
set battery level to be returned by DevStatusAns.
| uBattLevel | is the 8-bit value to be returned. Per LoRaWAN 1.0.3 line 769, this is MCMD_DEVS_EXT_POWER (0) if on external power, MCMD_DEVS_NOINFO (255) if not able to measure battery level, or a value in [ MCMD_DEVS_BATT_MIN, MCMD_DEVS_BATT_MAX ], numerically [1, 254], to represent the charge state of the battery. Note that this is not millivolts. |
The LMIC maintains an idea of the current battery state, initially set to MCMD_DEVS_NOINFO after the call to LMIC_init(). The appplication then calls this function from time to time to update the battery level.
It is possible (in non-Arduino environments) to supply a local implementation of os_getBatteryLevel(). In that case, it's up to the implementation to decide whether to use the value supplied by this API.
This implementation was chosen to minimize the risk of a battery measurement introducting breaking delays into the LMIC.
References LMIC_setBatteryLevel().
Referenced by LMIC_queryChannel(), and LMIC_setBatteryLevel().
| void LMIC_setSession | ( | u4_t | netid, |
| devaddr_t | devaddr, | ||
| xref2u1_t | nwkKey, | ||
| xref2u1_t | artKey ) |
Set up keys for ABP.
The LMIC stores the given session keys and put thes MAC in a state as if a join request/accept had just negotiated these keys.
| netid | a 24-bit number describing the network id this device is using |
| devaddr | the 32-bit session address of the device. It is strongly recommended to ensure that different devices use different numbers with high probability. |
| nwkKey | the 16-byte network session key used for message integrity. If NULL the caller has copied the key into LMIC.nwkKey before. |
| artKey | the 16-byte application router session key used for message confidentiality. If NULL the caller has copied the key into LMIC.artKey before. |
References LMIC_SecureElement_Aes128Key_s::bytes, LMIC_SecureElement_KeySelector_Unicast, LMIC_setSession(), OP_JOINING, OP_NEXTCHNL, OP_PINGINI, OP_REJOIN, OP_TRACK, OP_TXRXPEND, OP_UNJOIN, and os_copyMem.
Referenced by LMIC_queryChannel(), and LMIC_setSession().
| bit_t LMIC_setupChannel | ( | u1_t | chidx, |
| u4_t | freq, | ||
| u2_t | drmap, | ||
| s1_t | band ) |
define or redefine a channel (configurable-channel regions).
LMIC_setupChannel for EU 868.
| channel | channel index, from LMIC_queryNumDefaultChannels() to MAX_CHANNELS-1. Default channels cannot be changed. |
| freq | uplink frequency in Hz; zero disables the channel. |
| drmap | bit i set if data rate i is allowed; zero means the region default. |
| group | channel group index, or -1 to choose the group from the frequency. |
define or redefine a channel (configurable-channel regions).
NUM_DEFAULT_CHANNELS. This routine is used internally for MAC commands, so we enforce this for the extenal API as well. References DR_RANGE_MAP, and LMIC_setupChannel().
Referenced by LMIC_setupChannel().
| bit_t LMIC_setupChannelGroup | ( | u1_t | group, |
| s1_t | txpow, | ||
| u2_t | txcap ) |
set the duty-cycle limit and maximum power of a channel group (configurable-channel regions).
A channel group is the set of channels that share one regulatory duty-cycle limit and power limit; a channel belongs to a group by its frequency.
| group | channel group index, 0..MAX_BANDS-1. |
| txpow | maximum transmit power for the group, dBm. |
| txcap | duty-cycle divisor: the group may be used 1/txcap of the time. |
group names a group in this region. Fixed-channel regions have no groups and return non-zero without doing anything. References LMIC_setupChannelGroup().
Referenced by LMIC_setupChannelGroup().