mirror of
https://github.com/manuelbl/ttn-esp32.git
synced 2025-07-17 16:12:52 +02:00
Integrate development version of 3.0.99
This commit is contained in:
357
src/lmic/lmic.h
357
src/lmic/lmic.h
@ -103,9 +103,9 @@ extern "C"{
|
||||
|
||||
// Arduino LMIC version
|
||||
#define ARDUINO_LMIC_VERSION_CALC(major, minor, patch, local) \
|
||||
(((major) << 24u) | ((minor) << 16u) | ((patch) << 8u) | (local))
|
||||
(((major) << 24ul) | ((minor) << 16ul) | ((patch) << 8ul) | ((local) << 0ul))
|
||||
|
||||
#define ARDUINO_LMIC_VERSION ARDUINO_LMIC_VERSION_CALC(2, 3, 2, 0) /* v2.3.2 */
|
||||
#define ARDUINO_LMIC_VERSION ARDUINO_LMIC_VERSION_CALC(3, 0, 99, 5) /* v3.0.99.5 */
|
||||
|
||||
#define ARDUINO_LMIC_VERSION_GET_MAJOR(v) \
|
||||
(((v) >> 24u) & 0xFFu)
|
||||
@ -122,14 +122,19 @@ extern "C"{
|
||||
//! Only For Antenna Tuning Tests !
|
||||
//#define CFG_TxContinuousMode 1
|
||||
|
||||
enum { MAX_FRAME_LEN = 64 }; //!< Library cap on max frame length
|
||||
// since this was annouunced as the API variable, we keep it. But it's not used,
|
||||
// MAX_LEN_FRAME is what the code uses.
|
||||
enum { MAX_FRAME_LEN = MAX_LEN_FRAME }; //!< Library cap on max frame length
|
||||
|
||||
enum { TXCONF_ATTEMPTS = 8 }; //!< Transmit attempts for confirmed frames
|
||||
enum { MAX_MISSED_BCNS = 20 }; // threshold for triggering rejoin requests
|
||||
enum { MAX_RXSYMS = 100 }; // stop tracking beacon beyond this
|
||||
|
||||
enum { LINK_CHECK_CONT = 12 , // continue with this after reported dead link
|
||||
LINK_CHECK_DEAD = 24 , // after this UP frames and no response from NWK assume link is dead
|
||||
LINK_CHECK_INIT = -12 , // UP frame count until we inc datarate
|
||||
enum { LINK_CHECK_CONT = 0 , // continue with this after reported dead link
|
||||
LINK_CHECK_DEAD = 32 , // after this UP frames and no response to ack from NWK assume link is dead (ADR_ACK_DELAY)
|
||||
LINK_CHECK_UNJOIN_MIN = LINK_CHECK_DEAD + 4, // this is the minimum value of LINK_CHECK_UNJOIN if we parameterize
|
||||
LINK_CHECK_UNJOIN = LINK_CHECK_DEAD + (3 * 240), // after this many UP frames and no response, switch to join (by default)
|
||||
LINK_CHECK_INIT = -64 , // UP frame count until we ask for ack (ADR_ACK_LIMIT)
|
||||
LINK_CHECK_OFF =-128 }; // link check disabled
|
||||
|
||||
enum { TIME_RESYNC = 6*128 }; // secs
|
||||
@ -153,14 +158,27 @@ struct band_t {
|
||||
};
|
||||
TYPEDEF_xref2band_t; //!< \internal
|
||||
|
||||
struct lmic_saved_adr_state_s {
|
||||
u4_t channelFreq[MAX_CHANNELS];
|
||||
u2_t channelMap;
|
||||
};
|
||||
|
||||
#elif CFG_LMIC_US_like // US915 spectrum =================================================
|
||||
|
||||
enum { MAX_XCHANNELS = 2 }; // extra channels in RAM, channels 0-71 are immutable
|
||||
|
||||
struct lmic_saved_adr_state_s {
|
||||
u2_t channelMap[(72+MAX_XCHANNELS+15)/16]; // enabled bits
|
||||
u2_t activeChannels125khz;
|
||||
u2_t activeChannels500khz;
|
||||
};
|
||||
|
||||
#endif // ==========================================================================
|
||||
|
||||
typedef struct lmic_saved_adr_state_s lmic_saved_adr_state_t;
|
||||
|
||||
// Keep in sync with evdefs.hpp::drChange
|
||||
enum { DRCHG_SET, DRCHG_NOJACC, DRCHG_NOACK, DRCHG_NOADRACK, DRCHG_NWKCMD };
|
||||
enum { DRCHG_SET, DRCHG_NOJACC, DRCHG_NOACK, DRCHG_NOADRACK, DRCHG_NWKCMD, DRCHG_FRAMESIZE };
|
||||
enum { KEEP_TXPOW = -128 };
|
||||
|
||||
|
||||
@ -189,14 +207,14 @@ enum { BCN_NONE = 0x00, //!< No beacon received
|
||||
//! Information about the last and previous beacons.
|
||||
struct bcninfo_t {
|
||||
ostime_t txtime; //!< Time when the beacon was sent
|
||||
u4_t time; //!< GPS time in seconds of last beacon (received or surrogate)
|
||||
s4_t lat; //!< Lat field of last beacon (valid only if BCN_FULL set)
|
||||
s4_t lon; //!< Lon field of last beacon (valid only if BCN_FULL set)
|
||||
s1_t rssi; //!< Adjusted RSSI value of last received beacon
|
||||
s1_t snr; //!< Scaled SNR value of last received beacon
|
||||
u1_t flags; //!< Last beacon reception and tracking states. See BCN_* values.
|
||||
u4_t time; //!< GPS time in seconds of last beacon (received or surrogate)
|
||||
//
|
||||
u1_t info; //!< Info field of last beacon (valid only if BCN_FULL set)
|
||||
s4_t lat; //!< Lat field of last beacon (valid only if BCN_FULL set)
|
||||
s4_t lon; //!< Lon field of last beacon (valid only if BCN_FULL set)
|
||||
};
|
||||
#endif // !DISABLE_BEACONS
|
||||
|
||||
@ -220,29 +238,99 @@ enum { OP_NONE = 0x0000,
|
||||
OP_NEXTCHNL = 0x0800, // find a new channel
|
||||
OP_LINKDEAD = 0x1000, // link was reported as dead
|
||||
OP_TESTMODE = 0x2000, // developer test mode
|
||||
OP_UNJOIN = 0x4000, // unjoin and rejoin on next engineUpdate().
|
||||
};
|
||||
// TX-RX transaction flags - report back to user
|
||||
enum { TXRX_ACK = 0x80, // confirmed UP frame was acked
|
||||
TXRX_NACK = 0x40, // confirmed UP frame was not acked
|
||||
TXRX_NOPORT = 0x20, // set if a frame with a port was RXed, clr if no frame/no port
|
||||
TXRX_PORT = 0x10, // set if a frame with a port was RXed, LMIC.frame[LMIC.dataBeg-1] => port
|
||||
TXRX_DNW1 = 0x01, // received in 1st DN slot
|
||||
TXRX_LENERR = 0x08, // set if frame was discarded due to length error.
|
||||
TXRX_PING = 0x04, // received in a scheduled RX slot
|
||||
TXRX_DNW2 = 0x02, // received in 2dn DN slot
|
||||
TXRX_PING = 0x04 }; // received in a scheduled RX slot
|
||||
TXRX_DNW1 = 0x01, // received in 1st DN slot
|
||||
};
|
||||
|
||||
// Event types for event callback
|
||||
enum _ev_t { EV_SCAN_TIMEOUT=1, EV_BEACON_FOUND,
|
||||
EV_BEACON_MISSED, EV_BEACON_TRACKED, EV_JOINING,
|
||||
EV_JOINED, EV_RFU1, EV_JOIN_FAILED, EV_REJOIN_FAILED,
|
||||
EV_TXCOMPLETE, EV_LOST_TSYNC, EV_RESET,
|
||||
EV_RXCOMPLETE, EV_LINK_DEAD, EV_LINK_ALIVE, EV_SCAN_FOUND,
|
||||
EV_TXSTART };
|
||||
EV_TXSTART, EV_TXCANCELED, EV_RXSTART, EV_JOIN_TXCOMPLETE };
|
||||
typedef enum _ev_t ev_t;
|
||||
|
||||
// this macro can be used to initalize a normal table of event strings
|
||||
#define LMIC_EVENT_NAME_TABLE__INIT \
|
||||
"<<zero>>", \
|
||||
"EV_SCAN_TIMEOUT", "EV_BEACON_FOUND", \
|
||||
"EV_BEACON_MISSED", "EV_BEACON_TRACKED", "EV_JOINING", \
|
||||
"EV_JOINED", "EV_RFU1", "EV_JOIN_FAILED", "EV_REJOIN_FAILED", \
|
||||
"EV_TXCOMPLETE", "EV_LOST_TSYNC", "EV_RESET", \
|
||||
"EV_RXCOMPLETE", "EV_LINK_DEAD", "EV_LINK_ALIVE", "EV_SCAN_FOUND", \
|
||||
"EV_TXSTART", "EV_TXCANCELED", "EV_RXSTART", "EV_JOIN_TXCOMPLETE"
|
||||
|
||||
// if working on 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 \
|
||||
"<<zero>>\0" \
|
||||
"EV_SCAN_TIMEOUT\0" "EV_BEACON_FOUND\0" \
|
||||
"EV_BEACON_MISSED\0" "EV_BEACON_TRACKED\0" "EV_JOINING\0" \
|
||||
"EV_JOINED\0" "EV_RFU1\0" "EV_JOIN_FAILED\0" "EV_REJOIN_FAILED\0" \
|
||||
"EV_TXCOMPLETE\0" "EV_LOST_TSYNC\0" "EV_RESET\0" \
|
||||
"EV_RXCOMPLETE\0" "EV_LINK_DEAD\0" "EV_LINK_ALIVE\0" "EV_SCAN_FOUND\0" \
|
||||
"EV_TXSTART\0" "EV_TXCANCELED\0" "EV_RXSTART\0" "EV_JOIN_TXCOMPLETE\0"
|
||||
|
||||
enum {
|
||||
LMIC_ERROR_SUCCESS = 0,
|
||||
LMIC_ERROR_TX_BUSY = -1,
|
||||
LMIC_ERROR_TX_TOO_LARGE = -2,
|
||||
LMIC_ERROR_TX_NOT_FEASIBLE = -3,
|
||||
LMIC_ERROR_TX_FAILED = -4,
|
||||
};
|
||||
|
||||
typedef int lmic_tx_error_t;
|
||||
|
||||
#define LMIC_ERROR_NAME__INIT \
|
||||
"LMIC_ERROR_SUCCESS", \
|
||||
"LMIC_ERROR_TX_BUSY", \
|
||||
"LMIC_ERROR_TX_TOO_LARGE", \
|
||||
"LMIC_ERROR_TX_NOT_FEASIBLE", \
|
||||
"LMIC_ERROR_TX_FAILED"
|
||||
|
||||
#define LMIC_ERROR_NAME_MULTISZ__INIT \
|
||||
"LMIC_ERROR_SUCCESS\0" \
|
||||
"LMIC_ERROR_TX_BUSY\0" \
|
||||
"LMIC_ERROR_TX_TOO_LARGE\0" \
|
||||
"LMIC_ERROR_TX_NOT_FEASIBLE\0" \
|
||||
"LMIC_ERROR_TX_FAILED"
|
||||
|
||||
enum {
|
||||
LMIC_BEACON_ERROR_INVALID = -2,
|
||||
LMIC_BEACON_ERROR_WRONG_NETWORK = -1,
|
||||
LMIC_BEACON_ERROR_SUCCESS_PARTIAL = 0,
|
||||
LMIC_BEACON_ERROR_SUCCESS_FULL = 1,
|
||||
};
|
||||
|
||||
typedef s1_t lmic_beacon_error_t;
|
||||
|
||||
static inline bit_t LMIC_BEACON_SUCCESSFUL(lmic_beacon_error_t e) {
|
||||
return e < 0;
|
||||
}
|
||||
|
||||
enum {
|
||||
// This value represents 100% error in LMIC.clockError
|
||||
MAX_CLOCK_ERROR = 65536,
|
||||
};
|
||||
|
||||
// callbacks for client alerts.
|
||||
// types and functions are always defined, to reduce #ifs in example code and libraries.
|
||||
typedef void LMIC_ABI_STD lmic_rxmessage_cb_t(void *pUserData, uint8_t port, const uint8_t *pMessage, size_t nMessage);
|
||||
typedef void LMIC_ABI_STD lmic_txmessage_cb_t(void *pUserData, int fSuccess);
|
||||
typedef void LMIC_ABI_STD lmic_event_cb_t(void *pUserData, ev_t e);
|
||||
|
||||
// network time request callback function
|
||||
// defined unconditionally, because APIs and types can't change based on config.
|
||||
// This is called when a time-request succeeds or when we get a downlink
|
||||
@ -272,29 +360,123 @@ enum lmic_request_time_state_e {
|
||||
|
||||
typedef u1_t lmic_request_time_state_t;
|
||||
|
||||
enum lmic_engine_update_state_e {
|
||||
lmic_EngineUpdateState_idle = 0, // engineUpdate is idle.
|
||||
lmic_EngineUpdateState_busy = 1, // engineUpdate is busy, but has not been reentered.
|
||||
lmic_EngineUpdateState_again = 2, // engineUpdate is busy, and has to be evaluated again.
|
||||
};
|
||||
|
||||
typedef u1_t lmic_engine_update_state_t;
|
||||
|
||||
/*
|
||||
|
||||
Structure: lmic_client_data_t
|
||||
|
||||
Function:
|
||||
Holds LMIC client data that must live through LMIC_reset().
|
||||
|
||||
Description:
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
//! abstract type for collection of client data that survives LMIC_reset().
|
||||
typedef struct lmic_client_data_s lmic_client_data_t;
|
||||
|
||||
//! contents of lmic_client_data_t
|
||||
struct lmic_client_data_s {
|
||||
|
||||
/* pointer-width things come first */
|
||||
#if LMIC_ENABLE_DeviceTimeReq
|
||||
lmic_request_network_time_cb_t *pNetworkTimeCb; //! call-back routine for network time
|
||||
void *pNetworkTimeUserData; //! call-back data for network time.
|
||||
#endif
|
||||
|
||||
#if LMIC_ENABLE_user_events
|
||||
lmic_event_cb_t *eventCb; //! user-supplied callback function for events.
|
||||
void *eventUserData; //! data for eventCb
|
||||
lmic_rxmessage_cb_t *rxMessageCb; //! user-supplied message-received callback
|
||||
void *rxMessageUserData; //! data for rxMessageCb
|
||||
lmic_txmessage_cb_t *txMessageCb; //! transmit-complete message handler; reset on each tx complete.
|
||||
void *txMessageUserData; //! data for txMessageCb.
|
||||
#endif // LMIC_ENABLE_user_events
|
||||
|
||||
/* next we have things that are (u)int32_t */
|
||||
/* none at the moment */
|
||||
|
||||
/* next we have things that are (u)int16_t */
|
||||
|
||||
u2_t clockError; //! Inaccuracy in the clock. CLOCK_ERROR_MAX represents +/-100% error
|
||||
|
||||
/* finally, things that are (u)int8_t */
|
||||
/* none at the moment */
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Structure: lmic_t
|
||||
|
||||
Function:
|
||||
Provides the instance data for the LMIC.
|
||||
|
||||
*/
|
||||
|
||||
struct lmic_t {
|
||||
// client setup data, survives LMIC_reset().
|
||||
lmic_client_data_t client;
|
||||
|
||||
// the OS job object. pointer alignment.
|
||||
osjob_t osjob;
|
||||
|
||||
#if !defined(DISABLE_BEACONS)
|
||||
bcninfo_t bcninfo; // Last received beacon info
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_PING)
|
||||
rxsched_t ping; // pingable setup
|
||||
#endif
|
||||
|
||||
/* (u)int32_t things */
|
||||
|
||||
// Radio settings TX/RX (also accessed by HAL)
|
||||
ostime_t txend;
|
||||
ostime_t rxtime;
|
||||
|
||||
// LBT info
|
||||
ostime_t lbt_ticks; // ticks to listen
|
||||
s1_t lbt_dbmax; // max permissible dB on our channel (eg -80)
|
||||
|
||||
u4_t freq;
|
||||
s1_t rssi;
|
||||
s1_t snr; // LMIC.snr is SNR times 4
|
||||
rps_t rps;
|
||||
u1_t rxsyms;
|
||||
u1_t dndr;
|
||||
s1_t txpow; // dBm
|
||||
|
||||
osjob_t osjob;
|
||||
ostime_t globalDutyAvail; // time device can send again
|
||||
|
||||
// Channel scheduling
|
||||
u4_t netid; // current network id (~0 - none)
|
||||
devaddr_t devaddr;
|
||||
u4_t seqnoDn; // device level down stream seqno
|
||||
u4_t seqnoUp;
|
||||
u4_t dn2Freq;
|
||||
|
||||
#if !defined(DISABLE_BEACONS)
|
||||
ostime_t bcnRxtime;
|
||||
#endif
|
||||
|
||||
#if LMIC_ENABLE_DeviceTimeReq
|
||||
// put here for alignment, to reduce RAM use.
|
||||
ostime_t localDeviceTime; // the LMIC.txend value for last DeviceTimeAns
|
||||
lmic_gpstime_t netDeviceTime; // the netDeviceTime for lastDeviceTimeAns
|
||||
// zero ==> not valid.
|
||||
#endif // LMIC_ENABLE_DeviceTimeReq
|
||||
|
||||
// Channel scheduling -- very much private
|
||||
#if CFG_LMIC_EU_like
|
||||
band_t bands[MAX_BANDS];
|
||||
u4_t channelFreq[MAX_CHANNELS];
|
||||
#if !defined(DISABLE_MCMD_DlChannelReq)
|
||||
u4_t channelDlFreq[MAX_CHANNELS];
|
||||
#endif
|
||||
// bit map of enabled datarates for each channel
|
||||
u2_t channelDrMap[MAX_CHANNELS];
|
||||
u2_t channelMap;
|
||||
#elif CFG_LMIC_US_like
|
||||
@ -304,66 +486,70 @@ struct lmic_t {
|
||||
u2_t activeChannels125khz;
|
||||
u2_t activeChannels500khz;
|
||||
#endif
|
||||
|
||||
/* (u)int16_t things */
|
||||
rps_t rps; // radio parameter selections: SF, BW, CodingRate, NoCrc, implicit hdr
|
||||
u2_t opmode; // engineUpdate() operating mode flags
|
||||
u2_t devNonce; // last generated nonce
|
||||
|
||||
s2_t adrAckReq; // counter for link integrity tracking (LINK_CHECK_OFF=off)
|
||||
|
||||
#if !defined(DISABLE_BEACONS)
|
||||
s2_t drift; // last measured drift
|
||||
s2_t lastDriftDiff;
|
||||
s2_t maxDriftDiff;
|
||||
#endif
|
||||
|
||||
/* (u)int8_t things */
|
||||
lmic_engine_update_state_t engineUpdateState; // state of the engineUpdate() evaluator.
|
||||
s1_t rssi;
|
||||
s1_t snr; // LMIC.snr is SNR times 4
|
||||
u1_t rxsyms;
|
||||
u1_t dndr;
|
||||
s1_t txpow; // transmit dBm (administrative)
|
||||
s1_t radio_txpow; // the radio driver's copy of txpow, in dB limited by adrTxPow, and
|
||||
// also adjusted for EIRP/antenna gain considerations.
|
||||
// This is just the radio's idea of power. So if you are
|
||||
// controlling EIRP, and you have 3 dB antenna gain, this
|
||||
// needs to reduced by 3 dB.
|
||||
s1_t lbt_dbmax; // max permissible dB on our channel (eg -80)
|
||||
|
||||
u1_t txChnl; // channel for next TX
|
||||
u1_t globalDutyRate; // max rate: 1/2^k
|
||||
ostime_t globalDutyAvail; // time device can send again
|
||||
|
||||
u4_t netid; // current network id (~0 - none)
|
||||
u2_t opmode;
|
||||
u1_t upRepeat; // configured up repeat
|
||||
s1_t adrTxPow; // ADR adjusted TX power
|
||||
u1_t datarate; // current data rate
|
||||
u1_t errcr; // error coding rate (used for TX only)
|
||||
u1_t rejoinCnt; // adjustment for rejoin datarate
|
||||
#if !defined(DISABLE_BEACONS)
|
||||
s2_t drift; // last measured drift
|
||||
s2_t lastDriftDiff;
|
||||
s2_t maxDriftDiff;
|
||||
#endif
|
||||
|
||||
u2_t clockError; // Inaccuracy in the clock. CLOCK_ERROR_MAX
|
||||
// represents +/-100% error
|
||||
u1_t upRepeatCount; // current up-repeat
|
||||
bit_t initBandplanAfterReset; // cleared by LMIC_reset(), set by first join. See issue #244
|
||||
|
||||
u1_t pendTxPort;
|
||||
u1_t pendTxConf; // confirmed data
|
||||
u1_t pendTxLen; // +0x80 = confirmed
|
||||
u1_t pendTxLen; // count of bytes in pendTxData.
|
||||
u1_t pendTxData[MAX_LEN_PAYLOAD];
|
||||
|
||||
u2_t devNonce; // last generated nonce
|
||||
u1_t pendMacLen; // number of bytes of pending Mac response data
|
||||
bit_t pendMacPiggyback; // received on port 0 or piggyback?
|
||||
// response data if piggybacked
|
||||
u1_t pendMacData[LWAN_FCtrl_FOptsLen_MAX];
|
||||
|
||||
u1_t nwkKey[16]; // network session key
|
||||
u1_t artKey[16]; // application router session key
|
||||
devaddr_t devaddr;
|
||||
u4_t seqnoDn; // device level down stream seqno
|
||||
u4_t seqnoUp;
|
||||
#if LMIC_ENABLE_DeviceTimeReq
|
||||
// put here for alignment, to reduce RAM use.
|
||||
ostime_t localDeviceTime; // the LMIC.txend value for last DeviceTimeAns
|
||||
lmic_gpstime_t netDeviceTime; // the netDeviceTime for lastDeviceTimeAns
|
||||
// zero ==> not valid.
|
||||
lmic_request_network_time_cb_t *pNetworkTimeCb; // call-back routine
|
||||
void *pNetworkTimeUserData; // call-back data
|
||||
#endif // LMIC_ENABLE_DeviceTimeReq
|
||||
|
||||
u1_t dnConf; // dn frame confirm pending: LORA::FCT_ACK or 0
|
||||
s1_t adrAckReq; // counter until we reset data rate (0=off)
|
||||
u1_t lastDnConf; // downlink with seqnoDn-1 requested confirmation
|
||||
u1_t adrChanged;
|
||||
|
||||
u1_t rxDelay; // Rx delay after TX
|
||||
|
||||
u1_t margin;
|
||||
bit_t ladrAns; // link adr adapt answer pending
|
||||
bit_t devsAns; // device status answer pending
|
||||
s1_t devAnsMargin; // SNR value between -32 and 31 (inclusive) for the last successfully received DevStatusReq command
|
||||
u1_t adrEnabled;
|
||||
u1_t moreData; // NWK has more data pending
|
||||
#if !defined(DISABLE_MCMD_DCAP_REQ)
|
||||
bit_t dutyCapAns; // have to ACK duty cycle settings
|
||||
#endif
|
||||
#if !defined(DISABLE_MCMD_SNCH_REQ)
|
||||
u1_t snchAns; // answer set new channel
|
||||
#endif
|
||||
#if LMIC_ENABLE_TxParamSetupReq
|
||||
bit_t txParamSetupAns; // transmit setup answer pending.
|
||||
u1_t txParam; // the saved TX param byte.
|
||||
#endif
|
||||
#if LMIC_ENABLE_DeviceTimeReq
|
||||
@ -376,23 +562,21 @@ struct lmic_t {
|
||||
|
||||
// 2nd RX window (after up stream)
|
||||
u1_t dn2Dr;
|
||||
u4_t dn2Freq;
|
||||
#if !defined(DISABLE_MCMD_DN2P_SET)
|
||||
#if !defined(DISABLE_MCMD_RXParamSetupReq)
|
||||
u1_t dn2Ans; // 0=no answer pend, 0x80+ACKs
|
||||
#endif
|
||||
#if !defined(DISABLE_MCMD_DlChannelReq)
|
||||
u1_t macDlChannelAns; // 0 ==> no answer pending, 0x80+ACK bits
|
||||
#endif
|
||||
#if !defined(DISABLE_MCMD_RXTimingSetupReq)
|
||||
bit_t macRxTimingSetupAns; // 0 ==> no answer pend, non-zero inserts response.
|
||||
#endif
|
||||
|
||||
// Class B state
|
||||
#if !defined(DISABLE_BEACONS)
|
||||
u1_t missedBcns; // unable to track last N beacons
|
||||
u1_t bcninfoTries; // how often to try (scan mode only)
|
||||
#endif
|
||||
#if !defined(DISABLE_MCMD_PING_SET) && !defined(DISABLE_PING)
|
||||
u1_t pingSetAns; // answer set cmd and ACK bits
|
||||
#endif
|
||||
#if !defined(DISABLE_PING)
|
||||
rxsched_t ping; // pingable setup
|
||||
#endif
|
||||
|
||||
// Public part of MAC state
|
||||
u1_t txCnt;
|
||||
u1_t txrxFlags; // transaction flags (TX-RX combo)
|
||||
@ -403,11 +587,10 @@ struct lmic_t {
|
||||
#if !defined(DISABLE_BEACONS)
|
||||
u1_t bcnChnl;
|
||||
u1_t bcnRxsyms; //
|
||||
ostime_t bcnRxtime;
|
||||
bcninfo_t bcninfo; // Last received beacon info
|
||||
#endif
|
||||
|
||||
u1_t noRXIQinversion;
|
||||
u1_t saveIrqFlags; // last LoRa IRQ flags
|
||||
};
|
||||
|
||||
//! \var struct lmic_t LMIC
|
||||
@ -418,16 +601,20 @@ DECLARE_LMIC; //!< \internal
|
||||
#define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
|
||||
bit_t LMIC_setupBand (u1_t bandidx, s1_t txpow, u2_t txcap);
|
||||
bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
|
||||
void LMIC_disableChannel (u1_t channel);
|
||||
void LMIC_enableSubBand(u1_t band);
|
||||
void LMIC_enableChannel(u1_t channel);
|
||||
void LMIC_disableSubBand(u1_t band);
|
||||
void LMIC_selectSubBand(u1_t band);
|
||||
bit_t LMIC_disableChannel (u1_t channel);
|
||||
bit_t LMIC_enableSubBand(u1_t band);
|
||||
bit_t LMIC_enableChannel(u1_t channel);
|
||||
bit_t LMIC_disableSubBand(u1_t band);
|
||||
bit_t LMIC_selectSubBand(u1_t band);
|
||||
|
||||
void LMIC_setDrTxpow (dr_t dr, s1_t txpow); // set default/start DR/txpow
|
||||
void LMIC_setAdrMode (bit_t enabled); // set ADR mode (if mobile turn off)
|
||||
|
||||
#if !defined(DISABLE_JOIN)
|
||||
bit_t LMIC_startJoining (void);
|
||||
void LMIC_tryRejoin (void);
|
||||
void LMIC_unjoin (void);
|
||||
void LMIC_unjoinAndRejoin (void);
|
||||
#endif
|
||||
|
||||
void LMIC_shutdown (void);
|
||||
@ -435,7 +622,11 @@ void LMIC_init (void);
|
||||
void LMIC_reset (void);
|
||||
void LMIC_clrTxData (void);
|
||||
void LMIC_setTxData (void);
|
||||
int LMIC_setTxData2 (u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed);
|
||||
void LMIC_setTxData_strict(void);
|
||||
lmic_tx_error_t LMIC_setTxData2(u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed);
|
||||
lmic_tx_error_t LMIC_setTxData2_strict(u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed);
|
||||
lmic_tx_error_t LMIC_sendWithCallback(u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed, lmic_txmessage_cb_t *pCb, void *pUserData);
|
||||
lmic_tx_error_t LMIC_sendWithCallback_strict(u1_t port, xref2u1_t data, u1_t dlen, u1_t confirmed, lmic_txmessage_cb_t *pCb, void *pUserData);
|
||||
void LMIC_sendAlive (void);
|
||||
|
||||
#if !defined(DISABLE_BEACONS)
|
||||
@ -447,9 +638,6 @@ void LMIC_disableTracking (void);
|
||||
void LMIC_stopPingable (void);
|
||||
void LMIC_setPingable (u1_t intvExp);
|
||||
#endif
|
||||
#if !defined(DISABLE_JOIN)
|
||||
void LMIC_tryRejoin (void);
|
||||
#endif
|
||||
|
||||
void LMIC_setSession (u4_t netid, devaddr_t devaddr, xref2u1_t nwkKey, xref2u1_t artKey);
|
||||
void LMIC_setLinkCheckMode (bit_t enabled);
|
||||
@ -462,11 +650,26 @@ void LMIC_getSessionKeys (u4_t *netid, devaddr_t *devaddr, xref2u1_t nwkKey, xre
|
||||
void LMIC_requestNetworkTime(lmic_request_network_time_cb_t *pCallbackfn, void *pUserData);
|
||||
int LMIC_getNetworkTimeReference(lmic_time_reference_t *pReference);
|
||||
|
||||
int LMIC_registerRxMessageCb(lmic_rxmessage_cb_t *pRxMessageCb, void *pUserData);
|
||||
int LMIC_registerEventCb(lmic_event_cb_t *pEventCb, void *pUserData);
|
||||
|
||||
// APIs for client half of compliance.
|
||||
typedef u1_t lmic_compliance_rx_action_t;
|
||||
|
||||
enum lmic_compliance_rx_action_e {
|
||||
LMIC_COMPLIANCE_RX_ACTION_PROCESS = 0, // process this message normally
|
||||
LMIC_COMPLIANCE_RX_ACTION_START, // enter compliance mode, discard this message
|
||||
LMIC_COMPLIANCE_RX_ACTION_IGNORE, // continue in compliance mode, discard this message
|
||||
LMIC_COMPLIANCE_RX_ACTION_END // exit compliance mode, discard this message
|
||||
};
|
||||
|
||||
lmic_compliance_rx_action_t LMIC_complianceRxMessage(u1_t port, const u1_t *pMessage, size_t nMessage);
|
||||
|
||||
// Declare onEvent() function, to make sure any definition will have the
|
||||
// C conventions, even when in a C++ file.
|
||||
#if LMIC_ENABLE_onEvent
|
||||
DECL_ON_LMIC_EVENT;
|
||||
|
||||
|
||||
#endif /* LMIC_ENABLE_onEvent */
|
||||
|
||||
// Special APIs - for development or testing
|
||||
// !!!See implementation for caveats!!!
|
||||
|
Reference in New Issue
Block a user