mirror of https://github.com/ARMmbed/mbed-os.git
[IOTCELL-282] Code cleanup/simplification and rules
Baseline is changed to use a single set of data structures that simplifies the code in the LoRaWANStack and Mac layer. We are now following certian rules for naming data structures. - All structures visible outside their domain are prefixed as 'lorawan_' - All mac structures are prefixed as 'loramac_' - All subsystem or module strucutures carry their name in prefix, like 'mcps_' PHY layer still have legacy camel case data structures which will be entertained later while we will be simplifying PHY layer. Test cases are also updated with the new data structure naming conventions. One major difference from the previous baseline is the removal of static buffer from mcps indication. And we do not copy data from stack buffer to rx_msg buffer. This saves at least 512 bytes. It may look like now that if we have received something but the user have not read from the buffer, then the buffer will be overwritten and we will lose previous frame. Yes, we will. But the same will happen even if we would have copied the buffer into rx_msg because then the rx_msg gets overwritten. So we decide to abandon copying the buffer at multiple locations. We inform the user about reception, if the user doesn't read and the data gets overwritten, then so be it.pull/6059/head
parent
6ea541c054
commit
c02774343a
|
@ -42,16 +42,16 @@ LoRaWANInterface::~LoRaWANInterface()
|
|||
{
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::initialize(EventQueue *queue)
|
||||
lorawan_status_t LoRaWANInterface::initialize(EventQueue *queue)
|
||||
{
|
||||
if(!queue) {
|
||||
return LORA_MAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
return stk_obj().initialize_mac_layer(queue);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::connect()
|
||||
lorawan_status_t LoRaWANInterface::connect()
|
||||
{
|
||||
// connection attempt without parameters.
|
||||
// System tries to look for configuration in mbed_lib.json that can be
|
||||
|
@ -96,28 +96,28 @@ lora_mac_status_t LoRaWANInterface::connect()
|
|||
}
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::connect(const lorawan_connect_t &connect)
|
||||
lorawan_status_t LoRaWANInterface::connect(const lorawan_connect_t &connect)
|
||||
{
|
||||
lora_mac_status_t mac_status;
|
||||
lorawan_status_t mac_status;
|
||||
|
||||
if (connect.connect_type == LORAWAN_CONNECTION_OTAA) {
|
||||
mac_status = stk_obj().join_request_by_otaa(connect);
|
||||
} else if (connect.connect_type == LORAWAN_CONNECTION_ABP) {
|
||||
mac_status = stk_obj().activation_by_personalization(connect);
|
||||
} else {
|
||||
return LORA_MAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
return mac_status;
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::disconnect()
|
||||
lorawan_status_t LoRaWANInterface::disconnect()
|
||||
{
|
||||
stk_obj().shutdown();
|
||||
return LORA_MAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::add_link_check_request()
|
||||
lorawan_status_t LoRaWANInterface::add_link_check_request()
|
||||
{
|
||||
_link_check_requested = true;
|
||||
return stk_obj().set_link_check_request();
|
||||
|
@ -128,42 +128,42 @@ void LoRaWANInterface::remove_link_check_request()
|
|||
_link_check_requested = false;
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::set_datarate(uint8_t data_rate)
|
||||
lorawan_status_t LoRaWANInterface::set_datarate(uint8_t data_rate)
|
||||
{
|
||||
return stk_obj().set_channel_data_rate(data_rate);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::set_confirmed_msg_retries(uint8_t count)
|
||||
lorawan_status_t LoRaWANInterface::set_confirmed_msg_retries(uint8_t count)
|
||||
{
|
||||
return stk_obj().set_confirmed_msg_retry(count);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::enable_adaptive_datarate()
|
||||
lorawan_status_t LoRaWANInterface::enable_adaptive_datarate()
|
||||
{
|
||||
return stk_obj().enable_adaptive_datarate(true);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::disable_adaptive_datarate()
|
||||
lorawan_status_t LoRaWANInterface::disable_adaptive_datarate()
|
||||
{
|
||||
return stk_obj().enable_adaptive_datarate(false);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::set_channel_plan(const lora_channelplan_t &channel_plan)
|
||||
lorawan_status_t LoRaWANInterface::set_channel_plan(const lorawan_channelplan_t &channel_plan)
|
||||
{
|
||||
return stk_obj().add_channels(channel_plan);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::get_channel_plan(lora_channelplan_t &channel_plan)
|
||||
lorawan_status_t LoRaWANInterface::get_channel_plan(lorawan_channelplan_t &channel_plan)
|
||||
{
|
||||
return stk_obj().get_enabled_channels(channel_plan);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::remove_channel(uint8_t id)
|
||||
lorawan_status_t LoRaWANInterface::remove_channel(uint8_t id)
|
||||
{
|
||||
return stk_obj().remove_a_channel(id);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::remove_channel_plan()
|
||||
lorawan_status_t LoRaWANInterface::remove_channel_plan()
|
||||
{
|
||||
return stk_obj().drop_channel_list();
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ int16_t LoRaWANInterface::send(uint8_t port, const uint8_t* data,
|
|||
if (data) {
|
||||
return stk_obj().handle_tx(port, data, length, flags);
|
||||
} else {
|
||||
return LORA_MAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,19 +190,18 @@ int16_t LoRaWANInterface::receive(uint8_t port, uint8_t* data, uint16_t length,
|
|||
if (data && length > 0) {
|
||||
return stk_obj().handle_rx(port, data, length, flags);
|
||||
} else {
|
||||
return LORA_MAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::add_app_callbacks(lorawan_app_callbacks_t *callbacks)
|
||||
lorawan_status_t LoRaWANInterface::add_app_callbacks(lorawan_app_callbacks_t *callbacks)
|
||||
{
|
||||
|
||||
if (!callbacks || !callbacks->events) {
|
||||
// Event Callback is mandatory
|
||||
return LORA_MAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
stk_obj().set_lora_callbacks(callbacks);
|
||||
|
||||
return LORA_MAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
*
|
||||
* @return 0 on success, a negative error code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t initialize(events::EventQueue *ev_queue) ;
|
||||
virtual lorawan_status_t initialize(events::EventQueue *ev_queue) ;
|
||||
|
||||
/** Connect OTAA or ABP using Mbed-OS config system
|
||||
*
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
* You need to configure the connection properly via the Mbed OS configuration
|
||||
* system.
|
||||
*
|
||||
* When connecting via OTAA, the return code for success (LORA_MAC_STATUS_CONNECT_IN_PROGRESS) is negative.
|
||||
* When connecting via OTAA, the return code for success (LORAWAN_STATUS_CONNECT_IN_PROGRESS) is negative.
|
||||
* However, this is not a real error. It tells you that the connection is in progress and you will
|
||||
* be notified of the completion via an event. By default, after the Join Accept message
|
||||
* is received, base stations may provide the node with a CF-List that replaces
|
||||
|
@ -78,17 +78,17 @@ public:
|
|||
* is important, at least for ABP. That's why we try to restore frame counters from
|
||||
* session information after a disconnection.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or LORA_MAC_STATUS_CONNECT_IN_PROGRESS
|
||||
* @return LORAWAN_STATUS_OK or LORAWAN_STATUS_CONNECT_IN_PROGRESS
|
||||
* on success, or a negative error code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t connect();
|
||||
virtual lorawan_status_t connect();
|
||||
|
||||
/** Connect OTAA or ABP with parameters
|
||||
*
|
||||
* All connection parameters are chosen by the user and provided in the
|
||||
* data structure passed down.
|
||||
*
|
||||
* When connecting via OTAA, the return code for success (LORA_MAC_STATUS_CONNECT_IN_PROGRESS) is negative.
|
||||
* When connecting via OTAA, the return code for success (LORAWAN_STATUS_CONNECT_IN_PROGRESS) is negative.
|
||||
* However, this is not a real error. It tells you that connection is in progress and you will
|
||||
* be notified of completion via an event. By default, after Join Accept message
|
||||
* is received, base stations may provide the node with a CF-List which replaces
|
||||
|
@ -118,17 +118,17 @@ public:
|
|||
*
|
||||
* @param connect Options for an end device connection to the gateway.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or LORA_MAC_STATUS_CONNECT_IN_PROGRESS,
|
||||
* @return LORAWAN_STATUS_OK or LORAWAN_STATUS_CONNECT_IN_PROGRESS,
|
||||
* a negative error code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t connect(const lorawan_connect_t &connect);
|
||||
virtual lorawan_status_t connect(const lorawan_connect_t &connect);
|
||||
|
||||
/** Disconnect the current session.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error code on
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error code on
|
||||
* failure.
|
||||
*/
|
||||
virtual lora_mac_status_t disconnect();
|
||||
virtual lorawan_status_t disconnect();
|
||||
|
||||
/** Validate the connectivity with the network.
|
||||
*
|
||||
|
@ -145,7 +145,7 @@ public:
|
|||
*
|
||||
* This API is usable only when the 'link_check_resp' callback is set by
|
||||
* the application. See add_lora_app_callbacks API. If the above mentioned
|
||||
* callback is not set, a LORA_MAC_STATUS_PARAMETER_INVALID error is thrown.
|
||||
* callback is not set, a LORAWAN_STATUS_PARAMETER_INVALID error is thrown.
|
||||
*
|
||||
* First parameter to callback function is the demodulation margin and
|
||||
* the second parameter is the number of gateways that successfully received
|
||||
|
@ -155,11 +155,11 @@ public:
|
|||
* transmission, until/unless application explicitly turns it off using
|
||||
* remove_link_check_request() API.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on successfully queuing a request, or
|
||||
* @return LORAWAN_STATUS_OK on successfully queuing a request, or
|
||||
* a negative error code on failure.
|
||||
*
|
||||
*/
|
||||
virtual lora_mac_status_t add_link_check_request();
|
||||
virtual lorawan_status_t add_link_check_request();
|
||||
|
||||
/** Removes link check request sticky MAC command.
|
||||
*
|
||||
|
@ -176,28 +176,28 @@ public:
|
|||
* @param data_rate The intended data rate, for example DR_0 or DR_1.
|
||||
* Please note, that the macro DR_* can mean different
|
||||
* things in different regions.
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well, otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well, otherwise
|
||||
* a negative error code.
|
||||
*/
|
||||
virtual lora_mac_status_t set_datarate(uint8_t data_rate);
|
||||
virtual lorawan_status_t set_datarate(uint8_t data_rate);
|
||||
|
||||
/** Enables adaptive data rate (ADR).
|
||||
*
|
||||
* The underlying LoRaPHY and LoRaMac layers handle the data rate automatically
|
||||
* for the user, based upon the radio conditions (network congestion).
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or negative error code otherwise.
|
||||
* @return LORAWAN_STATUS_OK or negative error code otherwise.
|
||||
*/
|
||||
virtual lora_mac_status_t enable_adaptive_datarate();
|
||||
virtual lorawan_status_t enable_adaptive_datarate();
|
||||
|
||||
/** Disables adaptive data rate.
|
||||
*
|
||||
* When adaptive data rate (ADR) is disabled, you can either set a certain
|
||||
* data rate or the MAC layer selects a default value.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or negative error code otherwise.
|
||||
* @return LORAWAN_STATUS_OK or negative error code otherwise.
|
||||
*/
|
||||
virtual lora_mac_status_t disable_adaptive_datarate();
|
||||
virtual lorawan_status_t disable_adaptive_datarate();
|
||||
|
||||
/** Sets up the retry counter for confirmed messages.
|
||||
*
|
||||
|
@ -212,9 +212,9 @@ public:
|
|||
*
|
||||
* @param count The number of retries for confirmed messages.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or a negative error code.
|
||||
* @return LORAWAN_STATUS_OK or a negative error code.
|
||||
*/
|
||||
virtual lora_mac_status_t set_confirmed_msg_retries(uint8_t count);
|
||||
virtual lorawan_status_t set_confirmed_msg_retries(uint8_t count);
|
||||
|
||||
/** Sets the channel plan.
|
||||
*
|
||||
|
@ -240,10 +240,10 @@ public:
|
|||
*
|
||||
* @param channel_plan The channel plan to set.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t set_channel_plan(const lora_channelplan_t &channel_plan);
|
||||
virtual lorawan_status_t set_channel_plan(const lorawan_channelplan_t &channel_plan);
|
||||
|
||||
/** Gets the channel plans from the LoRa stack.
|
||||
*
|
||||
|
@ -254,20 +254,20 @@ public:
|
|||
*
|
||||
* @param channel_plan The current channel plan information.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t get_channel_plan(lora_channelplan_t &channel_plan);
|
||||
virtual lorawan_status_t get_channel_plan(lorawan_channelplan_t &channel_plan);
|
||||
|
||||
/** Removes an active channel plan.
|
||||
*
|
||||
* You cannot remove default channels (the channels the base stations are listening to).
|
||||
* When a plan is abolished, only the non-default channels are removed.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t remove_channel_plan();
|
||||
virtual lorawan_status_t remove_channel_plan();
|
||||
|
||||
/** Removes a single channel.
|
||||
*
|
||||
|
@ -275,10 +275,10 @@ public:
|
|||
*
|
||||
* @param index The channel index.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t remove_channel(uint8_t index);
|
||||
virtual lorawan_status_t remove_channel(uint8_t index);
|
||||
|
||||
/** Send message to gateway
|
||||
*
|
||||
|
@ -311,7 +311,7 @@ public:
|
|||
*
|
||||
*
|
||||
* @return The number of bytes sent, or
|
||||
* LORA_MAC_STATUS_WOULD_BLOCK if another TX is
|
||||
* LORAWAN_STATUS_WOULD_BLOCK if another TX is
|
||||
* ongoing, or a negative error code on failure.
|
||||
*/
|
||||
virtual int16_t send(uint8_t port, const uint8_t* data, uint16_t length,
|
||||
|
@ -352,7 +352,7 @@ public:
|
|||
* @return It could be one of these:
|
||||
* i) 0 if there is nothing else to read.
|
||||
* ii) Number of bytes written to user buffer.
|
||||
* iii) LORA_MAC_STATUS_WOULD_BLOCK if there is
|
||||
* iii) LORAWAN_STATUS_WOULD_BLOCK if there is
|
||||
* nothing available to read at the moment.
|
||||
* iv) A negative error code on failure.
|
||||
*/
|
||||
|
@ -427,7 +427,7 @@ public:
|
|||
* @param callbacks A pointer to the structure containing application
|
||||
* callbacks.
|
||||
*/
|
||||
virtual lora_mac_status_t add_app_callbacks(lorawan_app_callbacks_t *callbacks);
|
||||
virtual lorawan_status_t add_app_callbacks(lorawan_app_callbacks_t *callbacks);
|
||||
|
||||
private:
|
||||
bool _link_check_requested;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -97,9 +97,9 @@ public:
|
|||
|
||||
/** End device initialization.
|
||||
* @param queue A pointer to an EventQueue passed from the application.
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error code on failure.
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error code on failure.
|
||||
*/
|
||||
lora_mac_status_t initialize_mac_layer(events::EventQueue *queue);
|
||||
lorawan_status_t initialize_mac_layer(events::EventQueue *queue);
|
||||
|
||||
/** Sets all callbacks for the application.
|
||||
*
|
||||
|
@ -126,35 +126,35 @@ public:
|
|||
*
|
||||
* @param channel_plan A list of channels or a single channel.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
lora_mac_status_t add_channels(const lora_channelplan_t &channel_plan);
|
||||
lorawan_status_t add_channels(const lorawan_channelplan_t &channel_plan);
|
||||
|
||||
/** Removes a channel from the list.
|
||||
*
|
||||
* @param channel_id Index of the channel being removed
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
lora_mac_status_t remove_a_channel(uint8_t channel_id);
|
||||
lorawan_status_t remove_a_channel(uint8_t channel_id);
|
||||
|
||||
/** Removes a previously set channel plan.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
lora_mac_status_t drop_channel_list();
|
||||
lorawan_status_t drop_channel_list();
|
||||
|
||||
/** Gets a list of currently enabled channels .
|
||||
*
|
||||
* @param channel_plan The channel plan structure to store final result.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
lora_mac_status_t get_enabled_channels(lora_channelplan_t &channel_plan);
|
||||
lorawan_status_t get_enabled_channels(lorawan_channelplan_t &channel_plan);
|
||||
|
||||
/** Sets up a retry counter for confirmed messages.
|
||||
*
|
||||
|
@ -164,9 +164,9 @@ public:
|
|||
*
|
||||
* @param count The number of retries for confirmed messages.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or a negative error code.
|
||||
* @return LORAWAN_STATUS_OK or a negative error code.
|
||||
*/
|
||||
lora_mac_status_t set_confirmed_msg_retry(uint8_t count);
|
||||
lorawan_status_t set_confirmed_msg_retry(uint8_t count);
|
||||
|
||||
/** Sets up the data rate.
|
||||
*
|
||||
|
@ -177,26 +177,26 @@ public:
|
|||
* Note that the macro DR_* can mean different
|
||||
* things in different regions.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well, otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well, otherwise
|
||||
* a negative error code.
|
||||
*/
|
||||
lora_mac_status_t set_channel_data_rate(uint8_t data_rate);
|
||||
lorawan_status_t set_channel_data_rate(uint8_t data_rate);
|
||||
|
||||
/** Enables ADR.
|
||||
*
|
||||
* @param adr_enabled 0 ADR disabled, 1 ADR enabled.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
lora_mac_status_t enable_adaptive_datarate(bool adr_enabled);
|
||||
lorawan_status_t enable_adaptive_datarate(bool adr_enabled);
|
||||
|
||||
/** Commissions a LoRa device.
|
||||
*
|
||||
* @param commission_data A structure representing all the commission
|
||||
* information.
|
||||
*/
|
||||
void commission_device(const lora_dev_commission_t &commission_data);
|
||||
void commission_device(const lorawan_dev_commission_t &commission_data);
|
||||
|
||||
/** End device OTAA join.
|
||||
*
|
||||
|
@ -205,11 +205,11 @@ public:
|
|||
*
|
||||
* @param params The `lorawan_connect_t` type structure.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or
|
||||
* LORA_MAC_STATUS_CONNECT_IN_PROGRESS on success,
|
||||
* @return LORAWAN_STATUS_OK or
|
||||
* LORAWAN_STATUS_CONNECT_IN_PROGRESS on success,
|
||||
* or a negative error code on failure.
|
||||
*/
|
||||
lora_mac_status_t join_request_by_otaa(const lorawan_connect_t ¶ms);
|
||||
lorawan_status_t join_request_by_otaa(const lorawan_connect_t ¶ms);
|
||||
|
||||
/** End device ABP join.
|
||||
*
|
||||
|
@ -218,11 +218,11 @@ public:
|
|||
*
|
||||
* @param params The `lorawan_connect_t` type structure.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or
|
||||
* LORA_MAC_STATUS_CONNECT_IN_PROGRESS on success,
|
||||
* @return LORAWAN_STATUS_OK or
|
||||
* LORAWAN_STATUS_CONNECT_IN_PROGRESS on success,
|
||||
* or a negative error code on failure.
|
||||
*/
|
||||
lora_mac_status_t activation_by_personalization(const lorawan_connect_t ¶ms);
|
||||
lorawan_status_t activation_by_personalization(const lorawan_connect_t ¶ms);
|
||||
|
||||
/** Send message to gateway
|
||||
*
|
||||
|
@ -255,7 +255,7 @@ public:
|
|||
*
|
||||
*
|
||||
* @return The number of bytes sent, or
|
||||
* LORA_MAC_STATUS_WOULD_BLOCK if another TX is
|
||||
* LORAWAN_STATUS_WOULD_BLOCK if another TX is
|
||||
* ongoing, or a negative error code on failure.
|
||||
*/
|
||||
int16_t handle_tx(uint8_t port, const uint8_t* data,
|
||||
|
@ -296,7 +296,7 @@ public:
|
|||
* @return It could be one of these:
|
||||
* i) 0 if there is nothing else to read.
|
||||
* ii) Number of bytes written to user buffer.
|
||||
* iii) LORA_MAC_STATUS_WOULD_BLOCK if there is
|
||||
* iii) LORAWAN_STATUS_WOULD_BLOCK if there is
|
||||
* nothing available to read at the moment.
|
||||
* iv) A negative error code on failure.
|
||||
*/
|
||||
|
@ -311,13 +311,13 @@ public:
|
|||
* from the Network Server, an event is generated.
|
||||
*
|
||||
* A callback function for the link check response must be set prior to using
|
||||
* this API, otherwise a LORA_MAC_STATUS_PARAMETER_INVALID error is thrown.
|
||||
* this API, otherwise a LORAWAN_STATUS_PARAMETER_INVALID error is thrown.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on successfully queuing a request, or
|
||||
* @return LORAWAN_STATUS_OK on successfully queuing a request, or
|
||||
* a negative error code on failure.
|
||||
*
|
||||
*/
|
||||
lora_mac_status_t set_link_check_request();
|
||||
lorawan_status_t set_link_check_request();
|
||||
|
||||
/** Shuts down the LoRaWAN protocol.
|
||||
*
|
||||
|
@ -338,7 +338,7 @@ private:
|
|||
* State machine for stack controller layer.
|
||||
* Needs to be wriggled for every state change
|
||||
*/
|
||||
lora_mac_status_t lora_state_machine();
|
||||
lorawan_status_t lora_state_machine();
|
||||
|
||||
/**
|
||||
* Sets the current state of the device.
|
||||
|
@ -351,56 +351,35 @@ private:
|
|||
/**
|
||||
* Hands over the packet to Mac layer by posting an MCPS request.
|
||||
*/
|
||||
lora_mac_status_t send_frame_to_mac();
|
||||
|
||||
/**
|
||||
* Callback function for MCPS confirm. Mac layer calls this function once
|
||||
* an MCPS confirmation is received. This method translates Mac layer data
|
||||
* structure into stack layer data structure.
|
||||
*/
|
||||
void mcps_confirm(McpsConfirm_t *mcps_confirm);
|
||||
|
||||
/**
|
||||
* Callback function for MCPS indication. Mac layer calls this function once
|
||||
* an MCPS indication is received. This method translates Mac layer data
|
||||
* structure into stack layer data structure.
|
||||
*/
|
||||
void mcps_indication(McpsIndication_t *mcps_indication);
|
||||
|
||||
/**
|
||||
* Callback function for MLME confirm. Mac layer calls this function once
|
||||
* an MLME confirmation is received. This method translates Mac layer data
|
||||
* structure into stack layer data structure.
|
||||
*/
|
||||
void mlme_confirm(MlmeConfirm_t *mlme_confirm);
|
||||
lorawan_status_t send_frame_to_mac();
|
||||
|
||||
/**
|
||||
* Callback function for MLME indication. Mac layer calls this function once
|
||||
* an MLME indication is received. This method translates Mac layer data
|
||||
* structure into stack layer data structure.
|
||||
*/
|
||||
void mlme_indication( MlmeIndication_t *mlmeIndication );
|
||||
void mlme_indication_handler(loramac_mlme_indication_t *mlmeIndication);
|
||||
|
||||
/**
|
||||
* Handles an MLME request coming from the upper layers and delegates
|
||||
* it to the Mac layer, for example, a Join request goes as an MLME request
|
||||
* to the Mac layer.
|
||||
*/
|
||||
lora_mac_status_t mlme_request_handler(lora_mac_mlme_req_t *mlme_request);
|
||||
lorawan_status_t mlme_request_handler(loramac_mlme_req_t *mlme_request);
|
||||
|
||||
/**
|
||||
* Handles an MLME confirmation coming from the Mac layer and uses it to
|
||||
* update the state for example, a Join Accept triggers an MLME confirmation,
|
||||
* that eventually comes here and we take necessary steps accordingly.
|
||||
*/
|
||||
void mlme_confirm_handler(lora_mac_mlme_confirm_t *mlme_confirm);
|
||||
void mlme_confirm_handler(loramac_mlme_confirm_t *mlme_confirm);
|
||||
|
||||
/**
|
||||
* Handles an MCPS request while attempting to hand over a packet from
|
||||
* upper layers to Mac layer. For example in response to send_frame_to_mac(),
|
||||
* an MCPS request is generated.
|
||||
*/
|
||||
lora_mac_status_t mcps_request_handler(lora_mac_mcps_req_t *mcps_request);
|
||||
lorawan_status_t mcps_request_handler(loramac_mcps_req_t *mcps_request);
|
||||
|
||||
/**
|
||||
* Handles an MCPS confirmation coming from the Mac layer in response to an
|
||||
|
@ -408,7 +387,7 @@ private:
|
|||
* e.g., letting the application know that ack was not received in case of
|
||||
* a CONFIRMED message or scheduling error etc.
|
||||
*/
|
||||
void mcps_confirm_handler(lora_mac_mcps_confirm_t *mcps_confirm);
|
||||
void mcps_confirm_handler(loramac_mcps_confirm_t *mcps_confirm);
|
||||
|
||||
/**
|
||||
* Handles an MCPS indication coming from the Mac layer, e.g., once we
|
||||
|
@ -416,22 +395,22 @@ private:
|
|||
* and consequently this handler posts an event to the application that
|
||||
* there is something available to read.
|
||||
*/
|
||||
void mcps_indication_handler(lora_mac_mcps_indication_t *mcps_indication);
|
||||
void mcps_indication_handler(loramac_mcps_indication_t *mcps_indication);
|
||||
|
||||
/**
|
||||
* Sets a MIB request, i.e., update a particular parameter etc.
|
||||
*/
|
||||
lora_mac_status_t mib_set_request(lora_mac_mib_request_confirm_t *mib_set_params);
|
||||
lorawan_status_t mib_set_request(loramac_mib_req_confirm_t *mib_set_params);
|
||||
|
||||
/**
|
||||
* Requests the MIB to inquire about a particular parameter.
|
||||
*/
|
||||
lora_mac_status_t mib_get_request(lora_mac_mib_request_confirm_t *mib_get_params);
|
||||
lorawan_status_t mib_get_request(loramac_mib_req_confirm_t *mib_get_params);
|
||||
|
||||
/**
|
||||
* Sets up user application port
|
||||
*/
|
||||
lora_mac_status_t set_application_port(uint8_t port);
|
||||
lorawan_status_t set_application_port(uint8_t port);
|
||||
|
||||
/**
|
||||
* Helper function to figure out if the user defined data size is possible
|
||||
|
@ -452,19 +431,14 @@ private:
|
|||
/**
|
||||
* Used only for compliance testing
|
||||
*/
|
||||
void compliance_test_handler(lora_mac_mcps_indication_t *mcps_indication);
|
||||
void compliance_test_handler(loramac_mcps_indication_t *mcps_indication);
|
||||
|
||||
/**
|
||||
* Used only for compliance testing
|
||||
*/
|
||||
lora_mac_status_t send_compliance_test_frame_to_mac();
|
||||
lorawan_status_t send_compliance_test_frame_to_mac();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* converts error codes from Mac layer to controller layer
|
||||
*/
|
||||
lora_mac_status_t error_type_converter(LoRaMacStatus_t type);
|
||||
|
||||
LoRaWANTimeHandler _lora_time;
|
||||
LoRaMac _loramac;
|
||||
LoRaPHY_region _lora_phy;
|
||||
|
@ -477,8 +451,8 @@ private:
|
|||
lorawan_app_callbacks_t _callbacks;
|
||||
radio_events_t *_mac_handlers;
|
||||
lorawan_session_t _lw_session;
|
||||
lora_mac_tx_message_t _tx_msg;
|
||||
lora_mac_rx_message_t _rx_msg;
|
||||
loramac_tx_message_t _tx_msg;
|
||||
loramac_rx_message_t _rx_msg;
|
||||
uint8_t _app_port;
|
||||
uint8_t _num_retry;
|
||||
events::EventQueue *_queue;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -83,12 +83,11 @@ public:
|
|||
* \param queue [in]- A pointer to the application provided EventQueue.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAMAC_STATUS_REGION_NOT_SUPPORTED.
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_REGION_NOT_SUPPORTED.
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacInitialization(LoRaMacPrimitives_t *primitives,
|
||||
LoRaMacCallback_t *callbacks,
|
||||
lorawan_status_t LoRaMacInitialization(loramac_primitives_t *primitives,
|
||||
LoRaPHY *phy,
|
||||
events::EventQueue *queue);
|
||||
|
||||
|
@ -105,16 +104,16 @@ public:
|
|||
* size, taking the scheduled MAC commands into account.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. When the parameters are
|
||||
* not valid, the function returns \ref LORAMAC_STATUS_PARAMETER_INVALID.
|
||||
* not valid, the function returns \ref LORAWAN_STATUS_PARAMETER_INVALID.
|
||||
* In case of a length error caused by the applicable payload in combination
|
||||
* with the MAC commands, the function returns \ref LORAMAC_STATUS_LENGTH_ERROR.
|
||||
* with the MAC commands, the function returns \ref LORAWAN_STATUS_LENGTH_ERROR.
|
||||
* Please note that if the size of the MAC commands in the queue do
|
||||
* not fit into the payload size on the related datarate, the LoRaMAC will
|
||||
* omit the MAC commands.
|
||||
* If the query is valid, and the LoRaMAC is able to send the frame,
|
||||
* the function returns \ref LORAMAC_STATUS_OK.
|
||||
* the function returns \ref LORAWAN_STATUS_OK.
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacQueryTxPossible( uint8_t size, LoRaMacTxInfo_t* txInfo );
|
||||
lorawan_status_t LoRaMacQueryTxPossible( uint8_t size, loramac_tx_info_t* txInfo );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel plan to the system.
|
||||
|
@ -127,11 +126,11 @@ public:
|
|||
* \param plan [in] - A reference to application provided channel plan.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t AddChannelPlan(const lora_channelplan_t& plan);
|
||||
lorawan_status_t AddChannelPlan(const lorawan_channelplan_t& plan);
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel plan from the system.
|
||||
|
@ -142,11 +141,11 @@ public:
|
|||
* LoRaWAN Regional Parameters V1.0.2rB.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t RemoveChannelPlan();
|
||||
lorawan_status_t RemoveChannelPlan();
|
||||
|
||||
/*!
|
||||
* \brief Access active channel plan.
|
||||
|
@ -158,11 +157,11 @@ public:
|
|||
* plan.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t GetChannelPlan(lora_channelplan_t& plan);
|
||||
lorawan_status_t GetChannelPlan(lorawan_channelplan_t& plan);
|
||||
|
||||
/*!
|
||||
* \brief Remove a given channel from the active plan.
|
||||
|
@ -172,11 +171,11 @@ public:
|
|||
* \param id - Id of the channel.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t RemoveSingleChannel( uint8_t id );
|
||||
lorawan_status_t RemoveSingleChannel( uint8_t id );
|
||||
|
||||
/*!
|
||||
* \brief LoRaMAC multicast channel link service.
|
||||
|
@ -186,11 +185,11 @@ public:
|
|||
* \param [in] channelParam - The multicast channel parameters to link.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacMulticastChannelLink( MulticastParams_t *channelParam );
|
||||
lorawan_status_t LoRaMacMulticastChannelLink( multicast_params_t *channelParam );
|
||||
|
||||
/*!
|
||||
* \brief LoRaMAC multicast channel unlink service.
|
||||
|
@ -200,11 +199,11 @@ public:
|
|||
* \param [in] channelParam - The multicast channel parameters to unlink.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacMulticastChannelUnlink( MulticastParams_t *channelParam );
|
||||
lorawan_status_t LoRaMacMulticastChannelUnlink( multicast_params_t *channelParam );
|
||||
|
||||
/*!
|
||||
* \brief LoRaMAC MIB-GET.
|
||||
|
@ -218,7 +217,7 @@ public:
|
|||
* MibRequestConfirm_t mibReq;
|
||||
* mibReq.Type = MIB_ADR;
|
||||
*
|
||||
* if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK )
|
||||
* if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAWAN_STATUS_OK )
|
||||
* {
|
||||
* // LoRaMAC updated the parameter mibParam.AdrEnable
|
||||
* }
|
||||
|
@ -227,11 +226,11 @@ public:
|
|||
* \param [in] mibGet - The MIB-GET request to perform. Refer to \ref MibRequestConfirm_t.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_SERVICE_UNKNOWN
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_SERVICE_UNKNOWN
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t *mibGet );
|
||||
lorawan_status_t LoRaMacMibGetRequestConfirm( loramac_mib_req_confirm_t *mibGet );
|
||||
|
||||
/*!
|
||||
* \brief LoRaMAC MIB-SET.
|
||||
|
@ -247,7 +246,7 @@ public:
|
|||
* mibReq.Type = MIB_ADR;
|
||||
* mibReq.Param.AdrEnable = true;
|
||||
*
|
||||
* if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK )
|
||||
* if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAWAN_STATUS_OK )
|
||||
* {
|
||||
* // LoRaMAC updated the parameter
|
||||
* }
|
||||
|
@ -256,12 +255,12 @@ public:
|
|||
* \param [in] mibSet - The MIB-SET request to perform. Refer to \ref MibRequestConfirm_t.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_SERVICE_UNKNOWN
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_SERVICE_UNKNOWN
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t *mibSet );
|
||||
lorawan_status_t LoRaMacMibSetRequestConfirm( loramac_mib_req_confirm_t *mibSet );
|
||||
|
||||
/*!
|
||||
* \brief LoRaMAC MLME request
|
||||
|
@ -291,7 +290,7 @@ public:
|
|||
* mlmeReq.Req.Join.AppEui = AppEui;
|
||||
* mlmeReq.Req.Join.AppKey = AppKey;
|
||||
*
|
||||
* if( LoRaMacMlmeRequest( &mlmeReq ) == LORAMAC_STATUS_OK )
|
||||
* if( LoRaMacMlmeRequest( &mlmeReq ) == LORAWAN_STATUS_OK )
|
||||
* {
|
||||
* // Service started successfully. Waiting for the Mlme-Confirm event
|
||||
* }
|
||||
|
@ -300,15 +299,15 @@ public:
|
|||
* \param [in] mlmeRequest - The MLME request to perform. Refer to \ref MlmeReq_t.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_SERVICE_UNKNOWN
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAMAC_STATUS_NO_NETWORK_JOINED
|
||||
* \ref LORAMAC_STATUS_LENGTH_ERROR
|
||||
* \ref LORAMAC_STATUS_DEVICE_OFF
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_SERVICE_UNKNOWN
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_NO_NETWORK_JOINED
|
||||
* \ref LORAWAN_STATUS_LENGTH_ERROR
|
||||
* \ref LORAWAN_STATUS_DEVICE_OFF
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t *mlmeRequest );
|
||||
lorawan_status_t LoRaMacMlmeRequest( loramac_mlme_req_t *mlmeRequest );
|
||||
|
||||
/*!
|
||||
* \brief LoRaMAC MCPS request
|
||||
|
@ -326,7 +325,7 @@ public:
|
|||
* mcpsReq.Req.Unconfirmed.fBuffer = myBuffer;
|
||||
* mcpsReq.Req.Unconfirmed.fBufferSize = sizeof( myBuffer );
|
||||
*
|
||||
* if( LoRaMacMcpsRequest( &mcpsReq ) == LORAMAC_STATUS_OK )
|
||||
* if( LoRaMacMcpsRequest( &mcpsReq ) == LORAWAN_STATUS_OK )
|
||||
* {
|
||||
* // Service started successfully. Waiting for the MCPS-Confirm event
|
||||
* }
|
||||
|
@ -335,15 +334,15 @@ public:
|
|||
* \param [in] mcpsRequest - The MCPS request to perform. Refer to \ref McpsReq_t.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_BUSY
|
||||
* \ref LORAMAC_STATUS_SERVICE_UNKNOWN
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAMAC_STATUS_NO_NETWORK_JOINED
|
||||
* \ref LORAMAC_STATUS_LENGTH_ERROR
|
||||
* \ref LORAMAC_STATUS_DEVICE_OFF
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_BUSY
|
||||
* \ref LORAWAN_STATUS_SERVICE_UNKNOWN
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_NO_NETWORK_JOINED
|
||||
* \ref LORAWAN_STATUS_LENGTH_ERROR
|
||||
* \ref LORAWAN_STATUS_DEVICE_OFF
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest );
|
||||
lorawan_status_t LoRaMacMcpsRequest( loramac_mcps_req_t *mcpsRequest );
|
||||
|
||||
/**
|
||||
* \brief LoRaMAC layer provides its callback functions for
|
||||
|
@ -368,7 +367,7 @@ public:
|
|||
* \param [IN] fBufferSize MAC data buffer size
|
||||
* \retval status Status of the operation.
|
||||
*/
|
||||
LoRaMacStatus_t Send( LoRaMacHeader_t *macHdr, uint8_t fPort, void *fBuffer, uint16_t fBufferSize );
|
||||
lorawan_status_t Send( loramac_mhdr_t *macHdr, uint8_t fPort, void *fBuffer, uint16_t fBufferSize );
|
||||
|
||||
/*!
|
||||
* \brief Sets the radio in continuous transmission mode
|
||||
|
@ -378,7 +377,7 @@ public:
|
|||
* \param [IN] timeout Time in seconds while the radio is kept in continuous wave mode
|
||||
* \retval status Status of the operation.
|
||||
*/
|
||||
LoRaMacStatus_t SetTxContinuousWave( uint16_t timeout );
|
||||
lorawan_status_t SetTxContinuousWave( uint16_t timeout );
|
||||
|
||||
/*!
|
||||
* \brief Sets the radio in continuous transmission mode
|
||||
|
@ -390,7 +389,7 @@ public:
|
|||
* \param [IN] power RF output power to be set.
|
||||
* \retval status Status of the operation.
|
||||
*/
|
||||
LoRaMacStatus_t SetTxContinuousWave1( uint16_t timeout, uint32_t frequency, uint8_t power );
|
||||
lorawan_status_t SetTxContinuousWave1( uint16_t timeout, uint32_t frequency, uint8_t power );
|
||||
|
||||
/*!
|
||||
* \brief Resets MAC specific parameters to default
|
||||
|
@ -414,10 +413,10 @@ public: // Test interface
|
|||
* \param [in] NextTxTime - Periodic time for next uplink.
|
||||
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacSetTxTimer( uint32_t NextTxTime );
|
||||
lorawan_status_t LoRaMacSetTxTimer( uint32_t NextTxTime );
|
||||
|
||||
/**
|
||||
* \brief LoRaMAC stop tx timer.
|
||||
|
@ -425,10 +424,10 @@ public: // Test interface
|
|||
* \details Stops the next tx timer.
|
||||
*
|
||||
* \retval `LoRaMacStatus_t` The status of the operation. The possible values are:
|
||||
* \ref LORAMAC_STATUS_OK
|
||||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
* \ref LORAWAN_STATUS_OK
|
||||
* \ref LORAWAN_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacStopTxTimer( );
|
||||
lorawan_status_t LoRaMacStopTxTimer( );
|
||||
|
||||
/**
|
||||
* \brief Enabled or disables the reception windows
|
||||
|
@ -474,7 +473,7 @@ private:
|
|||
/**
|
||||
* Timer to handle the application data transmission duty cycle
|
||||
*/
|
||||
TimerEvent_t TxNextPacketTimer;
|
||||
timer_event_t tx_next_packet_timer;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -576,14 +575,14 @@ private:
|
|||
* \param [IN] fBufferSize MAC data buffer size
|
||||
* \retval status Status of the operation.
|
||||
*/
|
||||
LoRaMacStatus_t PrepareFrame( LoRaMacHeader_t *macHdr, LoRaMacFrameCtrl_t *fCtrl, uint8_t fPort, void *fBuffer, uint16_t fBufferSize );
|
||||
lorawan_status_t PrepareFrame( loramac_mhdr_t *macHdr, loramac_frame_ctrl_t *fCtrl, uint8_t fPort, void *fBuffer, uint16_t fBufferSize );
|
||||
|
||||
/*
|
||||
* \brief Schedules the frame according to the duty cycle
|
||||
*
|
||||
* \retval Status of the operation
|
||||
*/
|
||||
LoRaMacStatus_t ScheduleTx( void );
|
||||
lorawan_status_t ScheduleTx( void );
|
||||
|
||||
/*
|
||||
* \brief Calculates the back-off time for the band of a channel.
|
||||
|
@ -601,7 +600,7 @@ private:
|
|||
* \param [IN] channel Channel to transmit on
|
||||
* \retval status Status of the operation.
|
||||
*/
|
||||
LoRaMacStatus_t SendFrameOnChannel( uint8_t channel );
|
||||
lorawan_status_t SendFrameOnChannel( uint8_t channel );
|
||||
|
||||
/*!
|
||||
* \brief Resets MAC specific parameters to default
|
||||
|
@ -669,7 +668,7 @@ private:
|
|||
/**
|
||||
* Central MAC layer data storage
|
||||
*/
|
||||
lora_mac_protocol_params _params;
|
||||
loramac_protocol_params _params;
|
||||
|
||||
/**
|
||||
* Radio event callback handlers for MAC
|
||||
|
@ -679,12 +678,7 @@ private:
|
|||
/*!
|
||||
* LoRaMac upper layer event functions
|
||||
*/
|
||||
LoRaMacPrimitives_t *LoRaMacPrimitives;
|
||||
|
||||
/*!
|
||||
* LoRaMac upper layer callback functions
|
||||
*/
|
||||
LoRaMacCallback_t *LoRaMacCallbacks;
|
||||
loramac_primitives_t *LoRaMacPrimitives;
|
||||
};
|
||||
|
||||
#endif // __LORAMAC_H__
|
||||
|
|
|
@ -39,11 +39,11 @@ void LoRaMacChannelPlan::activate_channelplan_subsystem(LoRaPHY *phy, LoRaMacMib
|
|||
_mib = mib;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacChannelPlan::set_plan(const lora_channelplan_t& plan)
|
||||
lorawan_status_t LoRaMacChannelPlan::set_plan(const lorawan_channelplan_t& plan)
|
||||
{
|
||||
ChannelAddParams_t channelAdd;
|
||||
ChannelParams_t mac_layer_ch_params;
|
||||
LoRaMacStatus_t status;
|
||||
channel_params_t mac_layer_ch_params;
|
||||
lorawan_status_t status;
|
||||
|
||||
GetPhyParams_t get_phy;
|
||||
PhyParam_t phy_param;
|
||||
|
@ -56,20 +56,20 @@ LoRaMacStatus_t LoRaMacChannelPlan::set_plan(const lora_channelplan_t& plan)
|
|||
|
||||
// check if user is setting more channels than supported
|
||||
if (plan.nb_channels > max_num_channels) {
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < plan.nb_channels; i++) {
|
||||
mac_layer_ch_params.Band = plan.channels[i].ch_param.band;
|
||||
mac_layer_ch_params.DrRange.Fields.Max =
|
||||
plan.channels[i].ch_param.dr_range.lora_mac_fields_s.max;
|
||||
mac_layer_ch_params.DrRange.Fields.Min =
|
||||
plan.channels[i].ch_param.dr_range.lora_mac_fields_s.min;
|
||||
mac_layer_ch_params.DrRange.Value =
|
||||
mac_layer_ch_params.band = plan.channels[i].ch_param.band;
|
||||
mac_layer_ch_params.dr_range.fields.max =
|
||||
plan.channels[i].ch_param.dr_range.fields.max;
|
||||
mac_layer_ch_params.dr_range.fields.min =
|
||||
plan.channels[i].ch_param.dr_range.fields.min;
|
||||
mac_layer_ch_params.dr_range.value =
|
||||
plan.channels[i].ch_param.dr_range.value;
|
||||
mac_layer_ch_params.Frequency =
|
||||
mac_layer_ch_params.frequency =
|
||||
plan.channels[i].ch_param.frequency;
|
||||
mac_layer_ch_params.Rx1Frequency =
|
||||
mac_layer_ch_params.rx1_frequency =
|
||||
plan.channels[i].ch_param.rx1_frequency;
|
||||
|
||||
channelAdd.ChannelId = plan.channels[i].id;
|
||||
|
@ -77,23 +77,23 @@ LoRaMacStatus_t LoRaMacChannelPlan::set_plan(const lora_channelplan_t& plan)
|
|||
|
||||
status = _lora_phy->add_channel(&channelAdd);
|
||||
|
||||
if (status != LORAMAC_STATUS_OK) {
|
||||
if (status != LORAWAN_STATUS_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacChannelPlan::get_plan(lora_channelplan_t& plan,
|
||||
lora_mac_protocol_params *params)
|
||||
lorawan_status_t LoRaMacChannelPlan::get_plan(lorawan_channelplan_t& plan,
|
||||
loramac_protocol_params *params)
|
||||
{
|
||||
if (params == NULL) {
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
MibRequestConfirm_t mib_params;
|
||||
LoRaMacStatus_t status;
|
||||
loramac_mib_req_confirm_t mib_confirm;
|
||||
lorawan_status_t status;
|
||||
|
||||
GetPhyParams_t get_phy;
|
||||
PhyParam_t phy_param;
|
||||
|
@ -112,12 +112,12 @@ LoRaMacStatus_t LoRaMacChannelPlan::get_plan(lora_channelplan_t& plan,
|
|||
channel_masks = phy_param.ChannelsMask;
|
||||
|
||||
// Request Mib to get channels
|
||||
memset(&mib_params, 0, sizeof(mib_params));
|
||||
mib_params.Type = MIB_CHANNELS;
|
||||
memset(&mib_confirm, 0, sizeof(mib_confirm));
|
||||
mib_confirm.type = MIB_CHANNELS;
|
||||
|
||||
status = _mib->get_request(&mib_params, params);
|
||||
status = _mib->get_request(&mib_confirm, params);
|
||||
|
||||
if (status != LORAMAC_STATUS_OK) {
|
||||
if (status != LORAWAN_STATUS_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -129,23 +129,23 @@ LoRaMacStatus_t LoRaMacChannelPlan::get_plan(lora_channelplan_t& plan,
|
|||
|
||||
// otherwise add them to the channel_plan struct
|
||||
plan.channels[count].id = i;
|
||||
plan.channels[count].ch_param.frequency = mib_params.Param.ChannelList[i].Frequency;
|
||||
plan.channels[count].ch_param.dr_range.value = mib_params.Param.ChannelList[i].DrRange.Value;
|
||||
plan.channels[count].ch_param.dr_range.lora_mac_fields_s.min = mib_params.Param.ChannelList[i].DrRange.Fields.Min;
|
||||
plan.channels[count].ch_param.dr_range.lora_mac_fields_s.max = mib_params.Param.ChannelList[i].DrRange.Fields.Max;
|
||||
plan.channels[count].ch_param.band = mib_params.Param.ChannelList[i].Band;
|
||||
plan.channels[count].ch_param.rx1_frequency = mib_params.Param.ChannelList[i].Rx1Frequency;
|
||||
plan.channels[count].ch_param.frequency = mib_confirm.param.channel_list[i].frequency;
|
||||
plan.channels[count].ch_param.dr_range.value = mib_confirm.param.channel_list[i].dr_range.value;
|
||||
plan.channels[count].ch_param.dr_range.fields.min = mib_confirm.param.channel_list[i].dr_range.fields.min;
|
||||
plan.channels[count].ch_param.dr_range.fields.max = mib_confirm.param.channel_list[i].dr_range.fields.max;
|
||||
plan.channels[count].ch_param.band = mib_confirm.param.channel_list[i].band;
|
||||
plan.channels[count].ch_param.rx1_frequency = mib_confirm.param.channel_list[i].rx1_frequency;
|
||||
count++;
|
||||
}
|
||||
|
||||
plan.nb_channels = count;
|
||||
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacChannelPlan::remove_plan()
|
||||
lorawan_status_t LoRaMacChannelPlan::remove_plan()
|
||||
{
|
||||
LoRaMacStatus_t status = LORAMAC_STATUS_OK;
|
||||
lorawan_status_t status = LORAWAN_STATUS_OK;
|
||||
|
||||
GetPhyParams_t get_phy;
|
||||
PhyParam_t phy_param;
|
||||
|
@ -181,7 +181,7 @@ LoRaMacStatus_t LoRaMacChannelPlan::remove_plan()
|
|||
|
||||
status = remove_single_channel(i);
|
||||
|
||||
if (status != LORAMAC_STATUS_OK) {
|
||||
if (status != LORAWAN_STATUS_OK) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ LoRaMacStatus_t LoRaMacChannelPlan::remove_plan()
|
|||
return status;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacChannelPlan::remove_single_channel(uint8_t channel_id)
|
||||
lorawan_status_t LoRaMacChannelPlan::remove_single_channel(uint8_t channel_id)
|
||||
{
|
||||
GetPhyParams_t get_phy;
|
||||
PhyParam_t phy_param;
|
||||
|
@ -206,7 +206,7 @@ LoRaMacStatus_t LoRaMacChannelPlan::remove_single_channel(uint8_t channel_id)
|
|||
// channel ID is N-1 where N=MAX_NUM_CHANNELS.
|
||||
// So any ID which is larger or equal to the Max number of channels is invalid
|
||||
if (channel_id >= max_num_channels) {
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
// Now check the Default channel mask
|
||||
|
@ -219,18 +219,18 @@ LoRaMacStatus_t LoRaMacChannelPlan::remove_single_channel(uint8_t channel_id)
|
|||
// have multiple channel masks for various sub-bands. So we check the first
|
||||
// mask only and return an error code if user sent a default channel id
|
||||
if ((channel_masks[0] & (1U << channel_id)) != 0) {
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
channelRemove.ChannelId = channel_id;
|
||||
|
||||
if(_lora_phy->remove_channel(&channelRemove) == false)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
_lora_phy->put_radio_to_sleep();
|
||||
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,10 +64,10 @@ public:
|
|||
* @param plan a reference to application channel plan. PHY layer takes a
|
||||
* copy of the channel parameters provided within.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well otherwise
|
||||
* a negative error code is returned.
|
||||
*/
|
||||
LoRaMacStatus_t set_plan(const lora_channelplan_t& plan);
|
||||
lorawan_status_t set_plan(const lorawan_channelplan_t& plan);
|
||||
|
||||
/** Access the active channel plan
|
||||
*
|
||||
|
@ -78,28 +78,28 @@ public:
|
|||
*
|
||||
* @param params pointer to active MAC layer parameters.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well otherwise
|
||||
* a negative error code is returned.
|
||||
*/
|
||||
LoRaMacStatus_t get_plan(lora_channelplan_t& plan, lora_mac_protocol_params *params);
|
||||
lorawan_status_t get_plan(lorawan_channelplan_t& plan, loramac_protocol_params *params);
|
||||
|
||||
/** Remove the active channel plan
|
||||
*
|
||||
* Drops the whole channel list except the 'Default Channels' ofcourse.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well otherwise
|
||||
* a negative error code is returned.
|
||||
*/
|
||||
LoRaMacStatus_t remove_plan();
|
||||
lorawan_status_t remove_plan();
|
||||
|
||||
/** Remove a single channel from the plan
|
||||
*
|
||||
* @param id the channel id which needs to be removed
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well otherwise
|
||||
* a negative error code is returned.
|
||||
*/
|
||||
LoRaMacStatus_t remove_single_channel(uint8_t id);
|
||||
lorawan_status_t remove_single_channel(uint8_t id);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ LoRaMacCommand::~LoRaMacCommand()
|
|||
{
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p2)
|
||||
lorawan_status_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p2)
|
||||
{
|
||||
LoRaMacStatus_t status = LORAMAC_STATUS_BUSY;
|
||||
lorawan_status_t status = LORAWAN_STATUS_BUSY;
|
||||
// The maximum buffer length must take MAC commands to re-send into account.
|
||||
const uint8_t bufLen = LORA_MAC_COMMAND_MAX_LENGTH - MacCommandsBufferToRepeatIndex;
|
||||
|
||||
|
@ -66,7 +66,7 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
{
|
||||
MacCommandsBuffer[MacCommandsBufferIndex++] = cmd;
|
||||
// No payload for this command
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
case MOTE_MAC_LINK_ADR_ANS:
|
||||
|
@ -75,7 +75,7 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
MacCommandsBuffer[MacCommandsBufferIndex++] = cmd;
|
||||
// Margin
|
||||
MacCommandsBuffer[MacCommandsBufferIndex++] = p1;
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
case MOTE_MAC_DUTY_CYCLE_ANS:
|
||||
|
@ -83,7 +83,7 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
{
|
||||
MacCommandsBuffer[MacCommandsBufferIndex++] = cmd;
|
||||
// No payload for this answer
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
case MOTE_MAC_RX_PARAM_SETUP_ANS:
|
||||
|
@ -94,7 +94,7 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
MacCommandsBuffer[MacCommandsBufferIndex++] = p1;
|
||||
// This is a sticky MAC command answer. Setup indication
|
||||
_lora_mac.SetMlmeScheduleUplinkIndication();
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
case MOTE_MAC_DEV_STATUS_ANS:
|
||||
|
@ -105,7 +105,7 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
// 2nd byte Margin
|
||||
MacCommandsBuffer[MacCommandsBufferIndex++] = p1;
|
||||
MacCommandsBuffer[MacCommandsBufferIndex++] = p2;
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
case MOTE_MAC_NEW_CHANNEL_ANS:
|
||||
|
@ -114,7 +114,7 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
MacCommandsBuffer[MacCommandsBufferIndex++] = cmd;
|
||||
// Status: Datarate range OK, Channel frequency OK
|
||||
MacCommandsBuffer[MacCommandsBufferIndex++] = p1;
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
case MOTE_MAC_RX_TIMING_SETUP_ANS:
|
||||
|
@ -124,7 +124,7 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
// No payload for this answer
|
||||
// This is a sticky MAC command answer. Setup indication
|
||||
_lora_mac.SetMlmeScheduleUplinkIndication();
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
case MOTE_MAC_TX_PARAM_SETUP_ANS:
|
||||
|
@ -132,7 +132,7 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
{
|
||||
MacCommandsBuffer[MacCommandsBufferIndex++] = cmd;
|
||||
// No payload for this answer
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
case MOTE_MAC_DL_CHANNEL_ANS:
|
||||
|
@ -143,13 +143,13 @@ LoRaMacStatus_t LoRaMacCommand::AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p
|
|||
MacCommandsBuffer[MacCommandsBufferIndex++] = p1;
|
||||
// This is a sticky MAC command answer. Setup indication
|
||||
_lora_mac.SetMlmeScheduleUplinkIndication();
|
||||
status = LORAMAC_STATUS_OK;
|
||||
status = LORAWAN_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return LORAMAC_STATUS_SERVICE_UNKNOWN;
|
||||
return LORAWAN_STATUS_SERVICE_UNKNOWN;
|
||||
}
|
||||
if( status == LORAMAC_STATUS_OK )
|
||||
if( status == LORAWAN_STATUS_OK )
|
||||
{
|
||||
MacCommandsInNextTx = true;
|
||||
}
|
||||
|
@ -251,9 +251,11 @@ bool LoRaMacCommand::IsMacCommandsInNextTx() const
|
|||
return MacCommandsInNextTx;
|
||||
}
|
||||
|
||||
void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint8_t commandsSize, uint8_t snr,
|
||||
MlmeConfirm_t& MlmeConfirm, LoRaMacCallback_t *LoRaMacCallbacks,
|
||||
lora_mac_system_params_t &LoRaMacParams, LoRaPHY &lora_phy)
|
||||
void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex,
|
||||
uint8_t commandsSize, uint8_t snr,
|
||||
loramac_mlme_confirm_t& MlmeConfirm,
|
||||
lora_mac_system_params_t &LoRaMacParams,
|
||||
LoRaPHY &lora_phy)
|
||||
{
|
||||
uint8_t status = 0;
|
||||
|
||||
|
@ -263,9 +265,9 @@ void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint
|
|||
switch( payload[macIndex++] )
|
||||
{
|
||||
case SRV_MAC_LINK_CHECK_ANS:
|
||||
MlmeConfirm.Status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
MlmeConfirm.DemodMargin = payload[macIndex++];
|
||||
MlmeConfirm.NbGateways = payload[macIndex++];
|
||||
MlmeConfirm.status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
MlmeConfirm.demod_margin = payload[macIndex++];
|
||||
MlmeConfirm.nb_gateways = payload[macIndex++];
|
||||
break;
|
||||
case SRV_MAC_LINK_ADR_REQ:
|
||||
{
|
||||
|
@ -278,11 +280,11 @@ void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint
|
|||
// Fill parameter structure
|
||||
linkAdrReq.Payload = &payload[macIndex - 1];
|
||||
linkAdrReq.PayloadSize = commandsSize - ( macIndex - 1 );
|
||||
linkAdrReq.AdrEnabled = LoRaMacParams.AdrCtrlOn;
|
||||
linkAdrReq.UplinkDwellTime = LoRaMacParams.UplinkDwellTime;
|
||||
linkAdrReq.CurrentDatarate = LoRaMacParams.ChannelsDatarate;
|
||||
linkAdrReq.CurrentTxPower = LoRaMacParams.ChannelsTxPower;
|
||||
linkAdrReq.CurrentNbRep = LoRaMacParams.ChannelsNbRep;
|
||||
linkAdrReq.AdrEnabled = LoRaMacParams.adr_on;
|
||||
linkAdrReq.UplinkDwellTime = LoRaMacParams.uplink_dwell_time;
|
||||
linkAdrReq.CurrentDatarate = LoRaMacParams.channel_data_rate;
|
||||
linkAdrReq.CurrentTxPower = LoRaMacParams.channel_tx_power;
|
||||
linkAdrReq.CurrentNbRep = LoRaMacParams.retry_num;
|
||||
|
||||
// Process the ADR requests
|
||||
status = lora_phy.link_ADR_request(&linkAdrReq, &linkAdrDatarate,
|
||||
|
@ -291,9 +293,9 @@ void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint
|
|||
|
||||
if( ( status & 0x07 ) == 0x07 )
|
||||
{
|
||||
LoRaMacParams.ChannelsDatarate = linkAdrDatarate;
|
||||
LoRaMacParams.ChannelsTxPower = linkAdrTxPower;
|
||||
LoRaMacParams.ChannelsNbRep = linkAdrNbRep;
|
||||
LoRaMacParams.channel_data_rate = linkAdrDatarate;
|
||||
LoRaMacParams.channel_tx_power = linkAdrTxPower;
|
||||
LoRaMacParams.retry_num = linkAdrNbRep;
|
||||
}
|
||||
|
||||
// Add the answers to the buffer
|
||||
|
@ -306,8 +308,8 @@ void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint
|
|||
}
|
||||
break;
|
||||
case SRV_MAC_DUTY_CYCLE_REQ:
|
||||
LoRaMacParams.MaxDCycle = payload[macIndex++];
|
||||
LoRaMacParams.AggregatedDCycle = 1 << LoRaMacParams.MaxDCycle;
|
||||
LoRaMacParams.max_duty_cycle = payload[macIndex++];
|
||||
LoRaMacParams.aggregated_duty_cycle = 1 << LoRaMacParams.max_duty_cycle;
|
||||
AddMacCommand( MOTE_MAC_DUTY_CYCLE_ANS, 0, 0 );
|
||||
break;
|
||||
case SRV_MAC_RX_PARAM_SETUP_REQ:
|
||||
|
@ -329,9 +331,9 @@ void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint
|
|||
|
||||
if( ( status & 0x07 ) == 0x07 )
|
||||
{
|
||||
LoRaMacParams.Rx2Channel.Datarate = rxParamSetupReq.Datarate;
|
||||
LoRaMacParams.Rx2Channel.Frequency = rxParamSetupReq.Frequency;
|
||||
LoRaMacParams.Rx1DrOffset = rxParamSetupReq.DrOffset;
|
||||
LoRaMacParams.rx2_channel.datarate = rxParamSetupReq.Datarate;
|
||||
LoRaMacParams.rx2_channel.frequency = rxParamSetupReq.Frequency;
|
||||
LoRaMacParams.rx1_dr_offset = rxParamSetupReq.DrOffset;
|
||||
}
|
||||
AddMacCommand( MOTE_MAC_RX_PARAM_SETUP_ANS, status, 0 );
|
||||
}
|
||||
|
@ -339,28 +341,26 @@ void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint
|
|||
case SRV_MAC_DEV_STATUS_REQ:
|
||||
{
|
||||
uint8_t batteryLevel = BAT_LEVEL_NO_MEASURE;
|
||||
if( ( LoRaMacCallbacks != NULL ) && ( LoRaMacCallbacks->GetBatteryLevel != NULL ) )
|
||||
{
|
||||
batteryLevel = LoRaMacCallbacks->GetBatteryLevel( );
|
||||
}
|
||||
// we don't have a mechanism at the moment to measure
|
||||
// battery levels
|
||||
AddMacCommand( MOTE_MAC_DEV_STATUS_ANS, batteryLevel, snr );
|
||||
break;
|
||||
}
|
||||
case SRV_MAC_NEW_CHANNEL_REQ:
|
||||
{
|
||||
NewChannelReqParams_t newChannelReq;
|
||||
ChannelParams_t chParam;
|
||||
channel_params_t chParam;
|
||||
status = 0x03;
|
||||
|
||||
newChannelReq.ChannelId = payload[macIndex++];
|
||||
newChannelReq.NewChannel = &chParam;
|
||||
|
||||
chParam.Frequency = ( uint32_t )payload[macIndex++];
|
||||
chParam.Frequency |= ( uint32_t )payload[macIndex++] << 8;
|
||||
chParam.Frequency |= ( uint32_t )payload[macIndex++] << 16;
|
||||
chParam.Frequency *= 100;
|
||||
chParam.Rx1Frequency = 0;
|
||||
chParam.DrRange.Value = payload[macIndex++];
|
||||
chParam.frequency = ( uint32_t )payload[macIndex++];
|
||||
chParam.frequency |= ( uint32_t )payload[macIndex++] << 8;
|
||||
chParam.frequency |= ( uint32_t )payload[macIndex++] << 16;
|
||||
chParam.frequency *= 100;
|
||||
chParam.rx1_frequency = 0;
|
||||
chParam.dr_range.value = payload[macIndex++];
|
||||
|
||||
status = lora_phy.request_new_channel(&newChannelReq);
|
||||
|
||||
|
@ -375,8 +375,8 @@ void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint
|
|||
{
|
||||
delay++;
|
||||
}
|
||||
LoRaMacParams.ReceiveDelay1 = delay * 1000;
|
||||
LoRaMacParams.ReceiveDelay2 = LoRaMacParams.ReceiveDelay1 + 1000;
|
||||
LoRaMacParams.recv_delay1 = delay * 1000;
|
||||
LoRaMacParams.recv_delay2 = LoRaMacParams.recv_delay1 + 1000;
|
||||
AddMacCommand( MOTE_MAC_RX_TIMING_SETUP_ANS, 0, 0 );
|
||||
}
|
||||
break;
|
||||
|
@ -402,9 +402,9 @@ void LoRaMacCommand::ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint
|
|||
if( lora_phy.setup_tx_params(&txParamSetupReq ) != -1 )
|
||||
{
|
||||
// Accept command
|
||||
LoRaMacParams.UplinkDwellTime = txParamSetupReq.UplinkDwellTime;
|
||||
LoRaMacParams.DownlinkDwellTime = txParamSetupReq.DownlinkDwellTime;
|
||||
LoRaMacParams.MaxEirp = LoRaMacMaxEirpTable[txParamSetupReq.MaxEirp];
|
||||
LoRaMacParams.uplink_dwell_time = txParamSetupReq.UplinkDwellTime;
|
||||
LoRaMacParams.downlink_dwell_time = txParamSetupReq.DownlinkDwellTime;
|
||||
LoRaMacParams.max_eirp = LoRaMacMaxEirpTable[txParamSetupReq.MaxEirp];
|
||||
// Add command response
|
||||
AddMacCommand( MOTE_MAC_TX_PARAM_SETUP_ANS, 0, 0 );
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
*
|
||||
* \retval status Function status [0: OK, 1: Unknown command, 2: Buffer full]
|
||||
*/
|
||||
LoRaMacStatus_t AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p2);
|
||||
lorawan_status_t AddMacCommand(uint8_t cmd, uint8_t p1, uint8_t p2);
|
||||
|
||||
/*!
|
||||
* \brief Clear MAC command buffer.
|
||||
|
@ -132,9 +132,11 @@ public:
|
|||
/*!
|
||||
* \brief Decodes MAC commands in the fOpts field and in the payload
|
||||
*/
|
||||
void ProcessMacCommands(uint8_t *payload, uint8_t macIndex, uint8_t commandsSize, uint8_t snr,
|
||||
MlmeConfirm_t &MlmeConfirm, LoRaMacCallback_t *LoRaMacCallbacks,
|
||||
lora_mac_system_params_t &LoRaMacParams, LoRaPHY &lora_phy);
|
||||
void ProcessMacCommands(uint8_t *payload, uint8_t macIndex,
|
||||
uint8_t commandsSize, uint8_t snr,
|
||||
loramac_mlme_confirm_t& MlmeConfirm,
|
||||
lora_mac_system_params_t& LoRaMacParams,
|
||||
LoRaPHY& lora_phy);
|
||||
|
||||
/*!
|
||||
* \brief Verifies if sticky MAC commands are pending.
|
||||
|
|
|
@ -300,7 +300,7 @@ int LoRaMacComputeMic( const uint8_t *, uint16_t , const uint8_t *, uint32_t,
|
|||
MBED_ASSERT("[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
|
||||
|
||||
// Never actually reaches here
|
||||
return LORA_MAC_STATUS_CRYPTO_FAIL;
|
||||
return LORAWAN_STATUS_CRYPTO_FAIL;
|
||||
}
|
||||
|
||||
int LoRaMacPayloadEncrypt( const uint8_t *, uint16_t , const uint8_t *, uint32_t,
|
||||
|
@ -309,7 +309,7 @@ int LoRaMacPayloadEncrypt( const uint8_t *, uint16_t , const uint8_t *, uint32_t
|
|||
MBED_ASSERT("[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
|
||||
|
||||
// Never actually reaches here
|
||||
return LORA_MAC_STATUS_CRYPTO_FAIL;
|
||||
return LORAWAN_STATUS_CRYPTO_FAIL;
|
||||
}
|
||||
|
||||
int LoRaMacPayloadDecrypt( const uint8_t *, uint16_t , const uint8_t *, uint32_t,
|
||||
|
@ -318,14 +318,14 @@ int LoRaMacPayloadDecrypt( const uint8_t *, uint16_t , const uint8_t *, uint32_t
|
|||
MBED_ASSERT("[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
|
||||
|
||||
// Never actually reaches here
|
||||
return LORA_MAC_STATUS_CRYPTO_FAIL;
|
||||
return LORAWAN_STATUS_CRYPTO_FAIL;
|
||||
}
|
||||
int LoRaMacJoinComputeMic( const uint8_t *, uint16_t , const uint8_t *, uint32_t * )
|
||||
{
|
||||
MBED_ASSERT("[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
|
||||
|
||||
// Never actually reaches here
|
||||
return LORA_MAC_STATUS_CRYPTO_FAIL;
|
||||
return LORAWAN_STATUS_CRYPTO_FAIL;
|
||||
}
|
||||
|
||||
int LoRaMacJoinDecrypt( const uint8_t *, uint16_t , const uint8_t *, uint8_t * )
|
||||
|
@ -333,7 +333,7 @@ int LoRaMacJoinDecrypt( const uint8_t *, uint16_t , const uint8_t *, uint8_t * )
|
|||
MBED_ASSERT("[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
|
||||
|
||||
// Never actually reaches here
|
||||
return LORA_MAC_STATUS_CRYPTO_FAIL;
|
||||
return LORAWAN_STATUS_CRYPTO_FAIL;
|
||||
}
|
||||
|
||||
int LoRaMacJoinComputeSKeys( const uint8_t *, const uint8_t *, uint16_t , uint8_t *, uint8_t * )
|
||||
|
@ -341,7 +341,7 @@ int LoRaMacJoinComputeSKeys( const uint8_t *, const uint8_t *, uint16_t , uint8_
|
|||
MBED_ASSERT("[LoRaCrypto] Must enable AES, CMAC & CIPHER from mbedTLS");
|
||||
|
||||
// Never actually reaches here
|
||||
return LORA_MAC_STATUS_CRYPTO_FAIL;
|
||||
return LORAWAN_STATUS_CRYPTO_FAIL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,22 +41,18 @@ void LoRaMacMcps::activate_mcps_subsystem(LoRaMac *mac, LoRaPHY *phy)
|
|||
_lora_phy = phy;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacMcps::set_request(McpsReq_t *mcpsRequest,
|
||||
lora_mac_protocol_params *params)
|
||||
lorawan_status_t LoRaMacMcps::set_request(loramac_mcps_req_t *mcpsRequest,
|
||||
loramac_protocol_params *params)
|
||||
{
|
||||
|
||||
if (mcpsRequest == NULL || _lora_phy == NULL || _lora_mac == NULL) {
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
if (params->LoRaMacState != LORAMAC_IDLE) {
|
||||
return LORAMAC_STATUS_BUSY;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
GetPhyParams_t getPhy;
|
||||
PhyParam_t phyParam;
|
||||
LoRaMacStatus_t status = LORAMAC_STATUS_SERVICE_UNKNOWN;
|
||||
LoRaMacHeader_t macHdr;
|
||||
lorawan_status_t status = LORAWAN_STATUS_SERVICE_UNKNOWN;
|
||||
loramac_mhdr_t macHdr;
|
||||
VerifyParams_t verify;
|
||||
uint8_t fPort = 0;
|
||||
void *fBuffer;
|
||||
|
@ -64,47 +60,47 @@ LoRaMacStatus_t LoRaMacMcps::set_request(McpsReq_t *mcpsRequest,
|
|||
int8_t datarate = DR_0;
|
||||
bool readyToSend = false;
|
||||
|
||||
macHdr.Value = 0;
|
||||
macHdr.value = 0;
|
||||
|
||||
// Before performing any MCPS request, clear the confirmation structure
|
||||
memset((uint8_t*) &confirmation, 0, sizeof(confirmation));
|
||||
|
||||
confirmation.Status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
||||
confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
||||
|
||||
// AckTimeoutRetriesCounter must be reset every time a new request (unconfirmed or confirmed) is performed.
|
||||
params->AckTimeoutRetriesCounter = 1;
|
||||
// ack_timeout_retry_counter must be reset every time a new request (unconfirmed or confirmed) is performed.
|
||||
params->ack_timeout_retry_counter = 1;
|
||||
|
||||
switch (mcpsRequest->Type) {
|
||||
switch (mcpsRequest->type) {
|
||||
case MCPS_UNCONFIRMED: {
|
||||
readyToSend = true;
|
||||
params->AckTimeoutRetries = 1;
|
||||
params->max_ack_timeout_retries = 1;
|
||||
|
||||
macHdr.Bits.MType = FRAME_TYPE_DATA_UNCONFIRMED_UP;
|
||||
fPort = mcpsRequest->Req.Unconfirmed.fPort;
|
||||
fBuffer = mcpsRequest->Req.Unconfirmed.fBuffer;
|
||||
fBufferSize = mcpsRequest->Req.Unconfirmed.fBufferSize;
|
||||
datarate = mcpsRequest->Req.Unconfirmed.Datarate;
|
||||
macHdr.bits.mtype = FRAME_TYPE_DATA_UNCONFIRMED_UP;
|
||||
fPort = mcpsRequest->req.unconfirmed.fport;
|
||||
fBuffer = mcpsRequest->f_buffer;
|
||||
fBufferSize = mcpsRequest->f_buffer_size;
|
||||
datarate = mcpsRequest->req.unconfirmed.data_rate;
|
||||
break;
|
||||
}
|
||||
case MCPS_CONFIRMED: {
|
||||
readyToSend = true;
|
||||
params->AckTimeoutRetries = mcpsRequest->Req.Confirmed.NbTrials;
|
||||
params->max_ack_timeout_retries = mcpsRequest->req.confirmed.nb_trials;
|
||||
|
||||
macHdr.Bits.MType = FRAME_TYPE_DATA_CONFIRMED_UP;
|
||||
fPort = mcpsRequest->Req.Confirmed.fPort;
|
||||
fBuffer = mcpsRequest->Req.Confirmed.fBuffer;
|
||||
fBufferSize = mcpsRequest->Req.Confirmed.fBufferSize;
|
||||
datarate = mcpsRequest->Req.Confirmed.Datarate;
|
||||
macHdr.bits.mtype = FRAME_TYPE_DATA_CONFIRMED_UP;
|
||||
fPort = mcpsRequest->req.confirmed.fport;
|
||||
fBuffer = mcpsRequest->f_buffer;
|
||||
fBufferSize = mcpsRequest->f_buffer_size;
|
||||
datarate = mcpsRequest->req.confirmed.data_rate;
|
||||
break;
|
||||
}
|
||||
case MCPS_PROPRIETARY: {
|
||||
readyToSend = true;
|
||||
params->AckTimeoutRetries = 1;
|
||||
params->max_ack_timeout_retries = 1;
|
||||
|
||||
macHdr.Bits.MType = FRAME_TYPE_PROPRIETARY;
|
||||
fBuffer = mcpsRequest->Req.Proprietary.fBuffer;
|
||||
fBufferSize = mcpsRequest->Req.Proprietary.fBufferSize;
|
||||
datarate = mcpsRequest->Req.Proprietary.Datarate;
|
||||
macHdr.bits.mtype = FRAME_TYPE_PROPRIETARY;
|
||||
fBuffer = mcpsRequest->f_buffer;
|
||||
fBufferSize = mcpsRequest->f_buffer_size;
|
||||
datarate = mcpsRequest->req.proprietary.data_rate;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -115,12 +111,12 @@ LoRaMacStatus_t LoRaMacMcps::set_request(McpsReq_t *mcpsRequest,
|
|||
// TODO: Does not work with PROPRIETARY messages
|
||||
// if( IsFPortAllowed( fPort ) == false )
|
||||
// {
|
||||
// return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
// return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
// }
|
||||
|
||||
// Get the minimum possible datarate
|
||||
getPhy.Attribute = PHY_MIN_TX_DR;
|
||||
getPhy.UplinkDwellTime = params->sys_params.UplinkDwellTime;
|
||||
getPhy.UplinkDwellTime = params->sys_params.uplink_dwell_time;
|
||||
phyParam = _lora_phy->get_phy_params(&getPhy);
|
||||
|
||||
// Apply the minimum possible datarate.
|
||||
|
@ -128,25 +124,25 @@ LoRaMacStatus_t LoRaMacMcps::set_request(McpsReq_t *mcpsRequest,
|
|||
datarate = MAX(datarate, phyParam.Value);
|
||||
|
||||
if (readyToSend == true) {
|
||||
if (params->sys_params.AdrCtrlOn == false) {
|
||||
if (params->sys_params.adr_on == false) {
|
||||
verify.DatarateParams.Datarate = datarate;
|
||||
verify.DatarateParams.UplinkDwellTime =
|
||||
params->sys_params.UplinkDwellTime;
|
||||
params->sys_params.uplink_dwell_time;
|
||||
|
||||
if (_lora_phy->verify(&verify, PHY_TX_DR) == true) {
|
||||
params->sys_params.ChannelsDatarate =
|
||||
params->sys_params.channel_data_rate =
|
||||
verify.DatarateParams.Datarate;
|
||||
} else {
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
status = _lora_mac->Send(&macHdr, fPort, fBuffer, fBufferSize);
|
||||
if (status == LORAMAC_STATUS_OK) {
|
||||
confirmation.McpsRequest = mcpsRequest->Type;
|
||||
params->LoRaMacFlags.Bits.McpsReq = 1;
|
||||
if (status == LORAWAN_STATUS_OK) {
|
||||
confirmation.req_type = mcpsRequest->type;
|
||||
params->flags.bits.mcps_req = 1;
|
||||
} else {
|
||||
params->NodeAckRequested = false;
|
||||
params->is_node_ack_requested = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,16 +67,16 @@ public:
|
|||
* @param mcpsRequest pointer to MCPS request structure
|
||||
* @param params pointer to MAC protocol parameters
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well otherwise
|
||||
* a negative error code is returned.
|
||||
*/
|
||||
LoRaMacStatus_t set_request(McpsReq_t *mcpsRequest, lora_mac_protocol_params *params);
|
||||
lorawan_status_t set_request(loramac_mcps_req_t *mcpsRequest, loramac_protocol_params *params);
|
||||
|
||||
/** Grants access to MCPS confirmation data
|
||||
*
|
||||
* @return a reference to MCPS confirm data structure
|
||||
*/
|
||||
inline McpsConfirm_t& get_confirmation()
|
||||
inline loramac_mcps_confirm_t& get_confirmation()
|
||||
{
|
||||
return confirmation;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
*
|
||||
* @return a reference to MCPS indication data structure
|
||||
*/
|
||||
inline McpsIndication_t& get_indication()
|
||||
inline loramac_mcps_indication_t& get_indication()
|
||||
{
|
||||
return indication;
|
||||
}
|
||||
|
@ -102,12 +102,12 @@ private:
|
|||
/**
|
||||
* Structure to hold MCPS indication data.
|
||||
*/
|
||||
McpsIndication_t indication;
|
||||
loramac_mcps_indication_t indication;
|
||||
|
||||
/**
|
||||
* Structure to hold MCPS confirm data.
|
||||
*/
|
||||
McpsConfirm_t confirmation;
|
||||
loramac_mcps_confirm_t confirmation;
|
||||
};
|
||||
|
||||
#endif /* MBED_OS_LORAWAN_MAC_MCPS_H_ */
|
||||
|
|
|
@ -41,22 +41,22 @@ void LoRaMacMib::activate_mib_subsystem(LoRaMac *mac, LoRaPHY *phy)
|
|||
_lora_phy = phy;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacMib::set_request(MibRequestConfirm_t *mibSet,
|
||||
lora_mac_protocol_params *params)
|
||||
lorawan_status_t LoRaMacMib::set_request(loramac_mib_req_confirm_t *mibSet,
|
||||
loramac_protocol_params *params)
|
||||
{
|
||||
if (mibSet == NULL || _lora_phy == NULL || _lora_mac == NULL) {
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t status = LORAMAC_STATUS_OK;
|
||||
lorawan_status_t status = LORAWAN_STATUS_OK;
|
||||
ChanMaskSetParams_t chanMaskSet;
|
||||
VerifyParams_t verify;
|
||||
|
||||
|
||||
switch (mibSet->Type) {
|
||||
switch (mibSet->type) {
|
||||
case MIB_DEVICE_CLASS: {
|
||||
params->LoRaMacDeviceClass = mibSet->Param.Class;
|
||||
switch (params->LoRaMacDeviceClass) {
|
||||
params->dev_class = mibSet->param.dev_class;
|
||||
switch (params->dev_class) {
|
||||
case CLASS_A: {
|
||||
// Set the radio into sleep to setup a defined state
|
||||
_lora_phy->put_radio_to_sleep();
|
||||
|
@ -66,16 +66,16 @@ LoRaMacStatus_t LoRaMacMib::set_request(MibRequestConfirm_t *mibSet,
|
|||
break;
|
||||
}
|
||||
case CLASS_C: {
|
||||
// Set the NodeAckRequested indicator to default
|
||||
params->NodeAckRequested = false;
|
||||
// Set the is_node_ack_requested indicator to default
|
||||
params->is_node_ack_requested = false;
|
||||
// Set the radio into sleep mode in case we are still in RX mode
|
||||
_lora_phy->put_radio_to_sleep();
|
||||
// Compute Rx2 windows parameters in case the RX2 datarate has changed
|
||||
_lora_phy->compute_rx_win_params(
|
||||
params->sys_params.Rx2Channel.Datarate,
|
||||
params->sys_params.MinRxSymbols,
|
||||
params->sys_params.SystemMaxRxError,
|
||||
¶ms->RxWindow2Config);
|
||||
params->sys_params.rx2_channel.datarate,
|
||||
params->sys_params.min_rx_symb,
|
||||
params->sys_params.max_sys_rx_error,
|
||||
¶ms->rx_window2_config);
|
||||
_lora_mac->OpenContinuousRx2Window();
|
||||
break;
|
||||
}
|
||||
|
@ -83,58 +83,57 @@ LoRaMacStatus_t LoRaMacMib::set_request(MibRequestConfirm_t *mibSet,
|
|||
break;
|
||||
}
|
||||
case MIB_NETWORK_JOINED: {
|
||||
params->IsLoRaMacNetworkJoined = mibSet->Param.IsNetworkJoined;
|
||||
params->is_nwk_joined = mibSet->param.is_nwk_joined;
|
||||
break;
|
||||
}
|
||||
case MIB_ADR: {
|
||||
params->sys_params.AdrCtrlOn = mibSet->Param.AdrEnable;
|
||||
params->sys_params.adr_on = mibSet->param.is_adr_enable;
|
||||
break;
|
||||
}
|
||||
case MIB_NET_ID: {
|
||||
params->LoRaMacNetID = mibSet->Param.NetID;
|
||||
params->net_id = mibSet->param.net_id;
|
||||
break;
|
||||
}
|
||||
case MIB_DEV_ADDR: {
|
||||
params->LoRaMacDevAddr = mibSet->Param.DevAddr;
|
||||
params->dev_addr = mibSet->param.dev_addr;
|
||||
break;
|
||||
}
|
||||
case MIB_NWK_SKEY: {
|
||||
if (mibSet->Param.NwkSKey != NULL) {
|
||||
memcpy(params->keys.LoRaMacNwkSKey, mibSet->Param.NwkSKey,
|
||||
sizeof(params->keys.LoRaMacNwkSKey));
|
||||
if (mibSet->param.nwk_skey != NULL) {
|
||||
memcpy(params->keys.nwk_skey, mibSet->param.nwk_skey,
|
||||
sizeof(params->keys.nwk_skey));
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_APP_SKEY: {
|
||||
if (mibSet->Param.AppSKey != NULL) {
|
||||
memcpy(params->keys.LoRaMacAppSKey, mibSet->Param.AppSKey,
|
||||
sizeof(params->keys.LoRaMacAppSKey));
|
||||
if (mibSet->param.app_skey != NULL) {
|
||||
memcpy(params->keys.app_skey, mibSet->param.app_skey,
|
||||
sizeof(params->keys.app_skey));
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_PUBLIC_NETWORK: {
|
||||
params->PublicNetwork = mibSet->Param.EnablePublicNetwork;
|
||||
_lora_phy->setup_public_network_mode(params->PublicNetwork);
|
||||
params->is_nwk_public = mibSet->param.enable_public_nwk;
|
||||
_lora_phy->setup_public_network_mode(params->is_nwk_public);
|
||||
break;
|
||||
}
|
||||
case MIB_REPEATER_SUPPORT: {
|
||||
params->RepeaterSupport = mibSet->Param.EnableRepeaterSupport;
|
||||
params->is_repeater_supported = mibSet->param.enable_repeater_support;
|
||||
break;
|
||||
}
|
||||
case MIB_RX2_CHANNEL: {
|
||||
verify.DatarateParams.Datarate = mibSet->Param.Rx2Channel.Datarate;
|
||||
verify.DatarateParams.DownlinkDwellTime =
|
||||
params->sys_params.DownlinkDwellTime;
|
||||
verify.DatarateParams.Datarate = mibSet->param.rx2_channel.datarate;
|
||||
verify.DatarateParams.DownlinkDwellTime = params->sys_params.downlink_dwell_time;
|
||||
|
||||
if (_lora_phy->verify(&verify, PHY_RX_DR) == true) {
|
||||
params->sys_params.Rx2Channel = mibSet->Param.Rx2Channel;
|
||||
params->sys_params.rx2_channel = mibSet->param.rx2_channel;
|
||||
|
||||
if ((params->LoRaMacDeviceClass == CLASS_C)
|
||||
&& (params->IsLoRaMacNetworkJoined == true)) {
|
||||
if ((params->dev_class == CLASS_C)
|
||||
&& (params->is_nwk_joined == true)) {
|
||||
// We can only compute the RX window parameters directly, if we are already
|
||||
// in class c mode and joined. We cannot setup an RX window in case of any other
|
||||
// class type.
|
||||
|
@ -142,214 +141,206 @@ LoRaMacStatus_t LoRaMacMib::set_request(MibRequestConfirm_t *mibSet,
|
|||
_lora_phy->put_radio_to_sleep();
|
||||
// Compute Rx2 windows parameters
|
||||
_lora_phy->compute_rx_win_params(
|
||||
params->sys_params.Rx2Channel.Datarate,
|
||||
params->sys_params.MinRxSymbols,
|
||||
params->sys_params.SystemMaxRxError,
|
||||
¶ms->RxWindow2Config);
|
||||
params->sys_params.rx2_channel.datarate,
|
||||
params->sys_params.min_rx_symb,
|
||||
params->sys_params.max_sys_rx_error,
|
||||
¶ms->rx_window2_config);
|
||||
|
||||
_lora_mac->OpenContinuousRx2Window();
|
||||
}
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_RX2_DEFAULT_CHANNEL: {
|
||||
verify.DatarateParams.Datarate = mibSet->Param.Rx2Channel.Datarate;
|
||||
verify.DatarateParams.DownlinkDwellTime =
|
||||
params->sys_params.DownlinkDwellTime;
|
||||
verify.DatarateParams.Datarate = mibSet->param.rx2_channel.datarate;
|
||||
verify.DatarateParams.DownlinkDwellTime = params->sys_params.downlink_dwell_time;
|
||||
|
||||
if (_lora_phy->verify(&verify, PHY_RX_DR) == true) {
|
||||
params->def_sys_params.Rx2Channel =
|
||||
mibSet->Param.Rx2DefaultChannel;
|
||||
params->def_sys_params.rx2_channel = mibSet->param.default_rx2_channel;
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_DEFAULT_MASK: {
|
||||
chanMaskSet.ChannelsMaskIn = mibSet->Param.ChannelsMask;
|
||||
chanMaskSet.ChannelsMaskIn = mibSet->param.channel_mask;
|
||||
chanMaskSet.ChannelsMaskType = CHANNELS_DEFAULT_MASK;
|
||||
|
||||
if (_lora_phy->set_channel_mask(&chanMaskSet) == false) {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_MASK: {
|
||||
chanMaskSet.ChannelsMaskIn = mibSet->Param.ChannelsMask;
|
||||
chanMaskSet.ChannelsMaskIn = mibSet->param.channel_mask;
|
||||
chanMaskSet.ChannelsMaskType = CHANNELS_MASK;
|
||||
|
||||
if (_lora_phy->set_channel_mask(&chanMaskSet) == false) {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_NB_REP: {
|
||||
if ((mibSet->Param.ChannelNbRep >= 1)
|
||||
&& (mibSet->Param.ChannelNbRep <= 15)) {
|
||||
params->sys_params.ChannelsNbRep = mibSet->Param.ChannelNbRep;
|
||||
if ((mibSet->param.channel_nb_rep >= 1)
|
||||
&& (mibSet->param.channel_nb_rep <= 15)) {
|
||||
params->sys_params.retry_num = mibSet->param.channel_nb_rep;
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_MAX_RX_WINDOW_DURATION: {
|
||||
params->sys_params.MaxRxWindow = mibSet->Param.MaxRxWindow;
|
||||
params->sys_params.max_rx_win_time = mibSet->param.max_rx_window;
|
||||
break;
|
||||
}
|
||||
case MIB_RECEIVE_DELAY_1: {
|
||||
params->sys_params.ReceiveDelay1 = mibSet->Param.ReceiveDelay1;
|
||||
params->sys_params.recv_delay1 = mibSet->param.recv_delay1;
|
||||
break;
|
||||
}
|
||||
case MIB_RECEIVE_DELAY_2: {
|
||||
params->sys_params.ReceiveDelay2 = mibSet->Param.ReceiveDelay2;
|
||||
params->sys_params.recv_delay2 = mibSet->param.recv_delay2;
|
||||
break;
|
||||
}
|
||||
case MIB_JOIN_ACCEPT_DELAY_1: {
|
||||
params->sys_params.JoinAcceptDelay1 =
|
||||
mibSet->Param.JoinAcceptDelay1;
|
||||
params->sys_params.join_accept_delay1 = mibSet->param.join_accept_delay1;
|
||||
break;
|
||||
}
|
||||
case MIB_JOIN_ACCEPT_DELAY_2: {
|
||||
params->sys_params.JoinAcceptDelay2 =
|
||||
mibSet->Param.JoinAcceptDelay2;
|
||||
params->sys_params.join_accept_delay2 = mibSet->param.join_accept_delay2;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_DEFAULT_DATARATE: {
|
||||
verify.DatarateParams.Datarate =
|
||||
mibSet->Param.ChannelsDefaultDatarate;
|
||||
verify.DatarateParams.Datarate = mibSet->param.default_channel_data_rate;
|
||||
|
||||
if (_lora_phy->verify(&verify, PHY_DEF_TX_DR) == true) {
|
||||
params->def_sys_params.ChannelsDatarate =
|
||||
verify.DatarateParams.Datarate;
|
||||
params->def_sys_params.channel_data_rate = verify.DatarateParams.Datarate;
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_DATARATE: {
|
||||
verify.DatarateParams.Datarate = mibSet->Param.ChannelsDatarate;
|
||||
verify.DatarateParams.UplinkDwellTime =
|
||||
params->sys_params.UplinkDwellTime;
|
||||
verify.DatarateParams.Datarate = mibSet->param.channel_data_rate;
|
||||
verify.DatarateParams.UplinkDwellTime = params->sys_params.uplink_dwell_time;
|
||||
|
||||
if (_lora_phy->verify(&verify, PHY_TX_DR) == true) {
|
||||
params->sys_params.ChannelsDatarate =
|
||||
verify.DatarateParams.Datarate;
|
||||
params->sys_params.channel_data_rate = verify.DatarateParams.Datarate;
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_DEFAULT_TX_POWER: {
|
||||
verify.TxPower = mibSet->Param.ChannelsDefaultTxPower;
|
||||
verify.TxPower = mibSet->param.default_channel_tx_pwr;
|
||||
|
||||
if (_lora_phy->verify(&verify, PHY_DEF_TX_POWER) == true) {
|
||||
params->def_sys_params.ChannelsTxPower = verify.TxPower;
|
||||
params->def_sys_params.channel_tx_power = verify.TxPower;
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_TX_POWER: {
|
||||
verify.TxPower = mibSet->Param.ChannelsTxPower;
|
||||
verify.TxPower = mibSet->param.channel_tx_pwr;
|
||||
|
||||
if (_lora_phy->verify(&verify, PHY_TX_POWER) == true) {
|
||||
params->sys_params.ChannelsTxPower = verify.TxPower;
|
||||
params->sys_params.channel_tx_power = verify.TxPower;
|
||||
} else {
|
||||
status = LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
status = LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIB_UPLINK_COUNTER: {
|
||||
params->UpLinkCounter = mibSet->Param.UpLinkCounter;
|
||||
params->ul_frame_counter = mibSet->param.ul_frame_counter;
|
||||
break;
|
||||
}
|
||||
case MIB_DOWNLINK_COUNTER: {
|
||||
params->DownLinkCounter = mibSet->Param.DownLinkCounter;
|
||||
params->dl_frame_counter = mibSet->param.dl_frame_counter;
|
||||
break;
|
||||
}
|
||||
case MIB_SYSTEM_MAX_RX_ERROR: {
|
||||
params->sys_params.SystemMaxRxError =
|
||||
params->def_sys_params.SystemMaxRxError =
|
||||
mibSet->Param.SystemMaxRxError;
|
||||
params->sys_params.max_sys_rx_error =
|
||||
params->def_sys_params.max_sys_rx_error =
|
||||
mibSet->param.max_rx_sys_error;
|
||||
break;
|
||||
}
|
||||
case MIB_MIN_RX_SYMBOLS: {
|
||||
params->sys_params.MinRxSymbols =
|
||||
params->def_sys_params.MinRxSymbols =
|
||||
mibSet->Param.MinRxSymbols;
|
||||
params->sys_params.min_rx_symb =
|
||||
params->def_sys_params.min_rx_symb =
|
||||
mibSet->param.min_rx_symb;
|
||||
break;
|
||||
}
|
||||
case MIB_ANTENNA_GAIN: {
|
||||
params->sys_params.AntennaGain = mibSet->Param.AntennaGain;
|
||||
params->sys_params.antenna_gain = mibSet->param.antenna_gain;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
status = LORAMAC_STATUS_SERVICE_UNKNOWN;
|
||||
status = LORAWAN_STATUS_SERVICE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacMib::get_request(MibRequestConfirm_t *mibGet,
|
||||
lora_mac_protocol_params *params)
|
||||
lorawan_status_t LoRaMacMib::get_request(loramac_mib_req_confirm_t *mibGet,
|
||||
loramac_protocol_params *params)
|
||||
{
|
||||
LoRaMacStatus_t status = LORAMAC_STATUS_OK;
|
||||
lorawan_status_t status = LORAWAN_STATUS_OK;
|
||||
GetPhyParams_t getPhy;
|
||||
PhyParam_t phyParam;
|
||||
|
||||
if( mibGet == NULL )
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
switch( mibGet->Type )
|
||||
switch( mibGet->type )
|
||||
{
|
||||
case MIB_DEVICE_CLASS:
|
||||
{
|
||||
mibGet->Param.Class = params->LoRaMacDeviceClass;
|
||||
mibGet->param.dev_class = params->dev_class;
|
||||
break;
|
||||
}
|
||||
case MIB_NETWORK_JOINED:
|
||||
{
|
||||
mibGet->Param.IsNetworkJoined = params->IsLoRaMacNetworkJoined;
|
||||
mibGet->param.is_nwk_joined = params->is_nwk_joined;
|
||||
break;
|
||||
}
|
||||
case MIB_ADR:
|
||||
{
|
||||
mibGet->Param.AdrEnable = params->sys_params.AdrCtrlOn;
|
||||
mibGet->param.is_adr_enable = params->sys_params.adr_on;
|
||||
break;
|
||||
}
|
||||
case MIB_NET_ID:
|
||||
{
|
||||
mibGet->Param.NetID = params->LoRaMacNetID;
|
||||
mibGet->param.net_id = params->net_id;
|
||||
break;
|
||||
}
|
||||
case MIB_DEV_ADDR:
|
||||
{
|
||||
mibGet->Param.DevAddr = params->LoRaMacDevAddr;
|
||||
mibGet->param.dev_addr = params->dev_addr;
|
||||
break;
|
||||
}
|
||||
case MIB_NWK_SKEY:
|
||||
{
|
||||
mibGet->Param.NwkSKey =params->keys.LoRaMacNwkSKey;
|
||||
mibGet->param.nwk_skey =params->keys.nwk_skey;
|
||||
break;
|
||||
}
|
||||
case MIB_APP_SKEY:
|
||||
{
|
||||
mibGet->Param.AppSKey = params->keys.LoRaMacAppSKey;
|
||||
mibGet->param.app_skey = params->keys.app_skey;
|
||||
break;
|
||||
}
|
||||
case MIB_PUBLIC_NETWORK:
|
||||
{
|
||||
mibGet->Param.EnablePublicNetwork = params->PublicNetwork;
|
||||
mibGet->param.enable_public_nwk = params->is_nwk_public;
|
||||
break;
|
||||
}
|
||||
case MIB_REPEATER_SUPPORT:
|
||||
{
|
||||
mibGet->Param.EnableRepeaterSupport = params->RepeaterSupport;
|
||||
mibGet->param.enable_repeater_support = params->is_repeater_supported;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS:
|
||||
|
@ -357,17 +348,17 @@ LoRaMacStatus_t LoRaMacMib::get_request(MibRequestConfirm_t *mibGet,
|
|||
getPhy.Attribute = PHY_CHANNELS;
|
||||
phyParam = _lora_phy->get_phy_params( &getPhy );
|
||||
|
||||
mibGet->Param.ChannelList = phyParam.Channels;
|
||||
mibGet->param.channel_list = phyParam.Channels;
|
||||
break;
|
||||
}
|
||||
case MIB_RX2_CHANNEL:
|
||||
{
|
||||
mibGet->Param.Rx2Channel = params->sys_params.Rx2Channel;
|
||||
mibGet->param.rx2_channel = params->sys_params.rx2_channel;
|
||||
break;
|
||||
}
|
||||
case MIB_RX2_DEFAULT_CHANNEL:
|
||||
{
|
||||
mibGet->Param.Rx2Channel = params->def_sys_params.Rx2Channel;
|
||||
mibGet->param.rx2_channel = params->def_sys_params.rx2_channel;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_DEFAULT_MASK:
|
||||
|
@ -375,7 +366,7 @@ LoRaMacStatus_t LoRaMacMib::get_request(MibRequestConfirm_t *mibGet,
|
|||
getPhy.Attribute = PHY_CHANNELS_DEFAULT_MASK;
|
||||
phyParam = _lora_phy->get_phy_params( &getPhy );
|
||||
|
||||
mibGet->Param.ChannelsDefaultMask = phyParam.ChannelsMask;
|
||||
mibGet->param.default_channel_mask = phyParam.ChannelsMask;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_MASK:
|
||||
|
@ -383,91 +374,91 @@ LoRaMacStatus_t LoRaMacMib::get_request(MibRequestConfirm_t *mibGet,
|
|||
getPhy.Attribute = PHY_CHANNELS_MASK;
|
||||
phyParam = _lora_phy->get_phy_params( &getPhy );
|
||||
|
||||
mibGet->Param.ChannelsMask = phyParam.ChannelsMask;
|
||||
mibGet->param.channel_mask = phyParam.ChannelsMask;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_NB_REP:
|
||||
{
|
||||
mibGet->Param.ChannelNbRep = params->sys_params.ChannelsNbRep;
|
||||
mibGet->param.channel_nb_rep = params->sys_params.retry_num;
|
||||
break;
|
||||
}
|
||||
case MIB_MAX_RX_WINDOW_DURATION:
|
||||
{
|
||||
mibGet->Param.MaxRxWindow = params->sys_params.MaxRxWindow;
|
||||
mibGet->param.max_rx_window = params->sys_params.max_rx_win_time;
|
||||
break;
|
||||
}
|
||||
case MIB_RECEIVE_DELAY_1:
|
||||
{
|
||||
mibGet->Param.ReceiveDelay1 = params->sys_params.ReceiveDelay1;
|
||||
mibGet->param.recv_delay1 = params->sys_params.recv_delay1;
|
||||
break;
|
||||
}
|
||||
case MIB_RECEIVE_DELAY_2:
|
||||
{
|
||||
mibGet->Param.ReceiveDelay2 = params->sys_params.ReceiveDelay2;
|
||||
mibGet->param.recv_delay2 = params->sys_params.recv_delay2;
|
||||
break;
|
||||
}
|
||||
case MIB_JOIN_ACCEPT_DELAY_1:
|
||||
{
|
||||
mibGet->Param.JoinAcceptDelay1 = params->sys_params.JoinAcceptDelay1;
|
||||
mibGet->param.join_accept_delay1 = params->sys_params.join_accept_delay1;
|
||||
break;
|
||||
}
|
||||
case MIB_JOIN_ACCEPT_DELAY_2:
|
||||
{
|
||||
mibGet->Param.JoinAcceptDelay2 = params->sys_params.JoinAcceptDelay2;
|
||||
mibGet->param.join_accept_delay2 = params->sys_params.join_accept_delay2;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_DEFAULT_DATARATE:
|
||||
{
|
||||
mibGet->Param.ChannelsDefaultDatarate = params->def_sys_params.ChannelsDatarate;
|
||||
mibGet->param.default_channel_data_rate = params->def_sys_params.channel_data_rate;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_DATARATE:
|
||||
{
|
||||
mibGet->Param.ChannelsDatarate = params->sys_params.ChannelsDatarate;
|
||||
mibGet->param.channel_data_rate = params->sys_params.channel_data_rate;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_DEFAULT_TX_POWER:
|
||||
{
|
||||
mibGet->Param.ChannelsDefaultTxPower = params->def_sys_params.ChannelsTxPower;
|
||||
mibGet->param.default_channel_tx_pwr = params->def_sys_params.channel_tx_power;
|
||||
break;
|
||||
}
|
||||
case MIB_CHANNELS_TX_POWER:
|
||||
{
|
||||
mibGet->Param.ChannelsTxPower = params->sys_params.ChannelsTxPower;
|
||||
mibGet->param.channel_tx_pwr = params->sys_params.channel_tx_power;
|
||||
break;
|
||||
}
|
||||
case MIB_UPLINK_COUNTER:
|
||||
{
|
||||
mibGet->Param.UpLinkCounter = params->UpLinkCounter;
|
||||
mibGet->param.ul_frame_counter = params->ul_frame_counter;
|
||||
break;
|
||||
}
|
||||
case MIB_DOWNLINK_COUNTER:
|
||||
{
|
||||
mibGet->Param.DownLinkCounter = params->DownLinkCounter;
|
||||
mibGet->param.dl_frame_counter = params->dl_frame_counter;
|
||||
break;
|
||||
}
|
||||
case MIB_MULTICAST_CHANNEL:
|
||||
{
|
||||
mibGet->Param.MulticastList = params->MulticastChannels;
|
||||
mibGet->param.multicast_list = params->multicast_channels;
|
||||
break;
|
||||
}
|
||||
case MIB_SYSTEM_MAX_RX_ERROR:
|
||||
{
|
||||
mibGet->Param.SystemMaxRxError = params->sys_params.SystemMaxRxError;
|
||||
mibGet->param.max_rx_sys_error = params->sys_params.max_sys_rx_error;
|
||||
break;
|
||||
}
|
||||
case MIB_MIN_RX_SYMBOLS:
|
||||
{
|
||||
mibGet->Param.MinRxSymbols = params->sys_params.MinRxSymbols;
|
||||
mibGet->param.min_rx_symb = params->sys_params.min_rx_symb;
|
||||
break;
|
||||
}
|
||||
case MIB_ANTENNA_GAIN:
|
||||
{
|
||||
mibGet->Param.AntennaGain = params->sys_params.AntennaGain;
|
||||
mibGet->param.antenna_gain = params->sys_params.antenna_gain;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
status = LORAMAC_STATUS_SERVICE_UNKNOWN;
|
||||
status = LORAWAN_STATUS_SERVICE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,10 +67,11 @@ public:
|
|||
* @param mibSet [in] pointer to MIB request structure
|
||||
* @param params pointer to MAC protocol parameters which will be modified
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well otherwise
|
||||
* a negative error code is returned.
|
||||
*/
|
||||
LoRaMacStatus_t set_request(MibRequestConfirm_t *mibSet, lora_mac_protocol_params *params);
|
||||
lorawan_status_t set_request(loramac_mib_req_confirm_t *mibSet,
|
||||
loramac_protocol_params *params);
|
||||
|
||||
/** Provides access to the given MIB parameter
|
||||
*
|
||||
|
@ -80,10 +81,11 @@ public:
|
|||
* @param mibGet [out] pointer to MIB request structure which will be filled in
|
||||
* @param params pointer to MAC protocol parameters
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well otherwise
|
||||
* a negative error code is returned.
|
||||
*/
|
||||
LoRaMacStatus_t get_request(MibRequestConfirm_t *mibGet, lora_mac_protocol_params *params);
|
||||
lorawan_status_t get_request(loramac_mib_req_confirm_t *mibGet,
|
||||
loramac_protocol_params *params);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -43,111 +43,111 @@ void LoRaMacMlme::activate_mlme_subsystem(LoRaMac *mac, LoRaPHY *phy,
|
|||
_mac_cmd = cmd;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacMlme::set_request(MlmeReq_t *mlmeRequest,
|
||||
lora_mac_protocol_params *params)
|
||||
lorawan_status_t LoRaMacMlme::set_request(loramac_mlme_req_t *mlmeRequest,
|
||||
loramac_protocol_params *params)
|
||||
{
|
||||
if (mlmeRequest && params && _lora_mac && _lora_phy && _mac_cmd) {
|
||||
|
||||
LoRaMacStatus_t status = LORAMAC_STATUS_SERVICE_UNKNOWN;
|
||||
LoRaMacHeader_t macHdr;
|
||||
lorawan_status_t status = LORAWAN_STATUS_SERVICE_UNKNOWN;
|
||||
loramac_mhdr_t macHdr;
|
||||
AlternateDrParams_t altDr;
|
||||
VerifyParams_t verify;
|
||||
GetPhyParams_t getPhy;
|
||||
PhyParam_t phyParam;
|
||||
|
||||
|
||||
if (params->LoRaMacState != LORAMAC_IDLE) {
|
||||
return LORAMAC_STATUS_BUSY;
|
||||
if (params->mac_state != LORAMAC_IDLE) {
|
||||
return LORAWAN_STATUS_BUSY;
|
||||
}
|
||||
|
||||
// Before setting a new MLME request, clear the MLME confirmation
|
||||
// structure
|
||||
memset((uint8_t*) &confirmation, 0, sizeof(confirmation));
|
||||
|
||||
confirmation.Status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
||||
confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
||||
|
||||
switch (mlmeRequest->Type) {
|
||||
switch (mlmeRequest->type) {
|
||||
case MLME_JOIN: {
|
||||
if ((params->LoRaMacState & LORAMAC_TX_DELAYED)
|
||||
if ((params->mac_state & LORAMAC_TX_DELAYED)
|
||||
== LORAMAC_TX_DELAYED) {
|
||||
return LORAMAC_STATUS_BUSY;
|
||||
return LORAWAN_STATUS_BUSY;
|
||||
}
|
||||
|
||||
if ((mlmeRequest->Req.Join.DevEui == NULL)
|
||||
|| (mlmeRequest->Req.Join.AppEui == NULL)
|
||||
|| (mlmeRequest->Req.Join.AppKey == NULL)
|
||||
|| (mlmeRequest->Req.Join.NbTrials == 0)) {
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
if ((mlmeRequest->req.join.dev_eui == NULL)
|
||||
|| (mlmeRequest->req.join.app_eui == NULL)
|
||||
|| (mlmeRequest->req.join.app_key == NULL)
|
||||
|| (mlmeRequest->req.join.nb_trials == 0)) {
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
// Verify the parameter NbTrials for the join procedure
|
||||
verify.NbJoinTrials = mlmeRequest->Req.Join.NbTrials;
|
||||
verify.NbJoinTrials = mlmeRequest->req.join.nb_trials;
|
||||
|
||||
if (_lora_phy->verify(&verify, PHY_NB_JOIN_TRIALS) == false) {
|
||||
// Value not supported, get default
|
||||
getPhy.Attribute = PHY_DEF_NB_JOIN_TRIALS;
|
||||
phyParam = _lora_phy->get_phy_params(&getPhy);
|
||||
mlmeRequest->Req.Join.NbTrials = (uint8_t) phyParam.Value;
|
||||
mlmeRequest->req.join.nb_trials = (uint8_t) phyParam.Value;
|
||||
}
|
||||
|
||||
params->LoRaMacFlags.Bits.MlmeReq = 1;
|
||||
confirmation.MlmeRequest = mlmeRequest->Type;
|
||||
params->flags.bits.mlme_req = 1;
|
||||
confirmation.req_type = mlmeRequest->type;
|
||||
|
||||
params->keys.LoRaMacDevEui = mlmeRequest->Req.Join.DevEui;
|
||||
params->keys.LoRaMacAppEui = mlmeRequest->Req.Join.AppEui;
|
||||
params->keys.LoRaMacAppKey = mlmeRequest->Req.Join.AppKey;
|
||||
params->MaxJoinRequestTrials = mlmeRequest->Req.Join.NbTrials;
|
||||
params->keys.dev_eui = mlmeRequest->req.join.dev_eui;
|
||||
params->keys.app_eui = mlmeRequest->req.join.app_eui;
|
||||
params->keys.app_key = mlmeRequest->req.join.app_key;
|
||||
params->max_join_request_trials = mlmeRequest->req.join.nb_trials;
|
||||
|
||||
// Reset variable JoinRequestTrials
|
||||
params->JoinRequestTrials = 0;
|
||||
params->join_request_trial_counter = 0;
|
||||
|
||||
// Setup header information
|
||||
macHdr.Value = 0;
|
||||
macHdr.Bits.MType = FRAME_TYPE_JOIN_REQ;
|
||||
macHdr.value = 0;
|
||||
macHdr.bits.mtype = FRAME_TYPE_JOIN_REQ;
|
||||
|
||||
_lora_mac->ResetMacParameters();
|
||||
|
||||
altDr.NbTrials = params->JoinRequestTrials + 1;
|
||||
altDr.NbTrials = params->join_request_trial_counter + 1;
|
||||
|
||||
params->sys_params.ChannelsDatarate =
|
||||
params->sys_params.channel_data_rate =
|
||||
_lora_phy->get_alternate_DR(&altDr);
|
||||
|
||||
status = _lora_mac->Send(&macHdr, 0, NULL, 0);
|
||||
break;
|
||||
}
|
||||
case MLME_LINK_CHECK: {
|
||||
params->LoRaMacFlags.Bits.MlmeReq = 1;
|
||||
params->flags.bits.mlme_req = 1;
|
||||
// LoRaMac will send this command piggy-backed
|
||||
confirmation.MlmeRequest = mlmeRequest->Type;
|
||||
confirmation.req_type = mlmeRequest->type;
|
||||
|
||||
status = _mac_cmd->AddMacCommand(MOTE_MAC_LINK_CHECK_REQ, 0, 0);
|
||||
break;
|
||||
}
|
||||
case MLME_TXCW: {
|
||||
confirmation.MlmeRequest = mlmeRequest->Type;
|
||||
params->LoRaMacFlags.Bits.MlmeReq = 1;
|
||||
status = _lora_mac->SetTxContinuousWave(mlmeRequest->Req.TxCw.Timeout);
|
||||
confirmation.req_type = mlmeRequest->type;
|
||||
params->flags.bits.mlme_req = 1;
|
||||
status = _lora_mac->SetTxContinuousWave(mlmeRequest->req.cw_tx_mode.timeout);
|
||||
break;
|
||||
}
|
||||
case MLME_TXCW_1: {
|
||||
confirmation.MlmeRequest = mlmeRequest->Type;
|
||||
params->LoRaMacFlags.Bits.MlmeReq = 1;
|
||||
status = _lora_mac->SetTxContinuousWave1(mlmeRequest->Req.TxCw.Timeout,
|
||||
mlmeRequest->Req.TxCw.Frequency,
|
||||
mlmeRequest->Req.TxCw.Power);
|
||||
confirmation.req_type = mlmeRequest->type;
|
||||
params->flags.bits.mlme_req = 1;
|
||||
status = _lora_mac->SetTxContinuousWave1(mlmeRequest->req.cw_tx_mode.timeout,
|
||||
mlmeRequest->req.cw_tx_mode.frequency,
|
||||
mlmeRequest->req.cw_tx_mode.power);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (status != LORAMAC_STATUS_OK) {
|
||||
params->NodeAckRequested = false;
|
||||
params->LoRaMacFlags.Bits.MlmeReq = 0;
|
||||
if (status != LORAWAN_STATUS_OK) {
|
||||
params->is_node_ack_requested = false;
|
||||
params->flags.bits.mlme_req = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
|
|
@ -69,16 +69,16 @@ public:
|
|||
* @param mlmeRequest pointer to MLME request structure
|
||||
* @param params pointer to MAC protocol parameters
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well otherwise
|
||||
* a negative error code is returned.
|
||||
*/
|
||||
LoRaMacStatus_t set_request(MlmeReq_t *mlmeRequest, lora_mac_protocol_params *params);
|
||||
lorawan_status_t set_request(loramac_mlme_req_t *mlmeRequest, loramac_protocol_params *params);
|
||||
|
||||
/** Grants access to MLME confirmation data
|
||||
*
|
||||
* @return a reference to MLME confirm data structure
|
||||
*/
|
||||
inline MlmeConfirm_t& get_confirmation()
|
||||
inline loramac_mlme_confirm_t& get_confirmation()
|
||||
{
|
||||
return confirmation;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
*
|
||||
* @return a reference to MLME indication data structure
|
||||
*/
|
||||
inline MlmeIndication_t& get_indication()
|
||||
inline loramac_mlme_indication_t& get_indication()
|
||||
{
|
||||
return indication;
|
||||
}
|
||||
|
@ -104,12 +104,12 @@ private:
|
|||
/**
|
||||
* Structure to hold MLME indication data.
|
||||
*/
|
||||
MlmeIndication_t indication;
|
||||
loramac_mlme_indication_t indication;
|
||||
|
||||
/**
|
||||
* Structure to hold MLME confirm data.
|
||||
*/
|
||||
MlmeConfirm_t confirmation;
|
||||
loramac_mlme_confirm_t confirmation;
|
||||
};
|
||||
|
||||
#endif /* MBED_OS_LORAWAN_MAC_MLME_H_ */
|
||||
|
|
|
@ -128,7 +128,7 @@ int32_t LoRaPHY::get_random(int32_t min, int32_t max)
|
|||
return (int32_t) rand() % (max - min + 1) + min;
|
||||
}
|
||||
|
||||
uint16_t LoRaPHY::get_join_DC( TimerTime_t elapsedTime )
|
||||
uint16_t LoRaPHY::get_join_DC( lorawan_time_t elapsedTime )
|
||||
{
|
||||
uint16_t dutyCycle = 0;
|
||||
|
||||
|
@ -147,7 +147,7 @@ uint16_t LoRaPHY::get_join_DC( TimerTime_t elapsedTime )
|
|||
return dutyCycle;
|
||||
}
|
||||
|
||||
bool LoRaPHY::verify_channel_DR( uint8_t nbChannels, uint16_t* channelsMask, int8_t dr, int8_t minDr, int8_t maxDr, ChannelParams_t* channels )
|
||||
bool LoRaPHY::verify_channel_DR( uint8_t nbChannels, uint16_t* channelsMask, int8_t dr, int8_t minDr, int8_t maxDr, channel_params_t* channels )
|
||||
{
|
||||
if( val_in_range( dr, minDr, maxDr ) == 0 )
|
||||
{
|
||||
|
@ -160,8 +160,8 @@ bool LoRaPHY::verify_channel_DR( uint8_t nbChannels, uint16_t* channelsMask, int
|
|||
{
|
||||
if( ( ( channelsMask[k] & ( 1 << j ) ) != 0 ) )
|
||||
{// Check datarate validity for enabled channels
|
||||
if( val_in_range( dr, ( channels[i + j].DrRange.Fields.Min & 0x0F ),
|
||||
( channels[i + j].DrRange.Fields.Max & 0x0F ) ) == 1 )
|
||||
if( val_in_range( dr, ( channels[i + j].dr_range.fields.min & 0x0F ),
|
||||
( channels[i + j].dr_range.fields.max & 0x0F ) ) == 1 )
|
||||
{
|
||||
// At least 1 channel has been found we can return OK.
|
||||
return true;
|
||||
|
@ -224,58 +224,58 @@ void LoRaPHY::copy_channel_mask( uint16_t* channelsMaskDest, uint16_t* channelsM
|
|||
}
|
||||
}
|
||||
|
||||
void LoRaPHY::set_last_tx_done( bool joined, Band_t* band, TimerTime_t lastTxDone )
|
||||
void LoRaPHY::set_last_tx_done( bool joined, band_t* band, lorawan_time_t lastTxDone )
|
||||
{
|
||||
if( joined == true )
|
||||
{
|
||||
band->LastTxDoneTime = lastTxDone;
|
||||
band->last_tx_time = lastTxDone;
|
||||
}
|
||||
else
|
||||
{
|
||||
band->LastTxDoneTime = lastTxDone;
|
||||
band->LastJoinTxDoneTime = lastTxDone;
|
||||
band->last_tx_time = lastTxDone;
|
||||
band->last_join_tx_time = lastTxDone;
|
||||
}
|
||||
}
|
||||
|
||||
TimerTime_t LoRaPHY::update_band_timeoff( bool joined, bool dutyCycle, Band_t* bands, uint8_t nbBands )
|
||||
lorawan_time_t LoRaPHY::update_band_timeoff( bool joined, bool dutyCycle, band_t* bands, uint8_t nbBands )
|
||||
{
|
||||
TimerTime_t nextTxDelay = ( TimerTime_t )( -1 );
|
||||
lorawan_time_t nextTxDelay = ( lorawan_time_t )( -1 );
|
||||
|
||||
// Update bands Time OFF
|
||||
for( uint8_t i = 0; i < nbBands; i++ )
|
||||
{
|
||||
if( joined == false )
|
||||
{
|
||||
uint32_t txDoneTime = MAX( _lora_time.TimerGetElapsedTime( bands[i].LastJoinTxDoneTime ),
|
||||
( dutyCycle == true ) ? _lora_time.TimerGetElapsedTime( bands[i].LastTxDoneTime ) : 0 );
|
||||
uint32_t txDoneTime = MAX( _lora_time.TimerGetElapsedTime( bands[i].last_join_tx_time ),
|
||||
( dutyCycle == true ) ? _lora_time.TimerGetElapsedTime( bands[i].last_tx_time ) : 0 );
|
||||
|
||||
if( bands[i].TimeOff <= txDoneTime )
|
||||
if( bands[i].off_time <= txDoneTime )
|
||||
{
|
||||
bands[i].TimeOff = 0;
|
||||
bands[i].off_time = 0;
|
||||
}
|
||||
if( bands[i].TimeOff != 0 )
|
||||
if( bands[i].off_time != 0 )
|
||||
{
|
||||
nextTxDelay = MIN( bands[i].TimeOff - txDoneTime, nextTxDelay );
|
||||
nextTxDelay = MIN( bands[i].off_time - txDoneTime, nextTxDelay );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dutyCycle == true )
|
||||
{
|
||||
if( bands[i].TimeOff <= _lora_time.TimerGetElapsedTime( bands[i].LastTxDoneTime ) )
|
||||
if( bands[i].off_time <= _lora_time.TimerGetElapsedTime( bands[i].last_tx_time ) )
|
||||
{
|
||||
bands[i].TimeOff = 0;
|
||||
bands[i].off_time = 0;
|
||||
}
|
||||
if( bands[i].TimeOff != 0 )
|
||||
if( bands[i].off_time != 0 )
|
||||
{
|
||||
nextTxDelay = MIN( bands[i].TimeOff - _lora_time.TimerGetElapsedTime( bands[i].LastTxDoneTime ),
|
||||
nextTxDelay = MIN( bands[i].off_time - _lora_time.TimerGetElapsedTime( bands[i].last_tx_time ),
|
||||
nextTxDelay );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nextTxDelay = 0;
|
||||
bands[i].TimeOff = 0;
|
||||
bands[i].off_time = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -396,12 +396,12 @@ int8_t LoRaPHY::compute_tx_power( int8_t txPowerIndex, float maxEirp, float ante
|
|||
|
||||
void LoRaPHY::get_DC_backoff( RegionCommonCalcBackOffParams_t* calcBackOffParams )
|
||||
{
|
||||
uint8_t bandIdx = calcBackOffParams->Channels[calcBackOffParams->Channel].Band;
|
||||
uint16_t dutyCycle = calcBackOffParams->Bands[bandIdx].DCycle;
|
||||
uint8_t bandIdx = calcBackOffParams->Channels[calcBackOffParams->Channel].band;
|
||||
uint16_t dutyCycle = calcBackOffParams->Bands[bandIdx].duty_cycle;
|
||||
uint16_t joinDutyCycle = 0;
|
||||
|
||||
// Reset time-off to initial value.
|
||||
calcBackOffParams->Bands[bandIdx].TimeOff = 0;
|
||||
calcBackOffParams->Bands[bandIdx].off_time = 0;
|
||||
|
||||
if( calcBackOffParams->Joined == false )
|
||||
{
|
||||
|
@ -416,23 +416,23 @@ void LoRaPHY::get_DC_backoff( RegionCommonCalcBackOffParams_t* calcBackOffParams
|
|||
// This could happen in case of a rejoin, e.g. in compliance test mode.
|
||||
// In this special case we have to set the time off to 0, since the join duty cycle shall only
|
||||
// be applied after the first join request.
|
||||
calcBackOffParams->Bands[bandIdx].TimeOff = 0;
|
||||
calcBackOffParams->Bands[bandIdx].off_time = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply band time-off.
|
||||
calcBackOffParams->Bands[bandIdx].TimeOff = calcBackOffParams->TxTimeOnAir * dutyCycle - calcBackOffParams->TxTimeOnAir;
|
||||
calcBackOffParams->Bands[bandIdx].off_time = calcBackOffParams->TxTimeOnAir * dutyCycle - calcBackOffParams->TxTimeOnAir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( calcBackOffParams->DutyCycleEnabled == true )
|
||||
{
|
||||
calcBackOffParams->Bands[bandIdx].TimeOff = calcBackOffParams->TxTimeOnAir * dutyCycle - calcBackOffParams->TxTimeOnAir;
|
||||
calcBackOffParams->Bands[bandIdx].off_time = calcBackOffParams->TxTimeOnAir * dutyCycle - calcBackOffParams->TxTimeOnAir;
|
||||
}
|
||||
else
|
||||
{
|
||||
calcBackOffParams->Bands[bandIdx].TimeOff = 0;
|
||||
calcBackOffParams->Bands[bandIdx].off_time = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate ) = 0;
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate ) = 0;
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -193,7 +193,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams) = 0;
|
||||
rx_config_params_t *rxConfigParams) = 0;
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
*
|
||||
|
@ -206,7 +206,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir ) = 0;
|
||||
lorawan_time_t* txTimeOnAir ) = 0;
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR Request.
|
||||
|
@ -296,8 +296,8 @@ public:
|
|||
* \retval Function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff ) = 0;
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff ) = 0;
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -306,7 +306,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd ) = 0;
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd ) = 0;
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -418,7 +418,7 @@ protected:
|
|||
/*!
|
||||
* A pointer to the channels.
|
||||
*/
|
||||
ChannelParams_t* Channels;
|
||||
channel_params_t* Channels;
|
||||
/*!
|
||||
* The minimum possible TX power.
|
||||
*/
|
||||
|
@ -434,11 +434,11 @@ protected:
|
|||
/*!
|
||||
* A pointer to region specific channels.
|
||||
*/
|
||||
ChannelParams_t* Channels;
|
||||
channel_params_t* Channels;
|
||||
/*!
|
||||
* A pointer to region specific bands.
|
||||
*/
|
||||
Band_t* Bands;
|
||||
band_t* Bands;
|
||||
/*!
|
||||
* Set to true, if the last uplink was a join request.
|
||||
*/
|
||||
|
@ -458,11 +458,11 @@ protected:
|
|||
/*!
|
||||
* The elapsed time since initialization.
|
||||
*/
|
||||
TimerTime_t ElapsedTime;
|
||||
lorawan_time_t ElapsedTime;
|
||||
/*!
|
||||
* The time on air of the last TX frame.
|
||||
*/
|
||||
TimerTime_t TxTimeOnAir;
|
||||
lorawan_time_t TxTimeOnAir;
|
||||
}RegionCommonCalcBackOffParams_t;
|
||||
|
||||
/*!
|
||||
|
@ -473,7 +473,7 @@ protected:
|
|||
*
|
||||
* \retval Duty cycle restriction.
|
||||
*/
|
||||
uint16_t get_join_DC( TimerTime_t elapsedTime );
|
||||
uint16_t get_join_DC( lorawan_time_t elapsedTime );
|
||||
|
||||
/*!
|
||||
* \brief Verifies, if a value is in a given range.
|
||||
|
@ -508,7 +508,7 @@ protected:
|
|||
* \retval True if the datarate is supported, false if not.
|
||||
*/
|
||||
bool verify_channel_DR( uint8_t nbChannels, uint16_t* channelsMask, int8_t dr,
|
||||
int8_t minDr, int8_t maxDr, ChannelParams_t* channels );
|
||||
int8_t minDr, int8_t maxDr, channel_params_t* channels );
|
||||
|
||||
/*!
|
||||
* \brief Disables a channel in a given channels mask.
|
||||
|
@ -560,7 +560,7 @@ protected:
|
|||
*
|
||||
* \param [in] lastTxDone The time of the last TX done.
|
||||
*/
|
||||
void set_last_tx_done( bool joined, Band_t* band, TimerTime_t lastTxDone );
|
||||
void set_last_tx_done( bool joined, band_t* band, lorawan_time_t lastTxDone );
|
||||
|
||||
/*!
|
||||
* \brief Updates the time-offs of the bands.
|
||||
|
@ -576,7 +576,7 @@ protected:
|
|||
*
|
||||
* \retval The time which must be waited to perform the next uplink.
|
||||
*/
|
||||
TimerTime_t update_band_timeoff( bool joined, bool dutyCycle, Band_t* bands, uint8_t nbBands );
|
||||
lorawan_time_t update_band_timeoff( bool joined, bool dutyCycle, band_t* bands, uint8_t nbBands );
|
||||
|
||||
/*!
|
||||
* \brief Parses the parameter of an LinkAdrRequest.
|
||||
|
|
|
@ -321,7 +321,7 @@ static bool VerifyTxFreq( uint32_t freq )
|
|||
|
||||
uint8_t LoRaPHYAS923::CountNbOfEnabledChannels(bool joined, uint8_t datarate,
|
||||
uint16_t* channelsMask,
|
||||
ChannelParams_t* channels, Band_t* bands,
|
||||
channel_params_t* channels, band_t* bands,
|
||||
uint8_t* enabledChannels, uint8_t* delayTx)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
|
@ -333,7 +333,7 @@ uint8_t LoRaPHYAS923::CountNbOfEnabledChannels(bool joined, uint8_t datarate,
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
|
@ -344,12 +344,12 @@ uint8_t LoRaPHYAS923::CountNbOfEnabledChannels(bool joined, uint8_t datarate,
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -366,7 +366,7 @@ uint8_t LoRaPHYAS923::CountNbOfEnabledChannels(bool joined, uint8_t datarate,
|
|||
LoRaPHYAS923::LoRaPHYAS923(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = AS923_BAND0;
|
||||
const band_t band0 = AS923_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ PhyParam_t LoRaPHYAS923::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYAS923::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYAS923::load_defaults(InitType_t type)
|
||||
|
@ -572,8 +572,8 @@ void LoRaPHYAS923::load_defaults(InitType_t type)
|
|||
case INIT_TYPE_INIT:
|
||||
{
|
||||
// Channels
|
||||
const ChannelParams_t channel1 = AS923_LC1;
|
||||
const ChannelParams_t channel2 = AS923_LC2;
|
||||
const channel_params_t channel1 = AS923_LC1;
|
||||
const channel_params_t channel2 = AS923_LC2;
|
||||
Channels[0] = channel1;
|
||||
Channels[1] = channel2;
|
||||
|
||||
|
@ -647,12 +647,12 @@ bool LoRaPHYAS923::verify(VerifyParams_t* verify, PhyAttribute_t phyAttribute)
|
|||
|
||||
void LoRaPHYAS923::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
||||
{
|
||||
ChannelParams_t newChannel;
|
||||
channel_params_t newChannel;
|
||||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
// Setup default datarate range
|
||||
newChannel.DrRange.Value = ( DR_5 << 4 ) | DR_0;
|
||||
newChannel.dr_range.value = ( DR_5 << 4 ) | DR_0;
|
||||
|
||||
// Size of the optional CF list
|
||||
if( applyCFList->Size != 16 )
|
||||
|
@ -666,22 +666,22 @@ void LoRaPHYAS923::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
|||
if( chanIdx < ( AS923_NUMB_CHANNELS_CF_LIST + AS923_NUMB_DEFAULT_CHANNELS ) )
|
||||
{
|
||||
// Channel frequency
|
||||
newChannel.Frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.Frequency *= 100;
|
||||
newChannel.frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.frequency *= 100;
|
||||
|
||||
// Initialize alternative frequency to 0
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
newChannel.Frequency = 0;
|
||||
newChannel.DrRange.Value = 0;
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.frequency = 0;
|
||||
newChannel.dr_range.value = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
|
||||
if( newChannel.Frequency != 0 )
|
||||
if( newChannel.frequency != 0 )
|
||||
{
|
||||
channelAdd.NewChannel = &newChannel;
|
||||
channelAdd.ChannelId = chanIdx;
|
||||
|
@ -791,47 +791,47 @@ bool LoRaPHYAS923::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYAS923::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, AS923_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, AS923_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
if( rxConfigParams->Datarate == DR_7 )
|
||||
if( rxConfigParams->datarate == DR_7 )
|
||||
{ // FSK
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesAS923[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesAS923[rxConfigParams->datarate] );
|
||||
}
|
||||
else
|
||||
{ // LoRa
|
||||
tSymbol = compute_symb_timeout_lora( DataratesAS923[rxConfigParams->Datarate], BandwidthsAS923[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesAS923[rxConfigParams->datarate], BandwidthsAS923[rxConfigParams->datarate] );
|
||||
}
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYAS923::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYAS923::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if( _radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1 )
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = Channels[rxConfig->Channel].Frequency;
|
||||
frequency = Channels[rxConfig->channel].frequency;
|
||||
// Apply the alternative RX 1 window frequency, if it is available
|
||||
if( Channels[rxConfig->Channel].Rx1Frequency != 0 )
|
||||
if( Channels[rxConfig->channel].rx1_frequency != 0 )
|
||||
{
|
||||
frequency = Channels[rxConfig->Channel].Rx1Frequency;
|
||||
frequency = Channels[rxConfig->channel].rx1_frequency;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -845,19 +845,19 @@ bool LoRaPHYAS923::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
{
|
||||
modem = MODEM_FSK;
|
||||
_radio->set_rx_config(modem, 50000, phyDr * 1000, 0, 83333, 5,
|
||||
rxConfig->WindowTimeout, false, 0, true, 0,
|
||||
0, false, rxConfig->RxContinuous);
|
||||
rxConfig->window_timeout, false, 0, true, 0,
|
||||
0, false, rxConfig->is_rx_continuous);
|
||||
}
|
||||
else
|
||||
{
|
||||
modem = MODEM_LORA;
|
||||
_radio->set_rx_config(modem, rxConfig->Bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->WindowTimeout, false, 0, false, 0, 0,
|
||||
true, rxConfig->RxContinuous);
|
||||
_radio->set_rx_config(modem, rxConfig->bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->window_timeout, false, 0, false, 0, 0,
|
||||
true, rxConfig->is_rx_continuous);
|
||||
}
|
||||
|
||||
// Check for repeater support
|
||||
if( rxConfig->RepeaterSupport == true )
|
||||
if( rxConfig->is_repeater_supported == true )
|
||||
{
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterDwell0AS923[dr];
|
||||
}
|
||||
|
@ -873,11 +873,11 @@ bool LoRaPHYAS923::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
}
|
||||
|
||||
bool LoRaPHYAS923::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir)
|
||||
lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t phyDr = DataratesAS923[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
|
@ -885,7 +885,7 @@ bool LoRaPHYAS923::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
|||
phyTxPower = compute_tx_power( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel(Channels[txConfig->Channel].Frequency);
|
||||
_radio->set_channel(Channels[txConfig->Channel].frequency);
|
||||
|
||||
if( txConfig->Datarate == DR_7 )
|
||||
{ // High Speed FSK channel
|
||||
|
@ -956,7 +956,7 @@ uint8_t LoRaPHYAS923::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
{
|
||||
if( linkAdrParams.ChMaskCtrl == 6 )
|
||||
{
|
||||
if( Channels[i].Frequency != 0 )
|
||||
if( Channels[i].frequency != 0 )
|
||||
{
|
||||
chMask |= 1 << i;
|
||||
}
|
||||
|
@ -964,7 +964,7 @@ uint8_t LoRaPHYAS923::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
else
|
||||
{
|
||||
if( ( ( chMask & ( 1 << i ) ) != 0 ) &&
|
||||
( Channels[i].Frequency == 0 ) )
|
||||
( Channels[i].frequency == 0 ) )
|
||||
{// Trying to enable an undefined channel
|
||||
status &= 0xFE; // Channel mask KO
|
||||
}
|
||||
|
@ -1046,7 +1046,7 @@ uint8_t LoRaPHYAS923::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
if( newChannelReq->NewChannel->Frequency == 0 )
|
||||
if( newChannelReq->NewChannel->frequency == 0 )
|
||||
{
|
||||
channelRemove.ChannelId = newChannelReq->ChannelId;
|
||||
|
||||
|
@ -1063,21 +1063,21 @@ uint8_t LoRaPHYAS923::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
|
||||
switch( add_channel (&channelAdd ))
|
||||
{
|
||||
case LORAMAC_STATUS_OK:
|
||||
case LORAWAN_STATUS_OK:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQUENCY_INVALID:
|
||||
case LORAWAN_STATUS_FREQUENCY_INVALID:
|
||||
{
|
||||
status &= 0xFE;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_DATARATE_INVALID:
|
||||
case LORAWAN_STATUS_DATARATE_INVALID:
|
||||
{
|
||||
status &= 0xFD;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQ_AND_DR_INVALID:
|
||||
case LORAWAN_STATUS_FREQ_AND_DR_INVALID:
|
||||
{
|
||||
status &= 0xFC;
|
||||
break;
|
||||
|
@ -1110,7 +1110,7 @@ uint8_t LoRaPHYAS923::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
}
|
||||
|
||||
// Verify if an uplink frequency exists
|
||||
if( Channels[dlChannelReq->ChannelId].Frequency == 0 )
|
||||
if( Channels[dlChannelReq->ChannelId].frequency == 0 )
|
||||
{
|
||||
status &= 0xFD;
|
||||
}
|
||||
|
@ -1118,7 +1118,7 @@ uint8_t LoRaPHYAS923::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
// Apply Rx1 frequency, if the status is OK
|
||||
if( status == 0x03 )
|
||||
{
|
||||
Channels[dlChannelReq->ChannelId].Rx1Frequency = dlChannelReq->Rx1Frequency;
|
||||
Channels[dlChannelReq->ChannelId].rx1_frequency = dlChannelReq->Rx1Frequency;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1147,14 +1147,14 @@ void LoRaPHYAS923::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYAS923::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t channelNext = 0;
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[AS923_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
if( num_active_channels( ChannelsMask, 0, 1 ) == 0 )
|
||||
{ // Reactivate default channels
|
||||
|
@ -1190,7 +1190,7 @@ bool LoRaPHYAS923::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
// Perform carrier sense for AS923_CARRIER_SENSE_TIME
|
||||
// If the channel is free, we can stop the LBT mechanism
|
||||
if( _radio->perform_carrier_sense(MODEM_LORA,
|
||||
Channels[channelNext].Frequency,
|
||||
Channels[channelNext].frequency,
|
||||
AS923_RSSI_FREE_TH,
|
||||
AS923_CARRIER_SENSE_TIME ) == true)
|
||||
{
|
||||
|
@ -1217,7 +1217,7 @@ bool LoRaPHYAS923::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYAS923::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYAS923::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
uint8_t band = 0;
|
||||
bool drInvalid = false;
|
||||
|
@ -1226,19 +1226,19 @@ LoRaMacStatus_t LoRaPHYAS923::add_channel(ChannelAddParams_t* channelAdd)
|
|||
|
||||
if( id >= AS923_MAX_NB_CHANNELS )
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
// Validate the datarate range
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Min, AS923_TX_MIN_DATARATE, AS923_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.min, AS923_TX_MIN_DATARATE, AS923_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, AS923_TX_MIN_DATARATE, AS923_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, AS923_TX_MIN_DATARATE, AS923_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > channelAdd->NewChannel->dr_range.fields.max )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
|
@ -1247,17 +1247,17 @@ LoRaMacStatus_t LoRaPHYAS923::add_channel(ChannelAddParams_t* channelAdd)
|
|||
if( id < AS923_NUMB_DEFAULT_CHANNELS )
|
||||
{
|
||||
// Validate the datarate range for min: must be DR_0
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > DR_0 )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > DR_0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// Validate the datarate range for max: must be DR_5 <= Max <= TX_MAX_DATARATE
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, DR_5, AS923_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, DR_5, AS923_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// We are not allowed to change the frequency
|
||||
if( channelAdd->NewChannel->Frequency != Channels[id].Frequency )
|
||||
if( channelAdd->NewChannel->frequency != Channels[id].frequency )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1266,7 +1266,7 @@ LoRaMacStatus_t LoRaPHYAS923::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check frequency
|
||||
if( freqInvalid == false )
|
||||
{
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->Frequency ) == false )
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->frequency ) == false )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1275,21 +1275,21 @@ LoRaMacStatus_t LoRaPHYAS923::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check status
|
||||
if( ( drInvalid == true ) && ( freqInvalid == true ) )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQ_AND_DR_INVALID;
|
||||
return LORAWAN_STATUS_FREQ_AND_DR_INVALID;
|
||||
}
|
||||
if( drInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_DATARATE_INVALID;
|
||||
return LORAWAN_STATUS_DATARATE_INVALID;
|
||||
}
|
||||
if( freqInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQUENCY_INVALID;
|
||||
return LORAWAN_STATUS_FREQUENCY_INVALID;
|
||||
}
|
||||
|
||||
memcpy( &(Channels[id]), channelAdd->NewChannel, sizeof( Channels[id] ) );
|
||||
Channels[id].Band = band;
|
||||
Channels[id].band = band;
|
||||
ChannelsMask[0] |= ( 1 << id );
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
bool LoRaPHYAS923::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
|
@ -1302,7 +1302,7 @@ bool LoRaPHYAS923::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
}
|
||||
|
||||
// Remove the channel from the list of channels
|
||||
const ChannelParams_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
const channel_params_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
Channels[id] = empty_channel;
|
||||
|
||||
return disable_channel( ChannelsMask, id, AS923_MAX_NB_CHANNELS );
|
||||
|
@ -1310,9 +1310,9 @@ bool LoRaPHYAS923::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
|
||||
void LoRaPHYAS923::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, continuousWave->MaxEirp, continuousWave->AntennaGain );
|
||||
|
|
|
@ -131,7 +131,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing.
|
||||
|
@ -187,7 +187,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -201,7 +201,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR Request.
|
||||
|
@ -291,8 +291,8 @@ public:
|
|||
* \retval Function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -301,7 +301,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -335,19 +335,19 @@ public:
|
|||
private:
|
||||
uint8_t CountNbOfEnabledChannels(bool joined, uint8_t datarate,
|
||||
uint16_t* channelsMask,
|
||||
ChannelParams_t* channels, Band_t* bands,
|
||||
channel_params_t* channels, band_t* bands,
|
||||
uint8_t* enabledChannels, uint8_t* delayTx);
|
||||
|
||||
// Global attributes
|
||||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[AS923_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[AS923_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[AS923_MAX_NB_BANDS];
|
||||
band_t Bands[AS923_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -263,8 +263,8 @@ static int8_t LimitTxPower(int8_t txPower, int8_t maxBandTxPower,
|
|||
|
||||
uint8_t LoRaPHYAU915::CountNbOfEnabledChannels(uint8_t datarate,
|
||||
uint16_t* channelsMask,
|
||||
ChannelParams_t* channels,
|
||||
Band_t* bands, uint8_t* enabledChannels,
|
||||
channel_params_t* channels,
|
||||
band_t* bands, uint8_t* enabledChannels,
|
||||
uint8_t* delayTx)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
|
@ -273,14 +273,14 @@ uint8_t LoRaPHYAU915::CountNbOfEnabledChannels(uint8_t datarate,
|
|||
for (uint8_t i = 0, k = 0; i < AU915_MAX_NB_CHANNELS; i += 16, k++) {
|
||||
for (uint8_t j = 0; j < 16; j++) {
|
||||
if ((channelsMask[k] & (1 << j)) != 0) {
|
||||
if (channels[i + j].Frequency == 0) { // Check if the channel is enabled
|
||||
if (channels[i + j].frequency == 0) { // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
if (val_in_range(datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max) == 0) { // Check if the current channel selection supports the given datarate
|
||||
if (val_in_range(datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max) == 0) { // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if (bands[channels[i + j].Band].TimeOff > 0) { // Check if the band is available for transmission
|
||||
if (bands[channels[i + j].band].off_time > 0) { // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ uint8_t LoRaPHYAU915::CountNbOfEnabledChannels(uint8_t datarate,
|
|||
LoRaPHYAU915::LoRaPHYAU915(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = AU915_BAND0;
|
||||
const band_t band0 = AU915_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -430,7 +430,7 @@ PhyParam_t LoRaPHYAU915::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYAU915::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done(txDone->Joined, &Bands[Channels[txDone->Channel].Band],
|
||||
set_last_tx_done(txDone->Joined, &Bands[Channels[txDone->Channel].band],
|
||||
txDone->LastTxDoneTime);
|
||||
}
|
||||
|
||||
|
@ -441,17 +441,17 @@ void LoRaPHYAU915::load_defaults(InitType_t type)
|
|||
// Channels
|
||||
// 125 kHz channels
|
||||
for (uint8_t i = 0; i < AU915_MAX_NB_CHANNELS - 8; i++) {
|
||||
Channels[i].Frequency = 915200000 + i * 200000;
|
||||
Channels[i].DrRange.Value = ( DR_5 << 4) | DR_0;
|
||||
Channels[i].Band = 0;
|
||||
Channels[i].frequency = 915200000 + i * 200000;
|
||||
Channels[i].dr_range.value = ( DR_5 << 4) | DR_0;
|
||||
Channels[i].band = 0;
|
||||
}
|
||||
// 500 kHz channels
|
||||
for (uint8_t i = AU915_MAX_NB_CHANNELS - 8;
|
||||
i < AU915_MAX_NB_CHANNELS; i++) {
|
||||
Channels[i].Frequency = 915900000
|
||||
Channels[i].frequency = 915900000
|
||||
+ (i - ( AU915_MAX_NB_CHANNELS - 8)) * 1600000;
|
||||
Channels[i].DrRange.Value = ( DR_6 << 4) | DR_6;
|
||||
Channels[i].Band = 0;
|
||||
Channels[i].dr_range.value = ( DR_6 << 4) | DR_6;
|
||||
Channels[i].band = 0;
|
||||
}
|
||||
|
||||
// Initialize channels default mask
|
||||
|
@ -611,38 +611,38 @@ bool LoRaPHYAU915::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYAU915::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN(datarate, AU915_RX_MAX_DATARATE);
|
||||
rxConfigParams->Bandwidth = GetBandwidth(rxConfigParams->Datarate);
|
||||
rxConfigParams->datarate = MIN(datarate, AU915_RX_MAX_DATARATE);
|
||||
rxConfigParams->bandwidth = GetBandwidth(rxConfigParams->datarate);
|
||||
|
||||
tSymbol = compute_symb_timeout_lora(
|
||||
DataratesAU915[rxConfigParams->Datarate],
|
||||
BandwidthsAU915[rxConfigParams->Datarate]);
|
||||
DataratesAU915[rxConfigParams->datarate],
|
||||
BandwidthsAU915[rxConfigParams->datarate]);
|
||||
|
||||
get_rx_window_params(tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME,
|
||||
&rxConfigParams->WindowTimeout,
|
||||
&rxConfigParams->WindowOffset);
|
||||
&rxConfigParams->window_timeout,
|
||||
&rxConfigParams->window_offset);
|
||||
}
|
||||
|
||||
bool LoRaPHYAU915::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYAU915::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if (_radio->get_status() != RF_IDLE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rxConfig->RxSlot == RX_SLOT_WIN_1) {
|
||||
if (rxConfig->rx_slot == RX_SLOT_WIN_1) {
|
||||
// Apply window 1 frequency
|
||||
frequency = AU915_FIRST_RX1_CHANNEL
|
||||
+ (rxConfig->Channel % 8) * AU915_STEPWIDTH_RX1_CHANNEL;
|
||||
+ (rxConfig->channel % 8) * AU915_STEPWIDTH_RX1_CHANNEL;
|
||||
}
|
||||
|
||||
// Read the physical datarate from the datarates table
|
||||
|
@ -651,11 +651,11 @@ bool LoRaPHYAU915::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
_radio->set_channel(frequency);
|
||||
|
||||
// Radio configuration
|
||||
_radio->set_rx_config(MODEM_LORA, rxConfig->Bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->WindowTimeout, false, 0, false, 0, 0, true,
|
||||
rxConfig->RxContinuous);
|
||||
_radio->set_rx_config(MODEM_LORA, rxConfig->bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->window_timeout, false, 0, false, 0, 0, true,
|
||||
rxConfig->is_rx_continuous);
|
||||
|
||||
if (rxConfig->RepeaterSupport == true) {
|
||||
if (rxConfig->is_repeater_supported == true) {
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterAU915[dr];
|
||||
} else {
|
||||
maxPayload = MaxPayloadOfDatarateAU915[dr];
|
||||
|
@ -668,12 +668,12 @@ bool LoRaPHYAU915::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
}
|
||||
|
||||
bool LoRaPHYAU915::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir)
|
||||
lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
int8_t phyDr = DataratesAU915[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower(
|
||||
txConfig->TxPower,
|
||||
Bands[Channels[txConfig->Channel].Band].TxMaxPower,
|
||||
Bands[Channels[txConfig->Channel].band].max_tx_pwr,
|
||||
txConfig->Datarate, ChannelsMask);
|
||||
uint32_t bandwidth = GetBandwidth(txConfig->Datarate);
|
||||
int8_t phyTxPower = 0;
|
||||
|
@ -683,7 +683,7 @@ bool LoRaPHYAU915::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
|||
txConfig->AntennaGain);
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel(Channels[txConfig->Channel].Frequency);
|
||||
_radio->set_channel(Channels[txConfig->Channel].frequency);
|
||||
|
||||
_radio->set_tx_config(MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8,
|
||||
false, true, 0, 0, false, 3000);
|
||||
|
@ -885,13 +885,13 @@ void LoRaPHYAU915::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYAU915::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[AU915_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
// Count 125kHz channels
|
||||
if (num_active_channels(ChannelsMaskRemaining, 0, 4) == 0) { // Reactivate default channels
|
||||
|
@ -946,24 +946,24 @@ bool LoRaPHYAU915::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYAU915::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYAU915::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
bool LoRaPHYAU915::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
void LoRaPHYAU915::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower(
|
||||
continuousWave->TxPower,
|
||||
Bands[Channels[continuousWave->Channel].Band].TxMaxPower,
|
||||
Bands[Channels[continuousWave->Channel].band].max_tx_pwr,
|
||||
continuousWave->Datarate, ChannelsMask);
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power(txPowerLimited, continuousWave->MaxEirp,
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR Request.
|
||||
|
@ -294,8 +294,8 @@ public:
|
|||
* \retval The function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -304,7 +304,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -338,8 +338,8 @@ public:
|
|||
private:
|
||||
uint8_t CountNbOfEnabledChannels(uint8_t datarate,
|
||||
uint16_t* channelsMask,
|
||||
ChannelParams_t* channels,
|
||||
Band_t* bands, uint8_t* enabledChannels,
|
||||
channel_params_t* channels,
|
||||
band_t* bands, uint8_t* enabledChannels,
|
||||
uint8_t* delayTx);
|
||||
|
||||
|
||||
|
@ -347,12 +347,12 @@ private:
|
|||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[AU915_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[AU915_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[AU915_MAX_NB_BANDS];
|
||||
band_t Bands[AU915_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -245,7 +245,7 @@ static int8_t LimitTxPower( int8_t txPower, int8_t maxBandTxPower, int8_t datara
|
|||
return txPowerResult;
|
||||
}
|
||||
|
||||
uint8_t LoRaPHYCN470::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
uint8_t LoRaPHYCN470::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTransmission = 0;
|
||||
|
@ -256,16 +256,16 @@ uint8_t LoRaPHYCN470::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* chan
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -282,7 +282,7 @@ uint8_t LoRaPHYCN470::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* chan
|
|||
LoRaPHYCN470::LoRaPHYCN470(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = CN470_BAND0;
|
||||
const band_t band0 = CN470_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ PhyParam_t LoRaPHYCN470::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYCN470::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYCN470::load_defaults(InitType_t type)
|
||||
|
@ -452,9 +452,9 @@ void LoRaPHYCN470::load_defaults(InitType_t type)
|
|||
// 125 kHz channels
|
||||
for( uint8_t i = 0; i < CN470_MAX_NB_CHANNELS; i++ )
|
||||
{
|
||||
Channels[i].Frequency = 470300000 + i * 200000;
|
||||
Channels[i].DrRange.Value = ( DR_5 << 4 ) | DR_0;
|
||||
Channels[i].Band = 0;
|
||||
Channels[i].frequency = 470300000 + i * 200000;
|
||||
Channels[i].dr_range.value = ( DR_5 << 4 ) | DR_0;
|
||||
Channels[i].band = 0;
|
||||
}
|
||||
|
||||
// Initialize the channels default mask
|
||||
|
@ -612,35 +612,35 @@ bool LoRaPHYCN470::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYCN470::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, CN470_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, CN470_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
tSymbol = compute_symb_timeout_lora( DataratesCN470[rxConfigParams->Datarate], BandwidthsCN470[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesCN470[rxConfigParams->datarate], BandwidthsCN470[rxConfigParams->datarate] );
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYCN470::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYCN470::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if(_radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1 )
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = CN470_FIRST_RX1_CHANNEL + ( rxConfig->Channel % 48 ) * CN470_STEPWIDTH_RX1_CHANNEL;
|
||||
frequency = CN470_FIRST_RX1_CHANNEL + ( rxConfig->channel % 48 ) * CN470_STEPWIDTH_RX1_CHANNEL;
|
||||
}
|
||||
|
||||
// Read the physical datarate from the datarates table
|
||||
|
@ -649,11 +649,11 @@ bool LoRaPHYCN470::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
_radio->set_channel(frequency);
|
||||
|
||||
// Radio configuration
|
||||
_radio->set_rx_config(MODEM_LORA, rxConfig->Bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->WindowTimeout, false, 0, false, 0, 0, true,
|
||||
rxConfig->RxContinuous);
|
||||
_radio->set_rx_config(MODEM_LORA, rxConfig->bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->window_timeout, false, 0, false, 0, 0, true,
|
||||
rxConfig->is_rx_continuous);
|
||||
|
||||
if( rxConfig->RepeaterSupport == true )
|
||||
if( rxConfig->is_repeater_supported == true )
|
||||
{
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterCN470[dr];
|
||||
}
|
||||
|
@ -668,17 +668,17 @@ bool LoRaPHYCN470::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
}
|
||||
|
||||
bool LoRaPHYCN470::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir)
|
||||
lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
int8_t phyDr = DataratesCN470[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel(Channels[txConfig->Channel].Frequency);
|
||||
_radio->set_channel(Channels[txConfig->Channel].frequency);
|
||||
|
||||
_radio->set_tx_config(MODEM_LORA, phyTxPower, 0, 0, phyDr, 1, 8, false, true,
|
||||
0, 0, false, 3000);
|
||||
|
@ -740,7 +740,7 @@ uint8_t LoRaPHYCN470::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
for( uint8_t i = 0; i < 16; i++ )
|
||||
{
|
||||
if( ( ( linkAdrParams.ChMask & ( 1 << i ) ) != 0 ) &&
|
||||
( Channels[linkAdrParams.ChMaskCtrl * 16 + i].Frequency == 0 ) )
|
||||
( Channels[linkAdrParams.ChMaskCtrl * 16 + i].frequency == 0 ) )
|
||||
{// Trying to enable an undefined channel
|
||||
status &= 0xFE; // Channel mask KO
|
||||
}
|
||||
|
@ -882,13 +882,13 @@ void LoRaPHYCN470::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYCN470::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[CN470_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
// Count 125kHz channels
|
||||
if( num_active_channels( ChannelsMask, 0, 6 ) == 0 )
|
||||
|
@ -942,21 +942,21 @@ bool LoRaPHYCN470::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYCN470::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYCN470::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
bool LoRaPHYCN470::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
void LoRaPHYCN470::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, continuousWave->MaxEirp, continuousWave->AntennaGain );
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR request.
|
||||
|
@ -294,8 +294,8 @@ public:
|
|||
* \retval Function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -304,7 +304,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -336,7 +336,7 @@ public:
|
|||
virtual uint8_t apply_DR_offset(uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset );
|
||||
|
||||
private:
|
||||
uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
bool RegionCN470ChanMaskSet( ChanMaskSetParams_t* chanMaskSet );
|
||||
|
||||
|
||||
|
@ -344,12 +344,12 @@ private:
|
|||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[CN470_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[CN470_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[CN470_MAX_NB_BANDS];
|
||||
band_t Bands[CN470_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -285,7 +285,7 @@ static bool VerifyTxFreq( uint32_t freq, LoRaRadio *radio)
|
|||
return true;
|
||||
}
|
||||
|
||||
uint8_t LoRaPHYCN779::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
uint8_t LoRaPHYCN779::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTransmission = 0;
|
||||
|
@ -296,7 +296,7 @@ uint8_t LoRaPHYCN779::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
|
@ -307,12 +307,12 @@ uint8_t LoRaPHYCN779::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -329,7 +329,7 @@ uint8_t LoRaPHYCN779::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
LoRaPHYCN779::LoRaPHYCN779(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = CN779_BAND0;
|
||||
const band_t band0 = CN779_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ PhyParam_t LoRaPHYCN779::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYCN779::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYCN779::load_defaults(InitType_t type)
|
||||
|
@ -496,9 +496,9 @@ void LoRaPHYCN779::load_defaults(InitType_t type)
|
|||
case INIT_TYPE_INIT:
|
||||
{
|
||||
// Channels
|
||||
const ChannelParams_t channel1 = CN779_LC1;
|
||||
const ChannelParams_t channel2 = CN779_LC2;
|
||||
const ChannelParams_t channel3 = CN779_LC3;
|
||||
const channel_params_t channel1 = CN779_LC1;
|
||||
const channel_params_t channel2 = CN779_LC2;
|
||||
const channel_params_t channel3 = CN779_LC3;
|
||||
Channels[0] = channel1;
|
||||
Channels[1] = channel2;
|
||||
Channels[2] = channel3;
|
||||
|
@ -564,12 +564,12 @@ bool LoRaPHYCN779::verify(VerifyParams_t* verify, PhyAttribute_t phyAttribute)
|
|||
|
||||
void LoRaPHYCN779::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
||||
{
|
||||
ChannelParams_t newChannel;
|
||||
channel_params_t newChannel;
|
||||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
// Setup default datarate range
|
||||
newChannel.DrRange.Value = ( DR_5 << 4 ) | DR_0;
|
||||
newChannel.dr_range.value = ( DR_5 << 4 ) | DR_0;
|
||||
|
||||
// Size of the optional CF list
|
||||
if( applyCFList->Size != 16 )
|
||||
|
@ -583,22 +583,22 @@ void LoRaPHYCN779::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
|||
if( chanIdx < ( CN779_NUMB_CHANNELS_CF_LIST + CN779_NUMB_DEFAULT_CHANNELS ) )
|
||||
{
|
||||
// Channel frequency
|
||||
newChannel.Frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.Frequency *= 100;
|
||||
newChannel.frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.frequency *= 100;
|
||||
|
||||
// Initialize alternative frequency to 0
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
newChannel.Frequency = 0;
|
||||
newChannel.DrRange.Value = 0;
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.frequency = 0;
|
||||
newChannel.dr_range.value = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
|
||||
if( newChannel.Frequency != 0 )
|
||||
if( newChannel.frequency != 0 )
|
||||
{
|
||||
channelAdd.NewChannel = &newChannel;
|
||||
channelAdd.ChannelId = chanIdx;
|
||||
|
@ -698,47 +698,47 @@ bool LoRaPHYCN779::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYCN779::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, CN779_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, CN779_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
if( rxConfigParams->Datarate == DR_7 )
|
||||
if( rxConfigParams->datarate == DR_7 )
|
||||
{ // FSK
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesCN779[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesCN779[rxConfigParams->datarate] );
|
||||
}
|
||||
else
|
||||
{ // LoRa
|
||||
tSymbol = compute_symb_timeout_lora( DataratesCN779[rxConfigParams->Datarate], BandwidthsCN779[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesCN779[rxConfigParams->datarate], BandwidthsCN779[rxConfigParams->datarate] );
|
||||
}
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYCN779::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYCN779::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if(_radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1)
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1)
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = Channels[rxConfig->Channel].Frequency;
|
||||
frequency = Channels[rxConfig->channel].frequency;
|
||||
// Apply the alternative RX 1 window frequency, if it is available
|
||||
if( Channels[rxConfig->Channel].Rx1Frequency != 0 )
|
||||
if( Channels[rxConfig->channel].rx1_frequency != 0 )
|
||||
{
|
||||
frequency = Channels[rxConfig->Channel].Rx1Frequency;
|
||||
frequency = Channels[rxConfig->channel].rx1_frequency;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -751,15 +751,15 @@ bool LoRaPHYCN779::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
if( dr == DR_7 )
|
||||
{
|
||||
modem = MODEM_FSK;
|
||||
_radio->set_rx_config(modem, 50000, phyDr * 1000, 0, 83333, 5, rxConfig->WindowTimeout, false, 0, true, 0, 0, false, rxConfig->RxContinuous);
|
||||
_radio->set_rx_config(modem, 50000, phyDr * 1000, 0, 83333, 5, rxConfig->window_timeout, false, 0, true, 0, 0, false, rxConfig->is_rx_continuous);
|
||||
}
|
||||
else
|
||||
{
|
||||
modem = MODEM_LORA;
|
||||
_radio->set_rx_config(modem, rxConfig->Bandwidth, phyDr, 1, 0, 8, rxConfig->WindowTimeout, false, 0, false, 0, 0, true, rxConfig->RxContinuous);
|
||||
_radio->set_rx_config(modem, rxConfig->bandwidth, phyDr, 1, 0, 8, rxConfig->window_timeout, false, 0, false, 0, 0, true, rxConfig->is_rx_continuous);
|
||||
}
|
||||
|
||||
if( rxConfig->RepeaterSupport == true )
|
||||
if( rxConfig->is_repeater_supported == true )
|
||||
{
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterCN779[dr];
|
||||
}
|
||||
|
@ -774,11 +774,11 @@ bool LoRaPHYCN779::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
}
|
||||
|
||||
bool LoRaPHYCN779::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir)
|
||||
lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t phyDr = DataratesCN779[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
|
@ -786,7 +786,7 @@ bool LoRaPHYCN779::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
|||
phyTxPower = compute_tx_power( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel(Channels[txConfig->Channel].Frequency);
|
||||
_radio->set_channel(Channels[txConfig->Channel].frequency);
|
||||
|
||||
if( txConfig->Datarate == DR_7 )
|
||||
{ // High Speed FSK channel
|
||||
|
@ -855,7 +855,7 @@ uint8_t LoRaPHYCN779::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
{
|
||||
if( linkAdrParams.ChMaskCtrl == 6 )
|
||||
{
|
||||
if( Channels[i].Frequency != 0 )
|
||||
if( Channels[i].frequency != 0 )
|
||||
{
|
||||
chMask |= 1 << i;
|
||||
}
|
||||
|
@ -863,7 +863,7 @@ uint8_t LoRaPHYCN779::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
else
|
||||
{
|
||||
if( ( ( chMask & ( 1 << i ) ) != 0 ) &&
|
||||
( Channels[i].Frequency == 0 ) )
|
||||
( Channels[i].frequency == 0 ) )
|
||||
{// Trying to enable an undefined channel
|
||||
status &= 0xFE; // Channel mask KO
|
||||
}
|
||||
|
@ -945,7 +945,7 @@ uint8_t LoRaPHYCN779::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
if( newChannelReq->NewChannel->Frequency == 0 )
|
||||
if( newChannelReq->NewChannel->frequency == 0 )
|
||||
{
|
||||
channelRemove.ChannelId = newChannelReq->ChannelId;
|
||||
|
||||
|
@ -962,21 +962,21 @@ uint8_t LoRaPHYCN779::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
|
||||
switch (add_channel(&channelAdd))
|
||||
{
|
||||
case LORAMAC_STATUS_OK:
|
||||
case LORAWAN_STATUS_OK:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQUENCY_INVALID:
|
||||
case LORAWAN_STATUS_FREQUENCY_INVALID:
|
||||
{
|
||||
status &= 0xFE;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_DATARATE_INVALID:
|
||||
case LORAWAN_STATUS_DATARATE_INVALID:
|
||||
{
|
||||
status &= 0xFD;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQ_AND_DR_INVALID:
|
||||
case LORAWAN_STATUS_FREQ_AND_DR_INVALID:
|
||||
{
|
||||
status &= 0xFC;
|
||||
break;
|
||||
|
@ -1008,7 +1008,7 @@ uint8_t LoRaPHYCN779::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
}
|
||||
|
||||
// Verify if an uplink frequency exists
|
||||
if( Channels[dlChannelReq->ChannelId].Frequency == 0 )
|
||||
if( Channels[dlChannelReq->ChannelId].frequency == 0 )
|
||||
{
|
||||
status &= 0xFD;
|
||||
}
|
||||
|
@ -1016,7 +1016,7 @@ uint8_t LoRaPHYCN779::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
// Apply Rx1 frequency, if the status is OK
|
||||
if( status == 0x03 )
|
||||
{
|
||||
Channels[dlChannelReq->ChannelId].Rx1Frequency = dlChannelReq->Rx1Frequency;
|
||||
Channels[dlChannelReq->ChannelId].rx1_frequency = dlChannelReq->Rx1Frequency;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1070,13 +1070,13 @@ void LoRaPHYCN779::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYCN779::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[CN779_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
if( num_active_channels( ChannelsMask, 0, 1 ) == 0 )
|
||||
{ // Reactivate default channels
|
||||
|
@ -1125,7 +1125,7 @@ bool LoRaPHYCN779::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYCN779::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYCN779::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
uint8_t band = 0;
|
||||
bool drInvalid = false;
|
||||
|
@ -1134,19 +1134,19 @@ LoRaMacStatus_t LoRaPHYCN779::add_channel(ChannelAddParams_t* channelAdd)
|
|||
|
||||
if( id >= CN779_MAX_NB_CHANNELS )
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
// Validate the datarate range
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Min, CN779_TX_MIN_DATARATE, CN779_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.min, CN779_TX_MIN_DATARATE, CN779_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, CN779_TX_MIN_DATARATE, CN779_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, CN779_TX_MIN_DATARATE, CN779_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > channelAdd->NewChannel->dr_range.fields.max )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
|
@ -1155,17 +1155,17 @@ LoRaMacStatus_t LoRaPHYCN779::add_channel(ChannelAddParams_t* channelAdd)
|
|||
if( id < CN779_NUMB_DEFAULT_CHANNELS )
|
||||
{
|
||||
// Validate the datarate range for min: must be DR_0
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > DR_0 )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > DR_0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// Validate the datarate range for max: must be DR_5 <= Max <= TX_MAX_DATARATE
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, DR_5, CN779_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, DR_5, CN779_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// We are not allowed to change the frequency
|
||||
if( channelAdd->NewChannel->Frequency != Channels[id].Frequency )
|
||||
if( channelAdd->NewChannel->frequency != Channels[id].frequency )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1174,7 +1174,7 @@ LoRaMacStatus_t LoRaPHYCN779::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check frequency
|
||||
if( freqInvalid == false )
|
||||
{
|
||||
if( VerifyTxFreq(channelAdd->NewChannel->Frequency, _radio) == false )
|
||||
if( VerifyTxFreq(channelAdd->NewChannel->frequency, _radio) == false )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1183,21 +1183,21 @@ LoRaMacStatus_t LoRaPHYCN779::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check status
|
||||
if( ( drInvalid == true ) && ( freqInvalid == true ) )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQ_AND_DR_INVALID;
|
||||
return LORAWAN_STATUS_FREQ_AND_DR_INVALID;
|
||||
}
|
||||
if( drInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_DATARATE_INVALID;
|
||||
return LORAWAN_STATUS_DATARATE_INVALID;
|
||||
}
|
||||
if( freqInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQUENCY_INVALID;
|
||||
return LORAWAN_STATUS_FREQUENCY_INVALID;
|
||||
}
|
||||
|
||||
memcpy( &(Channels[id]), channelAdd->NewChannel, sizeof( Channels[id] ) );
|
||||
Channels[id].Band = band;
|
||||
Channels[id].band = band;
|
||||
ChannelsMask[0] |= ( 1 << id );
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
bool LoRaPHYCN779::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
|
@ -1210,7 +1210,7 @@ bool LoRaPHYCN779::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
}
|
||||
|
||||
// Remove the channel from the list of channels
|
||||
const ChannelParams_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
const channel_params_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
Channels[id] = empty_channel;
|
||||
|
||||
return disable_channel( ChannelsMask, id, CN779_MAX_NB_CHANNELS );
|
||||
|
@ -1218,9 +1218,9 @@ bool LoRaPHYCN779::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
|
||||
void LoRaPHYCN779::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, continuousWave->MaxEirp, continuousWave->AntennaGain );
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -180,7 +180,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR request.
|
||||
|
@ -285,8 +285,8 @@ public:
|
|||
* \retval Function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -295,7 +295,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -327,18 +327,18 @@ public:
|
|||
virtual uint8_t apply_DR_offset(uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset );
|
||||
|
||||
private:
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
|
||||
// Global attributes
|
||||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[CN779_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[CN779_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[CN779_MAX_NB_BANDS];
|
||||
band_t Bands[CN779_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -286,7 +286,7 @@ static bool VerifyTxFreq( uint32_t freq, LoRaRadio *radio )
|
|||
return true;
|
||||
}
|
||||
|
||||
uint8_t LoRaPHYEU433::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
uint8_t LoRaPHYEU433::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTransmission = 0;
|
||||
|
@ -297,7 +297,7 @@ uint8_t LoRaPHYEU433::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
|
@ -308,12 +308,12 @@ uint8_t LoRaPHYEU433::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -330,7 +330,7 @@ uint8_t LoRaPHYEU433::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
LoRaPHYEU433::LoRaPHYEU433(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = EU433_BAND0;
|
||||
const band_t band0 = EU433_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ PhyParam_t LoRaPHYEU433::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYEU433::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYEU433::load_defaults(InitType_t type)
|
||||
|
@ -497,9 +497,9 @@ void LoRaPHYEU433::load_defaults(InitType_t type)
|
|||
case INIT_TYPE_INIT:
|
||||
{
|
||||
// Channels
|
||||
const ChannelParams_t channel1 = EU433_LC1;
|
||||
const ChannelParams_t channel2 = EU433_LC2;
|
||||
const ChannelParams_t channel3 = EU433_LC3;
|
||||
const channel_params_t channel1 = EU433_LC1;
|
||||
const channel_params_t channel2 = EU433_LC2;
|
||||
const channel_params_t channel3 = EU433_LC3;
|
||||
Channels[0] = channel1;
|
||||
Channels[1] = channel2;
|
||||
Channels[2] = channel3;
|
||||
|
@ -565,12 +565,12 @@ bool LoRaPHYEU433::verify(VerifyParams_t* verify, PhyAttribute_t phyAttribute)
|
|||
|
||||
void LoRaPHYEU433::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
||||
{
|
||||
ChannelParams_t newChannel;
|
||||
channel_params_t newChannel;
|
||||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
// Setup default datarate range
|
||||
newChannel.DrRange.Value = ( DR_5 << 4 ) | DR_0;
|
||||
newChannel.dr_range.value = ( DR_5 << 4 ) | DR_0;
|
||||
|
||||
// Size of the optional CF list
|
||||
if( applyCFList->Size != 16 )
|
||||
|
@ -584,22 +584,22 @@ void LoRaPHYEU433::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
|||
if( chanIdx < ( EU433_NUMB_CHANNELS_CF_LIST + EU433_NUMB_DEFAULT_CHANNELS ) )
|
||||
{
|
||||
// Channel frequency
|
||||
newChannel.Frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.Frequency *= 100;
|
||||
newChannel.frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.frequency *= 100;
|
||||
|
||||
// Initialize alternative frequency to 0
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
newChannel.Frequency = 0;
|
||||
newChannel.DrRange.Value = 0;
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.frequency = 0;
|
||||
newChannel.dr_range.value = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
|
||||
if( newChannel.Frequency != 0 )
|
||||
if( newChannel.frequency != 0 )
|
||||
{
|
||||
channelAdd.NewChannel = &newChannel;
|
||||
channelAdd.ChannelId = chanIdx;
|
||||
|
@ -699,47 +699,47 @@ bool LoRaPHYEU433::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYEU433::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, EU433_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, EU433_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
if( rxConfigParams->Datarate == DR_7 )
|
||||
if( rxConfigParams->datarate == DR_7 )
|
||||
{ // FSK
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesEU433[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesEU433[rxConfigParams->datarate] );
|
||||
}
|
||||
else
|
||||
{ // LoRa
|
||||
tSymbol = compute_symb_timeout_lora( DataratesEU433[rxConfigParams->Datarate], BandwidthsEU433[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesEU433[rxConfigParams->datarate], BandwidthsEU433[rxConfigParams->datarate] );
|
||||
}
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYEU433::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYEU433::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if( _radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1 )
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = Channels[rxConfig->Channel].Frequency;
|
||||
frequency = Channels[rxConfig->channel].frequency;
|
||||
// Apply the alternative RX 1 window frequency, if it is available
|
||||
if( Channels[rxConfig->Channel].Rx1Frequency != 0 )
|
||||
if( Channels[rxConfig->channel].rx1_frequency != 0 )
|
||||
{
|
||||
frequency = Channels[rxConfig->Channel].Rx1Frequency;
|
||||
frequency = Channels[rxConfig->channel].rx1_frequency;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,18 +753,18 @@ bool LoRaPHYEU433::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
{
|
||||
modem = MODEM_FSK;
|
||||
_radio->set_rx_config( modem, 50000, phyDr * 1000, 0, 83333, 5,
|
||||
rxConfig->WindowTimeout, false, 0, true, 0, 0,
|
||||
false, rxConfig->RxContinuous );
|
||||
rxConfig->window_timeout, false, 0, true, 0, 0,
|
||||
false, rxConfig->is_rx_continuous );
|
||||
}
|
||||
else
|
||||
{
|
||||
modem = MODEM_LORA;
|
||||
_radio->set_rx_config( modem, rxConfig->Bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->WindowTimeout, false, 0, false, 0, 0,
|
||||
true, rxConfig->RxContinuous );
|
||||
_radio->set_rx_config( modem, rxConfig->bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->window_timeout, false, 0, false, 0, 0,
|
||||
true, rxConfig->is_rx_continuous );
|
||||
}
|
||||
|
||||
if( rxConfig->RepeaterSupport == true )
|
||||
if( rxConfig->is_repeater_supported == true )
|
||||
{
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterEU433[dr];
|
||||
}
|
||||
|
@ -779,11 +779,11 @@ bool LoRaPHYEU433::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
}
|
||||
|
||||
bool LoRaPHYEU433::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir)
|
||||
lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t phyDr = DataratesEU433[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
|
@ -791,7 +791,7 @@ bool LoRaPHYEU433::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
|||
phyTxPower = compute_tx_power( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel( Channels[txConfig->Channel].Frequency );
|
||||
_radio->set_channel( Channels[txConfig->Channel].frequency );
|
||||
|
||||
if( txConfig->Datarate == DR_7 )
|
||||
{ // High Speed FSK channel
|
||||
|
@ -860,7 +860,7 @@ uint8_t LoRaPHYEU433::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
{
|
||||
if( linkAdrParams.ChMaskCtrl == 6 )
|
||||
{
|
||||
if( Channels[i].Frequency != 0 )
|
||||
if( Channels[i].frequency != 0 )
|
||||
{
|
||||
chMask |= 1 << i;
|
||||
}
|
||||
|
@ -868,7 +868,7 @@ uint8_t LoRaPHYEU433::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
else
|
||||
{
|
||||
if( ( ( chMask & ( 1 << i ) ) != 0 ) &&
|
||||
( Channels[i].Frequency == 0 ) )
|
||||
( Channels[i].frequency == 0 ) )
|
||||
{// Trying to enable an undefined channel
|
||||
status &= 0xFE; // Channel mask KO
|
||||
}
|
||||
|
@ -950,7 +950,7 @@ uint8_t LoRaPHYEU433::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
if( newChannelReq->NewChannel->Frequency == 0 )
|
||||
if( newChannelReq->NewChannel->frequency == 0 )
|
||||
{
|
||||
channelRemove.ChannelId = newChannelReq->ChannelId;
|
||||
|
||||
|
@ -967,21 +967,21 @@ uint8_t LoRaPHYEU433::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
|
||||
switch( add_channel( &channelAdd ) )
|
||||
{
|
||||
case LORAMAC_STATUS_OK:
|
||||
case LORAWAN_STATUS_OK:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQUENCY_INVALID:
|
||||
case LORAWAN_STATUS_FREQUENCY_INVALID:
|
||||
{
|
||||
status &= 0xFE;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_DATARATE_INVALID:
|
||||
case LORAWAN_STATUS_DATARATE_INVALID:
|
||||
{
|
||||
status &= 0xFD;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQ_AND_DR_INVALID:
|
||||
case LORAWAN_STATUS_FREQ_AND_DR_INVALID:
|
||||
{
|
||||
status &= 0xFC;
|
||||
break;
|
||||
|
@ -1013,7 +1013,7 @@ uint8_t LoRaPHYEU433::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
}
|
||||
|
||||
// Verify if an uplink frequency exists
|
||||
if( Channels[dlChannelReq->ChannelId].Frequency == 0 )
|
||||
if( Channels[dlChannelReq->ChannelId].frequency == 0 )
|
||||
{
|
||||
status &= 0xFD;
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ uint8_t LoRaPHYEU433::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
// Apply Rx1 frequency, if the status is OK
|
||||
if( status == 0x03 )
|
||||
{
|
||||
Channels[dlChannelReq->ChannelId].Rx1Frequency = dlChannelReq->Rx1Frequency;
|
||||
Channels[dlChannelReq->ChannelId].rx1_frequency = dlChannelReq->Rx1Frequency;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1075,13 +1075,13 @@ void LoRaPHYEU433::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYEU433::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[EU433_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
if( num_active_channels( ChannelsMask, 0, 1 ) == 0 )
|
||||
{ // Reactivate default channels
|
||||
|
@ -1130,7 +1130,7 @@ bool LoRaPHYEU433::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYEU433::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYEU433::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
uint8_t band = 0;
|
||||
bool drInvalid = false;
|
||||
|
@ -1139,19 +1139,19 @@ LoRaMacStatus_t LoRaPHYEU433::add_channel(ChannelAddParams_t* channelAdd)
|
|||
|
||||
if( id >= EU433_MAX_NB_CHANNELS )
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
// Validate the datarate range
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Min, EU433_TX_MIN_DATARATE, EU433_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.min, EU433_TX_MIN_DATARATE, EU433_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, EU433_TX_MIN_DATARATE, EU433_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, EU433_TX_MIN_DATARATE, EU433_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > channelAdd->NewChannel->dr_range.fields.max )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
|
@ -1160,17 +1160,17 @@ LoRaMacStatus_t LoRaPHYEU433::add_channel(ChannelAddParams_t* channelAdd)
|
|||
if( id < EU433_NUMB_DEFAULT_CHANNELS )
|
||||
{
|
||||
// Validate the datarate range for min: must be DR_0
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > DR_0 )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > DR_0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// Validate the datarate range for max: must be DR_5 <= Max <= TX_MAX_DATARATE
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, DR_5, EU433_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, DR_5, EU433_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// We are not allowed to change the frequency
|
||||
if( channelAdd->NewChannel->Frequency != Channels[id].Frequency )
|
||||
if( channelAdd->NewChannel->frequency != Channels[id].frequency )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1179,7 +1179,7 @@ LoRaMacStatus_t LoRaPHYEU433::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check frequency
|
||||
if( freqInvalid == false )
|
||||
{
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->Frequency, _radio ) == false )
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->frequency, _radio ) == false )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1188,21 +1188,21 @@ LoRaMacStatus_t LoRaPHYEU433::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check status
|
||||
if( ( drInvalid == true ) && ( freqInvalid == true ) )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQ_AND_DR_INVALID;
|
||||
return LORAWAN_STATUS_FREQ_AND_DR_INVALID;
|
||||
}
|
||||
if( drInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_DATARATE_INVALID;
|
||||
return LORAWAN_STATUS_DATARATE_INVALID;
|
||||
}
|
||||
if( freqInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQUENCY_INVALID;
|
||||
return LORAWAN_STATUS_FREQUENCY_INVALID;
|
||||
}
|
||||
|
||||
memcpy( &(Channels[id]), channelAdd->NewChannel, sizeof( Channels[id] ) );
|
||||
Channels[id].Band = band;
|
||||
Channels[id].band = band;
|
||||
ChannelsMask[0] |= ( 1 << id );
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
bool LoRaPHYEU433::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
|
@ -1215,7 +1215,7 @@ bool LoRaPHYEU433::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
}
|
||||
|
||||
// Remove the channel from the list of channels
|
||||
const ChannelParams_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
const channel_params_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
Channels[id] = empty_channel;
|
||||
|
||||
return disable_channel( ChannelsMask, id, EU433_MAX_NB_CHANNELS );
|
||||
|
@ -1223,9 +1223,9 @@ bool LoRaPHYEU433::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
|
||||
void LoRaPHYEU433::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, continuousWave->MaxEirp, continuousWave->AntennaGain );
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -200,7 +200,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR request.
|
||||
|
@ -291,8 +291,8 @@ public:
|
|||
* \retval Function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -301,7 +301,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -333,18 +333,18 @@ public:
|
|||
virtual uint8_t apply_DR_offset(uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset );
|
||||
|
||||
private:
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
|
||||
// Global attributes
|
||||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[EU433_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[EU433_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[EU433_MAX_NB_BANDS];
|
||||
band_t Bands[EU433_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -331,7 +331,7 @@ static bool VerifyTxFreq( uint32_t freq, uint8_t *band, LoRaRadio *radio )
|
|||
return true;
|
||||
}
|
||||
|
||||
uint8_t LoRaPHYEU868::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
uint8_t LoRaPHYEU868::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTransmission = 0;
|
||||
|
@ -342,7 +342,7 @@ uint8_t LoRaPHYEU868::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
|
@ -353,12 +353,12 @@ uint8_t LoRaPHYEU868::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -375,11 +375,11 @@ uint8_t LoRaPHYEU868::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
LoRaPHYEU868::LoRaPHYEU868(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = EU868_BAND0;
|
||||
const Band_t band1 = EU868_BAND1;
|
||||
const Band_t band2 = EU868_BAND2;
|
||||
const Band_t band3 = EU868_BAND3;
|
||||
const Band_t band4 = EU868_BAND4;
|
||||
const band_t band0 = EU868_BAND0;
|
||||
const band_t band1 = EU868_BAND1;
|
||||
const band_t band2 = EU868_BAND2;
|
||||
const band_t band3 = EU868_BAND3;
|
||||
const band_t band4 = EU868_BAND4;
|
||||
|
||||
Bands[0] = band0;
|
||||
Bands[1] = band1;
|
||||
|
@ -541,7 +541,7 @@ PhyParam_t LoRaPHYEU868::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYEU868::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYEU868::load_defaults(InitType_t type)
|
||||
|
@ -551,9 +551,9 @@ void LoRaPHYEU868::load_defaults(InitType_t type)
|
|||
case INIT_TYPE_INIT:
|
||||
{
|
||||
// Channels
|
||||
const ChannelParams_t channel1 = EU868_LC1;
|
||||
const ChannelParams_t channel2 = EU868_LC2;
|
||||
const ChannelParams_t channel3 = EU868_LC3;
|
||||
const channel_params_t channel1 = EU868_LC1;
|
||||
const channel_params_t channel2 = EU868_LC2;
|
||||
const channel_params_t channel3 = EU868_LC3;
|
||||
Channels[0] = channel1;
|
||||
Channels[1] = channel2;
|
||||
Channels[2] = channel3;
|
||||
|
@ -619,12 +619,12 @@ bool LoRaPHYEU868::verify(VerifyParams_t* verify, PhyAttribute_t phyAttribute)
|
|||
|
||||
void LoRaPHYEU868::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
||||
{
|
||||
ChannelParams_t newChannel;
|
||||
channel_params_t newChannel;
|
||||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
// Setup default datarate range
|
||||
newChannel.DrRange.Value = ( DR_5 << 4 ) | DR_0;
|
||||
newChannel.dr_range.value = ( DR_5 << 4 ) | DR_0;
|
||||
|
||||
// Size of the optional CF list
|
||||
if( applyCFList->Size != 16 )
|
||||
|
@ -638,22 +638,22 @@ void LoRaPHYEU868::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
|||
if( chanIdx < ( EU868_NUMB_CHANNELS_CF_LIST + EU868_NUMB_DEFAULT_CHANNELS ) )
|
||||
{
|
||||
// Channel frequency
|
||||
newChannel.Frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.Frequency *= 100;
|
||||
newChannel.frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.frequency *= 100;
|
||||
|
||||
// Initialize alternative frequency to 0
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
newChannel.Frequency = 0;
|
||||
newChannel.DrRange.Value = 0;
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.frequency = 0;
|
||||
newChannel.dr_range.value = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
|
||||
if( newChannel.Frequency != 0 )
|
||||
if( newChannel.frequency != 0 )
|
||||
{
|
||||
channelAdd.NewChannel = &newChannel;
|
||||
channelAdd.ChannelId = chanIdx;
|
||||
|
@ -753,47 +753,47 @@ bool LoRaPHYEU868::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYEU868::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, EU868_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, EU868_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
if( rxConfigParams->Datarate == DR_7 )
|
||||
if( rxConfigParams->datarate == DR_7 )
|
||||
{ // FSK
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesEU868[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesEU868[rxConfigParams->datarate] );
|
||||
}
|
||||
else
|
||||
{ // LoRa
|
||||
tSymbol = compute_symb_timeout_lora( DataratesEU868[rxConfigParams->Datarate], BandwidthsEU868[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesEU868[rxConfigParams->datarate], BandwidthsEU868[rxConfigParams->datarate] );
|
||||
}
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYEU868::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYEU868::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if( _radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1 )
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = Channels[rxConfig->Channel].Frequency;
|
||||
frequency = Channels[rxConfig->channel].frequency;
|
||||
// Apply the alternative RX 1 window frequency, if it is available
|
||||
if( Channels[rxConfig->Channel].Rx1Frequency != 0 )
|
||||
if( Channels[rxConfig->channel].rx1_frequency != 0 )
|
||||
{
|
||||
frequency = Channels[rxConfig->Channel].Rx1Frequency;
|
||||
frequency = Channels[rxConfig->channel].rx1_frequency;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -806,15 +806,15 @@ bool LoRaPHYEU868::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
if( dr == DR_7 )
|
||||
{
|
||||
modem = MODEM_FSK;
|
||||
_radio->set_rx_config( modem, 50000, phyDr * 1000, 0, 83333, 5, rxConfig->WindowTimeout, false, 0, true, 0, 0, false, rxConfig->RxContinuous );
|
||||
_radio->set_rx_config( modem, 50000, phyDr * 1000, 0, 83333, 5, rxConfig->window_timeout, false, 0, true, 0, 0, false, rxConfig->is_rx_continuous );
|
||||
}
|
||||
else
|
||||
{
|
||||
modem = MODEM_LORA;
|
||||
_radio->set_rx_config( modem, rxConfig->Bandwidth, phyDr, 1, 0, 8, rxConfig->WindowTimeout, false, 0, false, 0, 0, true, rxConfig->RxContinuous );
|
||||
_radio->set_rx_config( modem, rxConfig->bandwidth, phyDr, 1, 0, 8, rxConfig->window_timeout, false, 0, false, 0, 0, true, rxConfig->is_rx_continuous );
|
||||
}
|
||||
|
||||
if( rxConfig->RepeaterSupport == true )
|
||||
if( rxConfig->is_repeater_supported == true )
|
||||
{
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterEU868[dr];
|
||||
}
|
||||
|
@ -830,11 +830,11 @@ bool LoRaPHYEU868::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
}
|
||||
|
||||
bool LoRaPHYEU868::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir)
|
||||
lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t phyDr = DataratesEU868[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
|
@ -842,7 +842,7 @@ bool LoRaPHYEU868::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
|||
phyTxPower = compute_tx_power( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel( Channels[txConfig->Channel].Frequency );
|
||||
_radio->set_channel( Channels[txConfig->Channel].frequency );
|
||||
|
||||
if( txConfig->Datarate == DR_7 )
|
||||
{ // High Speed FSK channel
|
||||
|
@ -911,7 +911,7 @@ uint8_t LoRaPHYEU868::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
{
|
||||
if( linkAdrParams.ChMaskCtrl == 6 )
|
||||
{
|
||||
if( Channels[i].Frequency != 0 )
|
||||
if( Channels[i].frequency != 0 )
|
||||
{
|
||||
chMask |= 1 << i;
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ uint8_t LoRaPHYEU868::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
else
|
||||
{
|
||||
if( ( ( chMask & ( 1 << i ) ) != 0 ) &&
|
||||
( Channels[i].Frequency == 0 ) )
|
||||
( Channels[i].frequency == 0 ) )
|
||||
{// Trying to enable an undefined channel
|
||||
status &= 0xFE; // Channel mask KO
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ uint8_t LoRaPHYEU868::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
if( newChannelReq->NewChannel->Frequency == 0 )
|
||||
if( newChannelReq->NewChannel->frequency == 0 )
|
||||
{
|
||||
channelRemove.ChannelId = newChannelReq->ChannelId;
|
||||
|
||||
|
@ -1018,21 +1018,21 @@ uint8_t LoRaPHYEU868::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
|
||||
switch( add_channel( &channelAdd ) )
|
||||
{
|
||||
case LORAMAC_STATUS_OK:
|
||||
case LORAWAN_STATUS_OK:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQUENCY_INVALID:
|
||||
case LORAWAN_STATUS_FREQUENCY_INVALID:
|
||||
{
|
||||
status &= 0xFE;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_DATARATE_INVALID:
|
||||
case LORAWAN_STATUS_DATARATE_INVALID:
|
||||
{
|
||||
status &= 0xFD;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQ_AND_DR_INVALID:
|
||||
case LORAWAN_STATUS_FREQ_AND_DR_INVALID:
|
||||
{
|
||||
status &= 0xFC;
|
||||
break;
|
||||
|
@ -1065,7 +1065,7 @@ uint8_t LoRaPHYEU868::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
}
|
||||
|
||||
// Verify if an uplink frequency exists
|
||||
if( Channels[dlChannelReq->ChannelId].Frequency == 0 )
|
||||
if( Channels[dlChannelReq->ChannelId].frequency == 0 )
|
||||
{
|
||||
status &= 0xFD;
|
||||
}
|
||||
|
@ -1073,7 +1073,7 @@ uint8_t LoRaPHYEU868::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
// Apply Rx1 frequency, if the status is OK
|
||||
if( status == 0x03 )
|
||||
{
|
||||
Channels[dlChannelReq->ChannelId].Rx1Frequency = dlChannelReq->Rx1Frequency;
|
||||
Channels[dlChannelReq->ChannelId].rx1_frequency = dlChannelReq->Rx1Frequency;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1127,13 +1127,13 @@ void LoRaPHYEU868::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYEU868::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[EU868_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
if( num_active_channels( ChannelsMask, 0, 1 ) == 0 )
|
||||
{ // Reactivate default channels
|
||||
|
@ -1182,7 +1182,7 @@ bool LoRaPHYEU868::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYEU868::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYEU868::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
uint8_t band = 0;
|
||||
bool drInvalid = false;
|
||||
|
@ -1191,19 +1191,19 @@ LoRaMacStatus_t LoRaPHYEU868::add_channel(ChannelAddParams_t* channelAdd)
|
|||
|
||||
if( id >= EU868_MAX_NB_CHANNELS )
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
// Validate the datarate range
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Min, EU868_TX_MIN_DATARATE, EU868_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.min, EU868_TX_MIN_DATARATE, EU868_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, EU868_TX_MIN_DATARATE, EU868_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, EU868_TX_MIN_DATARATE, EU868_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > channelAdd->NewChannel->dr_range.fields.max )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
|
@ -1212,17 +1212,17 @@ LoRaMacStatus_t LoRaPHYEU868::add_channel(ChannelAddParams_t* channelAdd)
|
|||
if( id < EU868_NUMB_DEFAULT_CHANNELS )
|
||||
{
|
||||
// Validate the datarate range for min: must be DR_0
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > DR_0 )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > DR_0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// Validate the datarate range for max: must be DR_5 <= Max <= TX_MAX_DATARATE
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, DR_5, EU868_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, DR_5, EU868_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// We are not allowed to change the frequency
|
||||
if( channelAdd->NewChannel->Frequency != Channels[id].Frequency )
|
||||
if( channelAdd->NewChannel->frequency != Channels[id].frequency )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ LoRaMacStatus_t LoRaPHYEU868::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check frequency
|
||||
if( freqInvalid == false )
|
||||
{
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->Frequency, &band, _radio ) == false )
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->frequency, &band, _radio ) == false )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1240,21 +1240,21 @@ LoRaMacStatus_t LoRaPHYEU868::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check status
|
||||
if( ( drInvalid == true ) && ( freqInvalid == true ) )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQ_AND_DR_INVALID;
|
||||
return LORAWAN_STATUS_FREQ_AND_DR_INVALID;
|
||||
}
|
||||
if( drInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_DATARATE_INVALID;
|
||||
return LORAWAN_STATUS_DATARATE_INVALID;
|
||||
}
|
||||
if( freqInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQUENCY_INVALID;
|
||||
return LORAWAN_STATUS_FREQUENCY_INVALID;
|
||||
}
|
||||
|
||||
memcpy( &(Channels[id]), channelAdd->NewChannel, sizeof( Channels[id] ) );
|
||||
Channels[id].Band = band;
|
||||
Channels[id].band = band;
|
||||
ChannelsMask[0] |= ( 1 << id );
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
bool LoRaPHYEU868::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
|
@ -1267,7 +1267,7 @@ bool LoRaPHYEU868::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
}
|
||||
|
||||
// Remove the channel from the list of channels
|
||||
const ChannelParams_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
const channel_params_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
Channels[id] = empty_channel;
|
||||
|
||||
return disable_channel( ChannelsMask, id, EU868_MAX_NB_CHANNELS );
|
||||
|
@ -1275,9 +1275,9 @@ bool LoRaPHYEU868::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
|
||||
void LoRaPHYEU868::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, continuousWave->MaxEirp, continuousWave->AntennaGain );
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -185,7 +185,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -199,7 +199,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR request.
|
||||
|
@ -289,8 +289,8 @@ public:
|
|||
* \retval The function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -299,7 +299,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -331,18 +331,18 @@ public:
|
|||
virtual uint8_t apply_DR_offset(uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset );
|
||||
|
||||
private:
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
|
||||
// Global attributes
|
||||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[EU868_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[EU868_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[EU868_MAX_NB_BANDS];
|
||||
band_t Bands[EU868_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -293,7 +293,7 @@ static bool VerifyTxFreq( uint32_t freq, uint8_t *band, LoRaRadio *radio )
|
|||
return true;
|
||||
}
|
||||
|
||||
uint8_t LoRaPHYIN865::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
uint8_t LoRaPHYIN865::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTransmission = 0;
|
||||
|
@ -304,7 +304,7 @@ uint8_t LoRaPHYIN865::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
|
@ -315,12 +315,12 @@ uint8_t LoRaPHYIN865::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -337,7 +337,7 @@ uint8_t LoRaPHYIN865::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
LoRaPHYIN865::LoRaPHYIN865(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = IN865_BAND0;
|
||||
const band_t band0 = IN865_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ PhyParam_t LoRaPHYIN865::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYIN865::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYIN865::load_defaults(InitType_t type)
|
||||
|
@ -504,9 +504,9 @@ void LoRaPHYIN865::load_defaults(InitType_t type)
|
|||
case INIT_TYPE_INIT:
|
||||
{
|
||||
// Channels
|
||||
const ChannelParams_t channel1 = IN865_LC1;
|
||||
const ChannelParams_t channel2 = IN865_LC2;
|
||||
const ChannelParams_t channel3 = IN865_LC3;
|
||||
const channel_params_t channel1 = IN865_LC1;
|
||||
const channel_params_t channel2 = IN865_LC2;
|
||||
const channel_params_t channel3 = IN865_LC3;
|
||||
Channels[0] = channel1;
|
||||
Channels[1] = channel2;
|
||||
Channels[2] = channel3;
|
||||
|
@ -572,12 +572,12 @@ bool LoRaPHYIN865::verify(VerifyParams_t* verify, PhyAttribute_t phyAttribute)
|
|||
|
||||
void LoRaPHYIN865::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
||||
{
|
||||
ChannelParams_t newChannel;
|
||||
channel_params_t newChannel;
|
||||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
// Setup default datarate range
|
||||
newChannel.DrRange.Value = ( DR_5 << 4 ) | DR_0;
|
||||
newChannel.dr_range.value = ( DR_5 << 4 ) | DR_0;
|
||||
|
||||
// Size of the optional CF list
|
||||
if( applyCFList->Size != 16 )
|
||||
|
@ -591,22 +591,22 @@ void LoRaPHYIN865::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
|||
if( chanIdx < ( IN865_NUMB_CHANNELS_CF_LIST + IN865_NUMB_DEFAULT_CHANNELS ) )
|
||||
{
|
||||
// Channel frequency
|
||||
newChannel.Frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.Frequency *= 100;
|
||||
newChannel.frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.frequency *= 100;
|
||||
|
||||
// Initialize alternative frequency to 0
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
newChannel.Frequency = 0;
|
||||
newChannel.DrRange.Value = 0;
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.frequency = 0;
|
||||
newChannel.dr_range.value = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
|
||||
if( newChannel.Frequency != 0 )
|
||||
if( newChannel.frequency != 0 )
|
||||
{
|
||||
channelAdd.NewChannel = &newChannel;
|
||||
channelAdd.ChannelId = chanIdx;
|
||||
|
@ -706,47 +706,47 @@ bool LoRaPHYIN865::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYIN865::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, IN865_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, IN865_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
if( rxConfigParams->Datarate == DR_7 )
|
||||
if( rxConfigParams->datarate == DR_7 )
|
||||
{ // FSK
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesIN865[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_fsk( DataratesIN865[rxConfigParams->datarate] );
|
||||
}
|
||||
else
|
||||
{ // LoRa
|
||||
tSymbol = compute_symb_timeout_lora( DataratesIN865[rxConfigParams->Datarate], BandwidthsIN865[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesIN865[rxConfigParams->datarate], BandwidthsIN865[rxConfigParams->datarate] );
|
||||
}
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYIN865::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYIN865::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if( _radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1 )
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = Channels[rxConfig->Channel].Frequency;
|
||||
frequency = Channels[rxConfig->channel].frequency;
|
||||
// Apply the alternative RX 1 window frequency, if it is available
|
||||
if( Channels[rxConfig->Channel].Rx1Frequency != 0 )
|
||||
if( Channels[rxConfig->channel].rx1_frequency != 0 )
|
||||
{
|
||||
frequency = Channels[rxConfig->Channel].Rx1Frequency;
|
||||
frequency = Channels[rxConfig->channel].rx1_frequency;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -759,15 +759,15 @@ bool LoRaPHYIN865::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
if( dr == DR_7 )
|
||||
{
|
||||
modem = MODEM_FSK;
|
||||
_radio->set_rx_config( modem, 50000, phyDr * 1000, 0, 83333, 5, rxConfig->WindowTimeout, false, 0, true, 0, 0, false, rxConfig->RxContinuous );
|
||||
_radio->set_rx_config( modem, 50000, phyDr * 1000, 0, 83333, 5, rxConfig->window_timeout, false, 0, true, 0, 0, false, rxConfig->is_rx_continuous );
|
||||
}
|
||||
else
|
||||
{
|
||||
modem = MODEM_LORA;
|
||||
_radio->set_rx_config( modem, rxConfig->Bandwidth, phyDr, 1, 0, 8, rxConfig->WindowTimeout, false, 0, false, 0, 0, true, rxConfig->RxContinuous );
|
||||
_radio->set_rx_config( modem, rxConfig->bandwidth, phyDr, 1, 0, 8, rxConfig->window_timeout, false, 0, false, 0, 0, true, rxConfig->is_rx_continuous );
|
||||
}
|
||||
|
||||
if( rxConfig->RepeaterSupport == true )
|
||||
if( rxConfig->is_repeater_supported == true )
|
||||
{
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterIN865[dr];
|
||||
}
|
||||
|
@ -781,11 +781,11 @@ bool LoRaPHYIN865::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool LoRaPHYIN865::tx_config(TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir)
|
||||
bool LoRaPHYIN865::tx_config(TxConfigParams_t* txConfig, int8_t* txPower, lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
radio_modems_t modem;
|
||||
int8_t phyDr = DataratesIN865[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
|
@ -793,7 +793,7 @@ bool LoRaPHYIN865::tx_config(TxConfigParams_t* txConfig, int8_t* txPower, TimerT
|
|||
phyTxPower = compute_tx_power( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel( Channels[txConfig->Channel].Frequency );
|
||||
_radio->set_channel( Channels[txConfig->Channel].frequency );
|
||||
|
||||
if( txConfig->Datarate == DR_7 )
|
||||
{ // High Speed FSK channel
|
||||
|
@ -862,7 +862,7 @@ uint8_t LoRaPHYIN865::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
{
|
||||
if( linkAdrParams.ChMaskCtrl == 6 )
|
||||
{
|
||||
if( Channels[i].Frequency != 0 )
|
||||
if( Channels[i].frequency != 0 )
|
||||
{
|
||||
chMask |= 1 << i;
|
||||
}
|
||||
|
@ -870,7 +870,7 @@ uint8_t LoRaPHYIN865::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
else
|
||||
{
|
||||
if( ( ( chMask & ( 1 << i ) ) != 0 ) &&
|
||||
( Channels[i].Frequency == 0 ) )
|
||||
( Channels[i].frequency == 0 ) )
|
||||
{// Trying to enable an undefined channel
|
||||
status &= 0xFE; // Channel mask KO
|
||||
}
|
||||
|
@ -952,7 +952,7 @@ uint8_t LoRaPHYIN865::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
if( newChannelReq->NewChannel->Frequency == 0 )
|
||||
if( newChannelReq->NewChannel->frequency == 0 )
|
||||
{
|
||||
channelRemove.ChannelId = newChannelReq->ChannelId;
|
||||
|
||||
|
@ -969,21 +969,21 @@ uint8_t LoRaPHYIN865::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
|
||||
switch( add_channel( &channelAdd ) )
|
||||
{
|
||||
case LORAMAC_STATUS_OK:
|
||||
case LORAWAN_STATUS_OK:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQUENCY_INVALID:
|
||||
case LORAWAN_STATUS_FREQUENCY_INVALID:
|
||||
{
|
||||
status &= 0xFE;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_DATARATE_INVALID:
|
||||
case LORAWAN_STATUS_DATARATE_INVALID:
|
||||
{
|
||||
status &= 0xFD;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQ_AND_DR_INVALID:
|
||||
case LORAWAN_STATUS_FREQ_AND_DR_INVALID:
|
||||
{
|
||||
status &= 0xFC;
|
||||
break;
|
||||
|
@ -1016,7 +1016,7 @@ uint8_t LoRaPHYIN865::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
}
|
||||
|
||||
// Verify if an uplink frequency exists
|
||||
if( Channels[dlChannelReq->ChannelId].Frequency == 0 )
|
||||
if( Channels[dlChannelReq->ChannelId].frequency == 0 )
|
||||
{
|
||||
status &= 0xFD;
|
||||
}
|
||||
|
@ -1024,7 +1024,7 @@ uint8_t LoRaPHYIN865::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
// Apply Rx1 frequency, if the status is OK
|
||||
if( status == 0x03 )
|
||||
{
|
||||
Channels[dlChannelReq->ChannelId].Rx1Frequency = dlChannelReq->Rx1Frequency;
|
||||
Channels[dlChannelReq->ChannelId].rx1_frequency = dlChannelReq->Rx1Frequency;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1078,13 +1078,13 @@ void LoRaPHYIN865::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYIN865::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[IN865_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
if( num_active_channels( ChannelsMask, 0, 1 ) == 0 )
|
||||
{ // Reactivate default channels
|
||||
|
@ -1133,7 +1133,7 @@ bool LoRaPHYIN865::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYIN865::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYIN865::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
uint8_t band = 0;
|
||||
bool drInvalid = false;
|
||||
|
@ -1142,19 +1142,19 @@ LoRaMacStatus_t LoRaPHYIN865::add_channel(ChannelAddParams_t* channelAdd)
|
|||
|
||||
if( id >= IN865_MAX_NB_CHANNELS )
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
// Validate the datarate range
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Min, IN865_TX_MIN_DATARATE, IN865_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.min, IN865_TX_MIN_DATARATE, IN865_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, IN865_TX_MIN_DATARATE, IN865_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, IN865_TX_MIN_DATARATE, IN865_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > channelAdd->NewChannel->dr_range.fields.max )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
|
@ -1163,17 +1163,17 @@ LoRaMacStatus_t LoRaPHYIN865::add_channel(ChannelAddParams_t* channelAdd)
|
|||
if( id < IN865_NUMB_DEFAULT_CHANNELS )
|
||||
{
|
||||
// Validate the datarate range for min: must be DR_0
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > DR_0 )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > DR_0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// Validate the datarate range for max: must be DR_5 <= Max <= TX_MAX_DATARATE
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, DR_5, IN865_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, DR_5, IN865_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
// We are not allowed to change the frequency
|
||||
if( channelAdd->NewChannel->Frequency != Channels[id].Frequency )
|
||||
if( channelAdd->NewChannel->frequency != Channels[id].frequency )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1182,7 +1182,7 @@ LoRaMacStatus_t LoRaPHYIN865::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check frequency
|
||||
if( freqInvalid == false )
|
||||
{
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->Frequency, &band, _radio ) == false )
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->frequency, &band, _radio ) == false )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1191,21 +1191,21 @@ LoRaMacStatus_t LoRaPHYIN865::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check status
|
||||
if( ( drInvalid == true ) && ( freqInvalid == true ) )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQ_AND_DR_INVALID;
|
||||
return LORAWAN_STATUS_FREQ_AND_DR_INVALID;
|
||||
}
|
||||
if( drInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_DATARATE_INVALID;
|
||||
return LORAWAN_STATUS_DATARATE_INVALID;
|
||||
}
|
||||
if( freqInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQUENCY_INVALID;
|
||||
return LORAWAN_STATUS_FREQUENCY_INVALID;
|
||||
}
|
||||
|
||||
memcpy( &(Channels[id]), channelAdd->NewChannel, sizeof( Channels[id] ) );
|
||||
Channels[id].Band = band;
|
||||
Channels[id].band = band;
|
||||
ChannelsMask[0] |= ( 1 << id );
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
bool LoRaPHYIN865::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
|
@ -1218,7 +1218,7 @@ bool LoRaPHYIN865::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
}
|
||||
|
||||
// Remove the channel from the list of channels
|
||||
const ChannelParams_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
const channel_params_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
Channels[id] = empty_channel;
|
||||
|
||||
return disable_channel( ChannelsMask, id, IN865_MAX_NB_CHANNELS );
|
||||
|
@ -1226,9 +1226,9 @@ bool LoRaPHYIN865::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
|
||||
void LoRaPHYIN865::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, continuousWave->MaxEirp, continuousWave->AntennaGain );
|
||||
|
|
|
@ -132,7 +132,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -188,7 +188,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -202,7 +202,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR request.
|
||||
|
@ -292,8 +292,8 @@ public:
|
|||
* \retval The function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -302,7 +302,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -334,18 +334,18 @@ public:
|
|||
virtual uint8_t apply_DR_offset(uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset );
|
||||
|
||||
private:
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
|
||||
// Global attributes
|
||||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[IN865_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[IN865_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[IN865_MAX_NB_BANDS];
|
||||
band_t Bands[IN865_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -318,7 +318,7 @@ static bool VerifyTxFreq( uint32_t freq, LoRaRadio *radio )
|
|||
return false;
|
||||
}
|
||||
|
||||
uint8_t LoRaPHYKR920::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
uint8_t LoRaPHYKR920::CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTransmission = 0;
|
||||
|
@ -329,7 +329,7 @@ uint8_t LoRaPHYKR920::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
|
@ -340,12 +340,12 @@ uint8_t LoRaPHYKR920::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -362,7 +362,7 @@ uint8_t LoRaPHYKR920::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
|||
LoRaPHYKR920::LoRaPHYKR920(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = KR920_BAND0;
|
||||
const band_t band0 = KR920_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ PhyParam_t LoRaPHYKR920::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYKR920::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYKR920::load_defaults(InitType_t type)
|
||||
|
@ -533,9 +533,9 @@ void LoRaPHYKR920::load_defaults(InitType_t type)
|
|||
case INIT_TYPE_INIT:
|
||||
{
|
||||
// Channels
|
||||
const ChannelParams_t channel1 = KR920_LC1;
|
||||
const ChannelParams_t channel2 = KR920_LC2;
|
||||
const ChannelParams_t channel3 = KR920_LC3;
|
||||
const channel_params_t channel1 = KR920_LC1;
|
||||
const channel_params_t channel2 = KR920_LC2;
|
||||
const channel_params_t channel3 = KR920_LC3;
|
||||
Channels[0] = channel1;
|
||||
Channels[1] = channel2;
|
||||
Channels[2] = channel3;
|
||||
|
@ -601,12 +601,12 @@ bool LoRaPHYKR920::verify( VerifyParams_t* verify, PhyAttribute_t phyAttribute )
|
|||
|
||||
void LoRaPHYKR920::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
||||
{
|
||||
ChannelParams_t newChannel;
|
||||
channel_params_t newChannel;
|
||||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
// Setup default datarate range
|
||||
newChannel.DrRange.Value = ( DR_5 << 4 ) | DR_0;
|
||||
newChannel.dr_range.value = ( DR_5 << 4 ) | DR_0;
|
||||
|
||||
// Size of the optional CF list
|
||||
if( applyCFList->Size != 16 )
|
||||
|
@ -620,22 +620,22 @@ void LoRaPHYKR920::apply_cf_list(ApplyCFListParams_t* applyCFList)
|
|||
if( chanIdx < ( KR920_NUMB_CHANNELS_CF_LIST + KR920_NUMB_DEFAULT_CHANNELS ) )
|
||||
{
|
||||
// Channel frequency
|
||||
newChannel.Frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.Frequency *= 100;
|
||||
newChannel.frequency = (uint32_t) applyCFList->Payload[i];
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
|
||||
newChannel.frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
|
||||
newChannel.frequency *= 100;
|
||||
|
||||
// Initialize alternative frequency to 0
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
newChannel.Frequency = 0;
|
||||
newChannel.DrRange.Value = 0;
|
||||
newChannel.Rx1Frequency = 0;
|
||||
newChannel.frequency = 0;
|
||||
newChannel.dr_range.value = 0;
|
||||
newChannel.rx1_frequency = 0;
|
||||
}
|
||||
|
||||
if( newChannel.Frequency != 0 )
|
||||
if( newChannel.frequency != 0 )
|
||||
{
|
||||
channelAdd.NewChannel = &newChannel;
|
||||
channelAdd.ChannelId = chanIdx;
|
||||
|
@ -735,39 +735,39 @@ bool LoRaPHYKR920::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYKR920::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, KR920_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, KR920_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
tSymbol = compute_symb_timeout_lora( DataratesKR920[rxConfigParams->Datarate], BandwidthsKR920[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesKR920[rxConfigParams->datarate], BandwidthsKR920[rxConfigParams->datarate] );
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYKR920::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYKR920::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if( _radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1 )
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = Channels[rxConfig->Channel].Frequency;
|
||||
frequency = Channels[rxConfig->channel].frequency;
|
||||
// Apply the alternative RX 1 window frequency, if it is available
|
||||
if( Channels[rxConfig->Channel].Rx1Frequency != 0 )
|
||||
if( Channels[rxConfig->channel].rx1_frequency != 0 )
|
||||
{
|
||||
frequency = Channels[rxConfig->Channel].Rx1Frequency;
|
||||
frequency = Channels[rxConfig->channel].rx1_frequency;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -777,9 +777,9 @@ bool LoRaPHYKR920::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
_radio->set_channel( frequency );
|
||||
|
||||
// Radio configuration
|
||||
_radio->set_rx_config( MODEM_LORA, rxConfig->Bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->WindowTimeout, false, 0, false, 0, 0, true,
|
||||
rxConfig->RxContinuous );
|
||||
_radio->set_rx_config( MODEM_LORA, rxConfig->bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->window_timeout, false, 0, false, 0, 0, true,
|
||||
rxConfig->is_rx_continuous );
|
||||
maxPayload = MaxPayloadOfDatarateKR920[dr];
|
||||
_radio->set_max_payload_length( MODEM_LORA, maxPayload + LORA_MAC_FRMPAYLOAD_OVERHEAD );
|
||||
|
||||
|
@ -787,12 +787,12 @@ bool LoRaPHYKR920::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool LoRaPHYKR920::tx_config(TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir)
|
||||
bool LoRaPHYKR920::tx_config(TxConfigParams_t* txConfig, int8_t* txPower, lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
int8_t phyDr = DataratesKR920[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
|
||||
float maxEIRP = GetMaxEIRP( Channels[txConfig->Channel].Frequency );
|
||||
float maxEIRP = GetMaxEIRP( Channels[txConfig->Channel].frequency );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
// Take the minimum between the maxEIRP and txConfig->MaxEirp.
|
||||
|
@ -803,7 +803,7 @@ bool LoRaPHYKR920::tx_config(TxConfigParams_t* txConfig, int8_t* txPower, TimerT
|
|||
phyTxPower = compute_tx_power( txPowerLimited, maxEIRP, txConfig->AntennaGain );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel( Channels[txConfig->Channel].Frequency );
|
||||
_radio->set_channel( Channels[txConfig->Channel].frequency );
|
||||
|
||||
_radio->set_tx_config( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3000 );
|
||||
|
||||
|
@ -863,7 +863,7 @@ uint8_t LoRaPHYKR920::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
{
|
||||
if( linkAdrParams.ChMaskCtrl == 6 )
|
||||
{
|
||||
if( Channels[i].Frequency != 0 )
|
||||
if( Channels[i].frequency != 0 )
|
||||
{
|
||||
chMask |= 1 << i;
|
||||
}
|
||||
|
@ -871,7 +871,7 @@ uint8_t LoRaPHYKR920::link_ADR_request(LinkAdrReqParams_t* linkAdrReq,
|
|||
else
|
||||
{
|
||||
if( ( ( chMask & ( 1 << i ) ) != 0 ) &&
|
||||
( Channels[i].Frequency == 0 ) )
|
||||
( Channels[i].frequency == 0 ) )
|
||||
{// Trying to enable an undefined channel
|
||||
status &= 0xFE; // Channel mask KO
|
||||
}
|
||||
|
@ -953,7 +953,7 @@ uint8_t LoRaPHYKR920::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
ChannelAddParams_t channelAdd;
|
||||
ChannelRemoveParams_t channelRemove;
|
||||
|
||||
if( newChannelReq->NewChannel->Frequency == 0 )
|
||||
if( newChannelReq->NewChannel->frequency == 0 )
|
||||
{
|
||||
channelRemove.ChannelId = newChannelReq->ChannelId;
|
||||
|
||||
|
@ -970,21 +970,21 @@ uint8_t LoRaPHYKR920::request_new_channel(NewChannelReqParams_t* newChannelReq)
|
|||
|
||||
switch( add_channel( &channelAdd ) )
|
||||
{
|
||||
case LORAMAC_STATUS_OK:
|
||||
case LORAWAN_STATUS_OK:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQUENCY_INVALID:
|
||||
case LORAWAN_STATUS_FREQUENCY_INVALID:
|
||||
{
|
||||
status &= 0xFE;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_DATARATE_INVALID:
|
||||
case LORAWAN_STATUS_DATARATE_INVALID:
|
||||
{
|
||||
status &= 0xFD;
|
||||
break;
|
||||
}
|
||||
case LORAMAC_STATUS_FREQ_AND_DR_INVALID:
|
||||
case LORAWAN_STATUS_FREQ_AND_DR_INVALID:
|
||||
{
|
||||
status &= 0xFC;
|
||||
break;
|
||||
|
@ -1016,7 +1016,7 @@ uint8_t LoRaPHYKR920::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
}
|
||||
|
||||
// Verify if an uplink frequency exists
|
||||
if( Channels[dlChannelReq->ChannelId].Frequency == 0 )
|
||||
if( Channels[dlChannelReq->ChannelId].frequency == 0 )
|
||||
{
|
||||
status &= 0xFD;
|
||||
}
|
||||
|
@ -1024,7 +1024,7 @@ uint8_t LoRaPHYKR920::dl_channel_request(DlChannelReqParams_t* dlChannelReq)
|
|||
// Apply Rx1 frequency, if the status is OK
|
||||
if( status == 0x03 )
|
||||
{
|
||||
Channels[dlChannelReq->ChannelId].Rx1Frequency = dlChannelReq->Rx1Frequency;
|
||||
Channels[dlChannelReq->ChannelId].rx1_frequency = dlChannelReq->Rx1Frequency;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1078,14 +1078,14 @@ void LoRaPHYKR920::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYKR920::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t channelNext = 0;
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[KR920_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
if( num_active_channels( ChannelsMask, 0, 1 ) == 0 )
|
||||
{ // Reactivate default channels
|
||||
|
@ -1121,7 +1121,7 @@ bool LoRaPHYKR920::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
// Perform carrier sense for KR920_CARRIER_SENSE_TIME
|
||||
// If the channel is free, we can stop the LBT mechanism
|
||||
if( _radio->perform_carrier_sense( MODEM_LORA,
|
||||
Channels[channelNext].Frequency,
|
||||
Channels[channelNext].frequency,
|
||||
KR920_RSSI_FREE_TH,
|
||||
KR920_CARRIER_SENSE_TIME ) == true )
|
||||
{
|
||||
|
@ -1148,7 +1148,7 @@ bool LoRaPHYKR920::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYKR920::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYKR920::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
uint8_t band = 0;
|
||||
bool drInvalid = false;
|
||||
|
@ -1157,19 +1157,19 @@ LoRaMacStatus_t LoRaPHYKR920::add_channel(ChannelAddParams_t* channelAdd)
|
|||
|
||||
if( id >= KR920_MAX_NB_CHANNELS )
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
// Validate the datarate range
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Min, KR920_TX_MIN_DATARATE, KR920_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.min, KR920_TX_MIN_DATARATE, KR920_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( val_in_range( channelAdd->NewChannel->DrRange.Fields.Max, KR920_TX_MIN_DATARATE, KR920_TX_MAX_DATARATE ) == 0 )
|
||||
if( val_in_range( channelAdd->NewChannel->dr_range.fields.max, KR920_TX_MIN_DATARATE, KR920_TX_MAX_DATARATE ) == 0 )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
if( channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max )
|
||||
if( channelAdd->NewChannel->dr_range.fields.min > channelAdd->NewChannel->dr_range.fields.max )
|
||||
{
|
||||
drInvalid = true;
|
||||
}
|
||||
|
@ -1179,7 +1179,7 @@ LoRaMacStatus_t LoRaPHYKR920::add_channel(ChannelAddParams_t* channelAdd)
|
|||
{
|
||||
// All datarates are supported
|
||||
// We are not allowed to change the frequency
|
||||
if( channelAdd->NewChannel->Frequency != Channels[id].Frequency )
|
||||
if( channelAdd->NewChannel->frequency != Channels[id].frequency )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1188,7 +1188,7 @@ LoRaMacStatus_t LoRaPHYKR920::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check frequency
|
||||
if( freqInvalid == false )
|
||||
{
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->Frequency, _radio ) == false )
|
||||
if( VerifyTxFreq( channelAdd->NewChannel->frequency, _radio ) == false )
|
||||
{
|
||||
freqInvalid = true;
|
||||
}
|
||||
|
@ -1197,21 +1197,21 @@ LoRaMacStatus_t LoRaPHYKR920::add_channel(ChannelAddParams_t* channelAdd)
|
|||
// Check status
|
||||
if( ( drInvalid == true ) && ( freqInvalid == true ) )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQ_AND_DR_INVALID;
|
||||
return LORAWAN_STATUS_FREQ_AND_DR_INVALID;
|
||||
}
|
||||
if( drInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_DATARATE_INVALID;
|
||||
return LORAWAN_STATUS_DATARATE_INVALID;
|
||||
}
|
||||
if( freqInvalid == true )
|
||||
{
|
||||
return LORAMAC_STATUS_FREQUENCY_INVALID;
|
||||
return LORAWAN_STATUS_FREQUENCY_INVALID;
|
||||
}
|
||||
|
||||
memcpy( &(Channels[id]), channelAdd->NewChannel, sizeof( Channels[id] ) );
|
||||
Channels[id].Band = band;
|
||||
Channels[id].band = band;
|
||||
ChannelsMask[0] |= ( 1 << id );
|
||||
return LORAMAC_STATUS_OK;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
bool LoRaPHYKR920::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
|
@ -1224,7 +1224,7 @@ bool LoRaPHYKR920::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
}
|
||||
|
||||
// Remove the channel from the list of channels
|
||||
const ChannelParams_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
const channel_params_t empty_channel = { 0, 0, { 0 }, 0 };
|
||||
Channels[id] = empty_channel;
|
||||
|
||||
return disable_channel( ChannelsMask, id, KR920_MAX_NB_CHANNELS );
|
||||
|
@ -1232,10 +1232,10 @@ bool LoRaPHYKR920::remove_channel(ChannelRemoveParams_t* channelRemove)
|
|||
|
||||
void LoRaPHYKR920::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
float maxEIRP = GetMaxEIRP( Channels[continuousWave->Channel].Frequency );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
float maxEIRP = GetMaxEIRP( Channels[continuousWave->Channel].frequency );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Take the minimum between the maxEIRP and continuousWave->MaxEirp.
|
||||
// The value of continuousWave->MaxEirp could have changed during runtime, e.g. due to a MAC command.
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -200,7 +200,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR request.
|
||||
|
@ -290,8 +290,8 @@ public:
|
|||
* \retval The function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -300,7 +300,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -331,18 +331,18 @@ public:
|
|||
*/
|
||||
virtual uint8_t apply_DR_offset(uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset );
|
||||
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
uint8_t CountNbOfEnabledChannels( bool joined, uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
|
||||
// Global attributes
|
||||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[KR920_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[KR920_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[KR920_MAX_NB_BANDS];
|
||||
band_t Bands[KR920_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -264,7 +264,7 @@ int8_t LoRaPHYUS915::LimitTxPower( int8_t txPower, int8_t maxBandTxPower, int8_t
|
|||
return txPowerResult;
|
||||
}
|
||||
|
||||
uint8_t LoRaPHYUS915::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
uint8_t LoRaPHYUS915::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTransmission = 0;
|
||||
|
@ -275,16 +275,16 @@ uint8_t LoRaPHYUS915::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* chan
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -301,7 +301,7 @@ uint8_t LoRaPHYUS915::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* chan
|
|||
LoRaPHYUS915::LoRaPHYUS915(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = US915_BAND0;
|
||||
const band_t band0 = US915_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ PhyParam_t LoRaPHYUS915::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYUS915::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYUS915::load_defaults(InitType_t type)
|
||||
|
@ -467,16 +467,16 @@ void LoRaPHYUS915::load_defaults(InitType_t type)
|
|||
// 125 kHz channels
|
||||
for( uint8_t i = 0; i < US915_MAX_NB_CHANNELS - 8; i++ )
|
||||
{
|
||||
Channels[i].Frequency = 902300000 + i * 200000;
|
||||
Channels[i].DrRange.Value = ( DR_3 << 4 ) | DR_0;
|
||||
Channels[i].Band = 0;
|
||||
Channels[i].frequency = 902300000 + i * 200000;
|
||||
Channels[i].dr_range.value = ( DR_3 << 4 ) | DR_0;
|
||||
Channels[i].band = 0;
|
||||
}
|
||||
// 500 kHz channels
|
||||
for( uint8_t i = US915_MAX_NB_CHANNELS - 8; i < US915_MAX_NB_CHANNELS; i++ )
|
||||
{
|
||||
Channels[i].Frequency = 903000000 + ( i - ( US915_MAX_NB_CHANNELS - 8 ) ) * 1600000;
|
||||
Channels[i].DrRange.Value = ( DR_4 << 4 ) | DR_4;
|
||||
Channels[i].Band = 0;
|
||||
Channels[i].frequency = 903000000 + ( i - ( US915_MAX_NB_CHANNELS - 8 ) ) * 1600000;
|
||||
Channels[i].dr_range.value = ( DR_4 << 4 ) | DR_4;
|
||||
Channels[i].band = 0;
|
||||
}
|
||||
|
||||
// ChannelsMask
|
||||
|
@ -659,35 +659,35 @@ bool LoRaPHYUS915::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
|
||||
void LoRaPHYUS915::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams)
|
||||
rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, US915_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, US915_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
tSymbol = compute_symb_timeout_lora( DataratesUS915[rxConfigParams->Datarate], BandwidthsUS915[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesUS915[rxConfigParams->datarate], BandwidthsUS915[rxConfigParams->datarate] );
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYUS915::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYUS915::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if(_radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1 )
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = US915_FIRST_RX1_CHANNEL + ( rxConfig->Channel % 8 ) * US915_STEPWIDTH_RX1_CHANNEL;
|
||||
frequency = US915_FIRST_RX1_CHANNEL + ( rxConfig->channel % 8 ) * US915_STEPWIDTH_RX1_CHANNEL;
|
||||
}
|
||||
|
||||
// Read the physical datarate from the datarates table
|
||||
|
@ -696,11 +696,11 @@ bool LoRaPHYUS915::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
_radio->set_channel( frequency );
|
||||
|
||||
// Radio configuration
|
||||
_radio->set_rx_config( MODEM_LORA, rxConfig->Bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->WindowTimeout, false, 0, false, 0, 0, true,
|
||||
rxConfig->RxContinuous );
|
||||
_radio->set_rx_config( MODEM_LORA, rxConfig->bandwidth, phyDr, 1, 0, 8,
|
||||
rxConfig->window_timeout, false, 0, false, 0, 0, true,
|
||||
rxConfig->is_rx_continuous );
|
||||
|
||||
if( rxConfig->RepeaterSupport == true )
|
||||
if( rxConfig->is_repeater_supported == true )
|
||||
{
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterUS915[dr];
|
||||
}
|
||||
|
@ -715,10 +715,10 @@ bool LoRaPHYUS915::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
}
|
||||
|
||||
bool LoRaPHYUS915::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir)
|
||||
lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
int8_t phyDr = DataratesUS915[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
|
@ -726,7 +726,7 @@ bool LoRaPHYUS915::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
|||
phyTxPower = compute_tx_power( txPowerLimited, US915_DEFAULT_MAX_ERP, 0 );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel( Channels[txConfig->Channel].Frequency );
|
||||
_radio->set_channel( Channels[txConfig->Channel].frequency );
|
||||
|
||||
_radio->set_tx_config( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8,
|
||||
false, true, 0, 0, false, 3000 );
|
||||
|
@ -938,13 +938,13 @@ void LoRaPHYUS915::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYUS915::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[US915_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
// Count 125kHz channels
|
||||
if( num_active_channels( ChannelsMaskRemaining, 0, 4 ) == 0 )
|
||||
|
@ -1003,21 +1003,21 @@ bool LoRaPHYUS915::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYUS915::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYUS915::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
bool LoRaPHYUS915::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
void LoRaPHYUS915::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, US915_DEFAULT_MAX_ERP, 0 );
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -200,7 +200,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR request.
|
||||
|
@ -290,8 +290,8 @@ public:
|
|||
* \retval The function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -300,7 +300,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -333,18 +333,18 @@ public:
|
|||
|
||||
private:
|
||||
int8_t LimitTxPower( int8_t txPower, int8_t maxBandTxPower, int8_t datarate, uint16_t* channelsMask );
|
||||
uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
|
||||
// Global attributes
|
||||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[US915_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[US915_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[US915_MAX_NB_BANDS];
|
||||
band_t Bands[US915_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -354,7 +354,7 @@ static bool ValidateChannelsMask( uint16_t* channelsMask )
|
|||
return chanMaskState;
|
||||
}
|
||||
|
||||
uint8_t LoRaPHYUS915Hybrid::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
uint8_t LoRaPHYUS915Hybrid::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx )
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTransmission = 0;
|
||||
|
@ -365,16 +365,16 @@ uint8_t LoRaPHYUS915Hybrid::CountNbOfEnabledChannels( uint8_t datarate, uint16_t
|
|||
{
|
||||
if( ( channelsMask[k] & ( 1 << j ) ) != 0 )
|
||||
{
|
||||
if( channels[i + j].Frequency == 0 )
|
||||
if( channels[i + j].frequency == 0 )
|
||||
{ // Check if the channel is enabled
|
||||
continue;
|
||||
}
|
||||
if( val_in_range( datarate, channels[i + j].DrRange.Fields.Min,
|
||||
channels[i + j].DrRange.Fields.Max ) == 0 )
|
||||
if( val_in_range( datarate, channels[i + j].dr_range.fields.min,
|
||||
channels[i + j].dr_range.fields.max ) == 0 )
|
||||
{ // Check if the current channel selection supports the given datarate
|
||||
continue;
|
||||
}
|
||||
if( bands[channels[i + j].Band].TimeOff > 0 )
|
||||
if( bands[channels[i + j].band].off_time > 0 )
|
||||
{ // Check if the band is available for transmission
|
||||
delayTransmission++;
|
||||
continue;
|
||||
|
@ -391,7 +391,7 @@ uint8_t LoRaPHYUS915Hybrid::CountNbOfEnabledChannels( uint8_t datarate, uint16_t
|
|||
LoRaPHYUS915Hybrid::LoRaPHYUS915Hybrid(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
{
|
||||
const Band_t band0 = US915_HYBRID_BAND0;
|
||||
const band_t band0 = US915_HYBRID_BAND0;
|
||||
Bands[0] = band0;
|
||||
}
|
||||
|
||||
|
@ -544,7 +544,7 @@ PhyParam_t LoRaPHYUS915Hybrid::get_phy_params(GetPhyParams_t* getPhy)
|
|||
|
||||
void LoRaPHYUS915Hybrid::set_band_tx_done(SetBandTxDoneParams_t* txDone)
|
||||
{
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].Band], txDone->LastTxDoneTime );
|
||||
set_last_tx_done( txDone->Joined, &Bands[Channels[txDone->Channel].band], txDone->LastTxDoneTime );
|
||||
}
|
||||
|
||||
void LoRaPHYUS915Hybrid::load_defaults(InitType_t type)
|
||||
|
@ -557,16 +557,16 @@ void LoRaPHYUS915Hybrid::load_defaults(InitType_t type)
|
|||
// 125 kHz channels
|
||||
for( uint8_t i = 0; i < US915_HYBRID_MAX_NB_CHANNELS - 8; i++ )
|
||||
{
|
||||
Channels[i].Frequency = 902300000 + i * 200000;
|
||||
Channels[i].DrRange.Value = ( DR_3 << 4 ) | DR_0;
|
||||
Channels[i].Band = 0;
|
||||
Channels[i].frequency = 902300000 + i * 200000;
|
||||
Channels[i].dr_range.value = ( DR_3 << 4 ) | DR_0;
|
||||
Channels[i].band = 0;
|
||||
}
|
||||
// 500 kHz channels
|
||||
for( uint8_t i = US915_HYBRID_MAX_NB_CHANNELS - 8; i < US915_HYBRID_MAX_NB_CHANNELS; i++ )
|
||||
{
|
||||
Channels[i].Frequency = 903000000 + ( i - ( US915_HYBRID_MAX_NB_CHANNELS - 8 ) ) * 1600000;
|
||||
Channels[i].DrRange.Value = ( DR_4 << 4 ) | DR_4;
|
||||
Channels[i].Band = 0;
|
||||
Channels[i].frequency = 903000000 + ( i - ( US915_HYBRID_MAX_NB_CHANNELS - 8 ) ) * 1600000;
|
||||
Channels[i].dr_range.value = ( DR_4 << 4 ) | DR_4;
|
||||
Channels[i].band = 0;
|
||||
}
|
||||
|
||||
// ChannelsMask
|
||||
|
@ -747,35 +747,35 @@ bool LoRaPHYUS915Hybrid::get_next_ADR(AdrNextParams_t* adrNext, int8_t* drOut,
|
|||
}
|
||||
|
||||
void LoRaPHYUS915Hybrid::compute_rx_win_params(int8_t datarate, uint8_t minRxSymbols,
|
||||
uint32_t rxError, RxConfigParams_t *rxConfigParams)
|
||||
uint32_t rxError, rx_config_params_t *rxConfigParams)
|
||||
{
|
||||
double tSymbol = 0.0;
|
||||
|
||||
// Get the datarate, perform a boundary check
|
||||
rxConfigParams->Datarate = MIN( datarate, US915_HYBRID_RX_MAX_DATARATE );
|
||||
rxConfigParams->Bandwidth = GetBandwidth( rxConfigParams->Datarate );
|
||||
rxConfigParams->datarate = MIN( datarate, US915_HYBRID_RX_MAX_DATARATE );
|
||||
rxConfigParams->bandwidth = GetBandwidth( rxConfigParams->datarate );
|
||||
|
||||
tSymbol = compute_symb_timeout_lora( DataratesUS915_HYBRID[rxConfigParams->Datarate], BandwidthsUS915_HYBRID[rxConfigParams->Datarate] );
|
||||
tSymbol = compute_symb_timeout_lora( DataratesUS915_HYBRID[rxConfigParams->datarate], BandwidthsUS915_HYBRID[rxConfigParams->datarate] );
|
||||
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
|
||||
get_rx_window_params( tSymbol, minRxSymbols, rxError, RADIO_WAKEUP_TIME, &rxConfigParams->window_timeout, &rxConfigParams->window_offset );
|
||||
}
|
||||
|
||||
bool LoRaPHYUS915Hybrid::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
||||
bool LoRaPHYUS915Hybrid::rx_config(rx_config_params_t* rxConfig, int8_t* datarate)
|
||||
{
|
||||
int8_t dr = rxConfig->Datarate;
|
||||
int8_t dr = rxConfig->datarate;
|
||||
uint8_t maxPayload = 0;
|
||||
int8_t phyDr = 0;
|
||||
uint32_t frequency = rxConfig->Frequency;
|
||||
uint32_t frequency = rxConfig->frequency;
|
||||
|
||||
if( _radio->get_status() != RF_IDLE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
|
||||
if( rxConfig->rx_slot == RX_SLOT_WIN_1 )
|
||||
{
|
||||
// Apply window 1 frequency
|
||||
frequency = US915_HYBRID_FIRST_RX1_CHANNEL + ( rxConfig->Channel % 8 ) * US915_HYBRID_STEPWIDTH_RX1_CHANNEL;
|
||||
frequency = US915_HYBRID_FIRST_RX1_CHANNEL + ( rxConfig->channel % 8 ) * US915_HYBRID_STEPWIDTH_RX1_CHANNEL;
|
||||
}
|
||||
|
||||
// Read the physical datarate from the datarates table
|
||||
|
@ -784,9 +784,9 @@ bool LoRaPHYUS915Hybrid::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
_radio->set_channel( frequency );
|
||||
|
||||
// Radio configuration
|
||||
_radio->set_rx_config( MODEM_LORA, rxConfig->Bandwidth, phyDr, 1, 0, 8, rxConfig->WindowTimeout, false, 0, false, 0, 0, true, rxConfig->RxContinuous );
|
||||
_radio->set_rx_config( MODEM_LORA, rxConfig->bandwidth, phyDr, 1, 0, 8, rxConfig->window_timeout, false, 0, false, 0, 0, true, rxConfig->is_rx_continuous );
|
||||
|
||||
if( rxConfig->RepeaterSupport == true )
|
||||
if( rxConfig->is_repeater_supported == true )
|
||||
{
|
||||
maxPayload = MaxPayloadOfDatarateRepeaterUS915_HYBRID[dr];
|
||||
}
|
||||
|
@ -801,10 +801,10 @@ bool LoRaPHYUS915Hybrid::rx_config(RxConfigParams_t* rxConfig, int8_t* datarate)
|
|||
}
|
||||
|
||||
bool LoRaPHYUS915Hybrid::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir)
|
||||
lorawan_time_t* txTimeOnAir)
|
||||
{
|
||||
int8_t phyDr = DataratesUS915_HYBRID[txConfig->Datarate];
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].Band].TxMaxPower, txConfig->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( txConfig->TxPower, Bands[Channels[txConfig->Channel].band].max_tx_pwr, txConfig->Datarate, ChannelsMask );
|
||||
uint32_t bandwidth = GetBandwidth( txConfig->Datarate );
|
||||
int8_t phyTxPower = 0;
|
||||
|
||||
|
@ -812,7 +812,7 @@ bool LoRaPHYUS915Hybrid::tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
|||
phyTxPower = compute_tx_power( txPowerLimited, US915_HYBRID_DEFAULT_MAX_ERP, 0 );
|
||||
|
||||
// Setup the radio frequency
|
||||
_radio->set_channel( Channels[txConfig->Channel].Frequency );
|
||||
_radio->set_channel( Channels[txConfig->Channel].frequency );
|
||||
|
||||
_radio->set_tx_config( MODEM_LORA, phyTxPower, 0, bandwidth, phyDr, 1, 8, false, true, 0, 0, false, 3000 );
|
||||
|
||||
|
@ -1029,13 +1029,13 @@ void LoRaPHYUS915Hybrid::calculate_backoff(CalcBackOffParams_t* calcBackOff)
|
|||
}
|
||||
|
||||
bool LoRaPHYUS915Hybrid::set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff)
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff)
|
||||
{
|
||||
uint8_t nbEnabledChannels = 0;
|
||||
uint8_t delayTx = 0;
|
||||
uint8_t enabledChannels[US915_HYBRID_MAX_NB_CHANNELS] = { 0 };
|
||||
TimerTime_t nextTxDelay = 0;
|
||||
lorawan_time_t nextTxDelay = 0;
|
||||
|
||||
// Count 125kHz channels
|
||||
if( num_active_channels( ChannelsMaskRemaining, 0, 4 ) == 0 )
|
||||
|
@ -1094,21 +1094,21 @@ bool LoRaPHYUS915Hybrid::set_next_channel(NextChanParams_t* nextChanParams,
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaPHYUS915Hybrid::add_channel(ChannelAddParams_t* channelAdd)
|
||||
lorawan_status_t LoRaPHYUS915Hybrid::add_channel(ChannelAddParams_t* channelAdd)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
bool LoRaPHYUS915Hybrid::remove_channel(ChannelRemoveParams_t* channelRemove)
|
||||
{
|
||||
return LORAMAC_STATUS_PARAMETER_INVALID;
|
||||
return LORAWAN_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
|
||||
void LoRaPHYUS915Hybrid::set_tx_cont_mode(ContinuousWaveParams_t* continuousWave)
|
||||
{
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].Band].TxMaxPower, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t txPowerLimited = LimitTxPower( continuousWave->TxPower, Bands[Channels[continuousWave->Channel].band].max_tx_pwr, continuousWave->Datarate, ChannelsMask );
|
||||
int8_t phyTxPower = 0;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].Frequency;
|
||||
uint32_t frequency = Channels[continuousWave->Channel].frequency;
|
||||
|
||||
// Calculate physical TX power
|
||||
phyTxPower = compute_tx_power( txPowerLimited, US915_HYBRID_DEFAULT_MAX_ERP, 0 );
|
||||
|
|
|
@ -131,7 +131,7 @@ public:
|
|||
*
|
||||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool rx_config(RxConfigParams_t* rxConfig, int8_t* datarate );
|
||||
virtual bool rx_config(rx_config_params_t* rxConfig, int8_t* datarate );
|
||||
|
||||
/*
|
||||
* RX window precise timing
|
||||
|
@ -187,7 +187,7 @@ public:
|
|||
virtual void compute_rx_win_params(int8_t datarate,
|
||||
uint8_t minRxSymbols,
|
||||
uint32_t rxError,
|
||||
RxConfigParams_t *rxConfigParams);
|
||||
rx_config_params_t *rxConfigParams);
|
||||
|
||||
/*!
|
||||
* \brief TX configuration.
|
||||
|
@ -201,7 +201,7 @@ public:
|
|||
* \retval True, if the configuration was applied successfully.
|
||||
*/
|
||||
virtual bool tx_config(TxConfigParams_t* txConfig, int8_t* txPower,
|
||||
TimerTime_t* txTimeOnAir );
|
||||
lorawan_time_t* txTimeOnAir );
|
||||
|
||||
/*!
|
||||
* \brief The function processes a Link ADR request.
|
||||
|
@ -291,8 +291,8 @@ public:
|
|||
* \retval The function status [1: OK, 0: Unable to find a channel on the current datarate].
|
||||
*/
|
||||
virtual bool set_next_channel(NextChanParams_t* nextChanParams,
|
||||
uint8_t* channel, TimerTime_t* time,
|
||||
TimerTime_t* aggregatedTimeOff );
|
||||
uint8_t* channel, lorawan_time_t* time,
|
||||
lorawan_time_t* aggregatedTimeOff );
|
||||
|
||||
/*!
|
||||
* \brief Adds a channel.
|
||||
|
@ -301,7 +301,7 @@ public:
|
|||
*
|
||||
* \retval The status of the operation.
|
||||
*/
|
||||
virtual LoRaMacStatus_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
virtual lorawan_status_t add_channel(ChannelAddParams_t* channelAdd );
|
||||
|
||||
/*!
|
||||
* \brief Removes a channel.
|
||||
|
@ -334,18 +334,18 @@ public:
|
|||
|
||||
private:
|
||||
int8_t LimitTxPower( int8_t txPower, int8_t maxBandTxPower, int8_t datarate, uint16_t* channelsMask );
|
||||
uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, ChannelParams_t* channels, Band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
uint8_t CountNbOfEnabledChannels( uint8_t datarate, uint16_t* channelsMask, channel_params_t* channels, band_t* bands, uint8_t* enabledChannels, uint8_t* delayTx );
|
||||
|
||||
// Global attributes
|
||||
/*!
|
||||
* LoRaMAC channels
|
||||
*/
|
||||
ChannelParams_t Channels[US915_HYBRID_MAX_NB_CHANNELS];
|
||||
channel_params_t Channels[US915_HYBRID_MAX_NB_CHANNELS];
|
||||
|
||||
/*!
|
||||
* LoRaMac bands
|
||||
*/
|
||||
Band_t Bands[US915_HYBRID_MAX_NB_BANDS];
|
||||
band_t Bands[US915_HYBRID_MAX_NB_BANDS];
|
||||
|
||||
/*!
|
||||
* LoRaMac channels mask
|
||||
|
|
|
@ -713,7 +713,7 @@ typedef union uPhyParam
|
|||
/*!
|
||||
* A pointer to the channels.
|
||||
*/
|
||||
ChannelParams_t* Channels;
|
||||
channel_params_t* Channels;
|
||||
}PhyParam_t;
|
||||
|
||||
/*!
|
||||
|
@ -761,7 +761,7 @@ typedef struct sSetBandTxDoneParams
|
|||
/*!
|
||||
* The last TX done time.
|
||||
*/
|
||||
TimerTime_t LastTxDoneTime;
|
||||
lorawan_time_t LastTxDoneTime;
|
||||
}SetBandTxDoneParams_t;
|
||||
|
||||
/*!
|
||||
|
@ -955,7 +955,7 @@ typedef struct sNewChannelReqParams
|
|||
/*!
|
||||
* A pointer to the new channels.
|
||||
*/
|
||||
ChannelParams_t* NewChannel;
|
||||
channel_params_t* NewChannel;
|
||||
/*!
|
||||
* The channel ID.
|
||||
*/
|
||||
|
@ -1031,11 +1031,11 @@ typedef struct sCalcBackOffParams
|
|||
/*!
|
||||
* Elapsed time since the start of the node.
|
||||
*/
|
||||
TimerTime_t ElapsedTime;
|
||||
lorawan_time_t ElapsedTime;
|
||||
/*!
|
||||
* Time-on-air of the last transmission.
|
||||
*/
|
||||
TimerTime_t TxTimeOnAir;
|
||||
lorawan_time_t TxTimeOnAir;
|
||||
}CalcBackOffParams_t;
|
||||
|
||||
/*!
|
||||
|
@ -1046,11 +1046,11 @@ typedef struct sNextChanParams
|
|||
/*!
|
||||
* The aggregated time-off time.
|
||||
*/
|
||||
TimerTime_t AggrTimeOff;
|
||||
lorawan_time_t AggrTimeOff;
|
||||
/*!
|
||||
* The time of the last aggregated TX.
|
||||
*/
|
||||
TimerTime_t LastAggrTx;
|
||||
lorawan_time_t LastAggrTx;
|
||||
/*!
|
||||
* The current datarate.
|
||||
*/
|
||||
|
@ -1073,7 +1073,7 @@ typedef struct sChannelAddParams
|
|||
/*!
|
||||
* A pointer to the new channel to add.
|
||||
*/
|
||||
ChannelParams_t* NewChannel;
|
||||
channel_params_t* NewChannel;
|
||||
/*!
|
||||
* The channel ID to add.
|
||||
*/
|
||||
|
|
|
@ -34,34 +34,34 @@ void LoRaWANTimeHandler::TimerTimeCounterInit(events::EventQueue *queue)
|
|||
_queue = queue;
|
||||
}
|
||||
|
||||
TimerTime_t LoRaWANTimeHandler::TimerGetCurrentTime( void )
|
||||
lorawan_time_t LoRaWANTimeHandler::TimerGetCurrentTime( void )
|
||||
{
|
||||
const uint32_t current_time = _queue->tick();
|
||||
return (TimerTime_t)current_time;
|
||||
return (lorawan_time_t)current_time;
|
||||
}
|
||||
|
||||
TimerTime_t LoRaWANTimeHandler::TimerGetElapsedTime( TimerTime_t savedTime )
|
||||
lorawan_time_t LoRaWANTimeHandler::TimerGetElapsedTime( lorawan_time_t savedTime )
|
||||
{
|
||||
return TimerGetCurrentTime() - savedTime;
|
||||
}
|
||||
|
||||
void LoRaWANTimeHandler::TimerInit( TimerEvent_t *obj, mbed::Callback<void()> callback)
|
||||
void LoRaWANTimeHandler::TimerInit( timer_event_t *obj, mbed::Callback<void()> callback)
|
||||
{
|
||||
obj->value = 0;
|
||||
obj->Callback = callback;
|
||||
obj->callback = callback;
|
||||
}
|
||||
|
||||
void LoRaWANTimeHandler::TimerStart( TimerEvent_t *obj )
|
||||
void LoRaWANTimeHandler::TimerStart( timer_event_t *obj )
|
||||
{
|
||||
obj->Timer.get()->attach_us( mbed::callback( obj->Callback ), obj->value * 1000 );
|
||||
obj->timer.get()->attach_us(obj->callback, obj->value * 1000 );
|
||||
}
|
||||
|
||||
void LoRaWANTimeHandler::TimerStop( TimerEvent_t *obj )
|
||||
void LoRaWANTimeHandler::TimerStop( timer_event_t *obj )
|
||||
{
|
||||
obj->Timer.get()->detach( );
|
||||
obj->timer.get()->detach( );
|
||||
}
|
||||
|
||||
void LoRaWANTimeHandler::TimerSetValue( TimerEvent_t *obj, uint32_t value )
|
||||
void LoRaWANTimeHandler::TimerSetValue( timer_event_t *obj, uint32_t value )
|
||||
{
|
||||
obj->value = value;
|
||||
}
|
||||
|
|
|
@ -49,14 +49,14 @@ public:
|
|||
* \param [in] obj The structure containing the timer object parameters.
|
||||
* \param [in] callback The function callback called at the end of the timeout.
|
||||
*/
|
||||
void TimerInit( TimerEvent_t *obj, mbed::Callback<void()> callback);
|
||||
void TimerInit( timer_event_t *obj, mbed::Callback<void()> callback);
|
||||
|
||||
/*!
|
||||
* \brief Read the current time.
|
||||
*
|
||||
* \retval time The current time.
|
||||
*/
|
||||
TimerTime_t TimerGetCurrentTime( void );
|
||||
lorawan_time_t TimerGetCurrentTime( void );
|
||||
|
||||
/*!
|
||||
* \brief Return the time elapsed since a fixed moment in time.
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
* \param [in] savedTime The fixed moment in time.
|
||||
* \retval time The elapsed time.
|
||||
*/
|
||||
TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime );
|
||||
lorawan_time_t TimerGetElapsedTime( lorawan_time_t savedTime );
|
||||
|
||||
|
||||
|
||||
|
@ -73,14 +73,14 @@ public:
|
|||
*
|
||||
* \param [in] obj The structure containing the timer object parameters.
|
||||
*/
|
||||
void TimerStart( TimerEvent_t *obj );
|
||||
void TimerStart( timer_event_t *obj );
|
||||
|
||||
/*!
|
||||
* \brief Stops and removes the timer object from the list of timer events.
|
||||
*
|
||||
* \param [in] obj The structure containing the timer object parameters.
|
||||
*/
|
||||
void TimerStop( TimerEvent_t *obj );
|
||||
void TimerStop( timer_event_t *obj );
|
||||
|
||||
/*!
|
||||
* \brief Set a new timeout value.
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
* \param [in] obj The structure containing the timer object parameters.
|
||||
* \param [in] value The new timeout value.
|
||||
*/
|
||||
void TimerSetValue( TimerEvent_t *obj, uint32_t value );
|
||||
void TimerSetValue( timer_event_t *obj, uint32_t value );
|
||||
|
||||
private:
|
||||
events::EventQueue *_queue;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,20 +31,20 @@ public:
|
|||
*
|
||||
* @param queue A pointer to EventQueue provided by the application.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error code on
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error code on
|
||||
* failure.
|
||||
*/
|
||||
virtual lora_mac_status_t initialize(events::EventQueue *queue) = 0;
|
||||
virtual lorawan_status_t initialize(events::EventQueue *queue) = 0;
|
||||
|
||||
/** Connect OTAA or ABP by setup.
|
||||
*
|
||||
* Connect by Over The Air Activation or Activation By Personalization.
|
||||
* The connection type is selected at the setup.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error code on
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error code on
|
||||
* failure.
|
||||
*/
|
||||
virtual lora_mac_status_t connect() = 0;
|
||||
virtual lorawan_status_t connect() = 0;
|
||||
|
||||
/** Connect OTAA or ABP by parameters
|
||||
*
|
||||
|
@ -53,16 +53,16 @@ public:
|
|||
* You need to define the parameters in the main application.
|
||||
*
|
||||
* @param connect Options how end-device will connect to gateway
|
||||
* @return LORA_MAC_STATUS_OK on success, negative error code
|
||||
* @return LORAWAN_STATUS_OK on success, negative error code
|
||||
* on failure
|
||||
*/
|
||||
virtual lora_mac_status_t connect(const lorawan_connect_t &connect) = 0;
|
||||
virtual lorawan_status_t connect(const lorawan_connect_t &connect) = 0;
|
||||
|
||||
/** Disconnects the current session.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error code on failure.
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t disconnect() = 0;
|
||||
virtual lorawan_status_t disconnect() = 0;
|
||||
|
||||
/** Validate the connectivity with the network.
|
||||
*
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
*
|
||||
* This API is usable only when the link check response is callback set by
|
||||
* the application. See add_lora_app_callbacks API. If the above mentioned
|
||||
* callback is not set, a LORA_MAC_STATUS_PARAMETER_INVALID error is thrown.
|
||||
* callback is not set, a LORAWAN_STATUS_PARAMETER_INVALID error is thrown.
|
||||
*
|
||||
* First parameter to callback function is the demodulation margin and
|
||||
* the second parameter is the number of gateways that successfully received
|
||||
|
@ -85,11 +85,11 @@ public:
|
|||
* remove_link_check_request() API.
|
||||
*
|
||||
* @param cb A callback function to receive link check response
|
||||
* @return LORA_MAC_STATUS_OK on successfully queuing a request, or
|
||||
* @return LORAWAN_STATUS_OK on successfully queuing a request, or
|
||||
* a negative error code on failure.
|
||||
*
|
||||
*/
|
||||
virtual lora_mac_status_t add_link_check_request() = 0;
|
||||
virtual lorawan_status_t add_link_check_request() = 0;
|
||||
|
||||
/** Detaches Link Request MAC command.
|
||||
*
|
||||
|
@ -102,30 +102,30 @@ public:
|
|||
* @param data_rate Intended data rate e.g., DR_0, DR_1 etc.
|
||||
* Caution is advised as the macro DR_* can mean different
|
||||
* things while being in a different region.
|
||||
* @return LORA_MAC_STATUS_OK if everything goes well, otherwise
|
||||
* @return LORAWAN_STATUS_OK if everything goes well, otherwise
|
||||
* a negative error code.
|
||||
*/
|
||||
virtual lora_mac_status_t set_datarate(uint8_t data_rate) = 0;
|
||||
virtual lorawan_status_t set_datarate(uint8_t data_rate) = 0;
|
||||
|
||||
/** Enables adaptive data rate (ADR)
|
||||
*
|
||||
* Underlying LoRaPHY and LoRaMac layers handle the data rate automatically
|
||||
* for the user based upon radio conditions (network congestion).
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, negative error code
|
||||
* @return LORAWAN_STATUS_OK on success, negative error code
|
||||
* on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t enable_adaptive_datarate() = 0;
|
||||
virtual lorawan_status_t enable_adaptive_datarate() = 0;
|
||||
|
||||
/** Disables adaptive data rate
|
||||
*
|
||||
* When adaptive data rate (ADR) is disabled, user can either set a certain
|
||||
* data rate or the Mac layer will choose a default value.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, negative error code
|
||||
* @return LORAWAN_STATUS_OK on success, negative error code
|
||||
* on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t disable_adaptive_datarate() = 0;
|
||||
virtual lorawan_status_t disable_adaptive_datarate() = 0;
|
||||
|
||||
/** Sets up retry counter for confirmed messages
|
||||
*
|
||||
|
@ -141,25 +141,25 @@ public:
|
|||
*
|
||||
* @param count number of retries for confirmed messages
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or a negative error code
|
||||
* @return LORAWAN_STATUS_OK or a negative error code
|
||||
*/
|
||||
virtual lora_mac_status_t set_confirmed_msg_retries(uint8_t count) = 0;
|
||||
virtual lorawan_status_t set_confirmed_msg_retries(uint8_t count) = 0;
|
||||
|
||||
/** Sets channel plan
|
||||
*
|
||||
* @param channel_plan The defined channel plans to be set.
|
||||
* @return 0 on success, a negative error code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t set_channel_plan(const lora_channelplan_t &channel_plan) = 0;
|
||||
virtual lorawan_status_t set_channel_plan(const lorawan_channelplan_t &channel_plan) = 0;
|
||||
|
||||
/** Gets the current channel plan.
|
||||
*
|
||||
* @param channel_plan The current channel information.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* @return LORAWAN_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t get_channel_plan(lora_channelplan_t &channel_plan) = 0;
|
||||
virtual lorawan_status_t get_channel_plan(lorawan_channelplan_t &channel_plan) = 0;
|
||||
|
||||
/** Removes currently active channel plan
|
||||
*
|
||||
|
@ -167,10 +167,10 @@ public:
|
|||
* allowed to be removed. So when a plan is abolished, only non-default
|
||||
* channels are removed.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, negative error
|
||||
* @return LORAWAN_STATUS_OK on success, negative error
|
||||
* code on failure
|
||||
*/
|
||||
virtual lora_mac_status_t remove_channel_plan() = 0;
|
||||
virtual lorawan_status_t remove_channel_plan() = 0;
|
||||
|
||||
/** Removes a given single channel
|
||||
*
|
||||
|
@ -179,10 +179,10 @@ public:
|
|||
*
|
||||
* @param index The channel index
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, negative error
|
||||
* @return LORAWAN_STATUS_OK on success, negative error
|
||||
* code on failure
|
||||
*/
|
||||
virtual lora_mac_status_t remove_channel(uint8_t index) = 0;
|
||||
virtual lorawan_status_t remove_channel(uint8_t index) = 0;
|
||||
|
||||
/** Send message to gateway
|
||||
*
|
||||
|
@ -215,7 +215,7 @@ public:
|
|||
*
|
||||
*
|
||||
* @return The number of bytes sent, or
|
||||
* LORA_MAC_STATUS_WOULD_BLOCK if another TX is
|
||||
* LORAWAN_STATUS_WOULD_BLOCK if another TX is
|
||||
* ongoing, or a negative error code on failure.
|
||||
*/
|
||||
virtual int16_t send(uint8_t port, const uint8_t* data,
|
||||
|
@ -256,7 +256,7 @@ public:
|
|||
* @return It could be one of these:
|
||||
* i) 0 if there is nothing else to read.
|
||||
* ii) Number of bytes written to user buffer.
|
||||
* iii) LORA_MAC_STATUS_WOULD_BLOCK if there is
|
||||
* iii) LORAWAN_STATUS_WOULD_BLOCK if there is
|
||||
* nothing available to read at the moment.
|
||||
* iv) A negative error code on failure.
|
||||
*/
|
||||
|
@ -331,7 +331,7 @@ public:
|
|||
* @param callbacks A pointer to the structure containing application
|
||||
* callbacks.
|
||||
*/
|
||||
virtual lora_mac_status_t add_app_callbacks(lorawan_app_callbacks_t *callbacks) = 0;
|
||||
virtual lorawan_status_t add_app_callbacks(lorawan_app_callbacks_t *callbacks) = 0;
|
||||
};
|
||||
|
||||
#endif /* LORAWAN_BASE_H_ */
|
||||
|
|
Loading…
Reference in New Issue