mirror of https://github.com/ARMmbed/mbed-os.git
Adding LoRaWANInterface - implementing, LoRaWANBase
This class is the doorway for the user application into the Mbed-OS implementation of LoRaWAN protocol. It implements LoRaWANBase and hence would work with any stack implementation underneath, ensuring seemless portability for applications. It takes a pre-constructed object of LoRaRadio and delegates it in the downward direction. Before calling connect() user must call initialize() function in order to initialize stack and mac layers. connect() APIs can be used to either provide relevent keys and connection method at runtime or compile time (using Mbed config system). enable_adaptive_datarate() and disable_adaptive_datarate() are used to turn on/off automatic rate control. Otherwisem set_datarate() could be used to set a particular data rate on the current channel. set_confirmed_msg_retries() is valid only for CONFIRMED messages. It means that the stack will retry for a given number of times before timing out. set_channel_plan() and get_channel_plan() are used to set or get a particular channel plan. These APIs are particularly useful in case of ABP (activation by personalization). Because in case of OTAA(over the air activation), by default the stack takes in a CF List (carrier frequency list) sent by the base station in conjunction with Network server. This list overwrites all user configured channels or channel plan. set_channel_plan() can be used to set a single channel as well by setting the parameter for number of channels to 1. remove_channel_plan() or remove_channel() are used to remove a currently active channel plan or a specific channel. send() and receive() APIs follow posix design except the socket descriptor is replaced with port number here. lora_event_callback() API is used to set a callback function from the application side which is used by the stack to inform user of particular events like CONNECTED, DISCONNECTED, CRYPTO_FAILURE, TX_TIMEOUT etc.pull/6087/head
parent
2f860d2be5
commit
f33ef6528b
|
@ -0,0 +1,177 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Implementation of LoRaWANBase
|
||||
*
|
||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "lorawan/LoRaWANInterface.h"
|
||||
|
||||
inline LoRaWANStack& stk_obj()
|
||||
{
|
||||
return LoRaWANStack::get_lorawan_stack();
|
||||
}
|
||||
|
||||
LoRaWANInterface::LoRaWANInterface(LoRaRadio& radio)
|
||||
{
|
||||
// Pass mac_handlers to radio to the radio driver after
|
||||
// binding radio driver to PHY layer
|
||||
radio_events_t *events = stk_obj().bind_radio_driver(radio);
|
||||
radio.lock();
|
||||
radio.init_radio(events);
|
||||
radio.unlock();
|
||||
}
|
||||
|
||||
LoRaWANInterface::~LoRaWANInterface()
|
||||
{
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::initialize()
|
||||
{
|
||||
return stk_obj().initialize_mac_layer();
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::connect()
|
||||
{
|
||||
// connection attempt without parameters.
|
||||
// System tries to look for configuration in mbed_lib.json that can be
|
||||
// overridden by mbed_app.json. However, if none of the json files are
|
||||
// available (highly unlikely), we still fallback to some default parameters.
|
||||
// Check lorawan_data_structure for fallback defaults.
|
||||
|
||||
lorawan_connect_t connection_params;
|
||||
|
||||
if (OVER_THE_AIR_ACTIVATION != 0) {
|
||||
static uint8_t dev_eui[] = LORAWAN_DEVICE_EUI;
|
||||
static uint8_t app_eui[] = LORAWAN_APPLICATION_EUI;
|
||||
static uint8_t app_key[] = LORAWAN_APPLICATION_KEY;
|
||||
/**
|
||||
*
|
||||
* OTAA join
|
||||
*/
|
||||
connection_params.connect_type = LORAWAN_CONNECTION_OTAA;
|
||||
connection_params.connection_u.otaa.app_eui = app_eui;
|
||||
connection_params.connection_u.otaa.dev_eui = dev_eui;
|
||||
connection_params.connection_u.otaa.app_key = app_key;
|
||||
connection_params.connection_u.otaa.nb_trials = LORAWAN_NB_TRIALS;
|
||||
|
||||
return connect(connection_params);
|
||||
} else {
|
||||
static uint8_t nwk_skey[] = LORAWAN_NWKSKEY;
|
||||
static uint8_t app_skey[] = LORAWAN_APPSKEY;
|
||||
static uint32_t dev_addr = LORAWAN_DEVICE_ADDRESS;
|
||||
static uint32_t nwk_id = (LORAWAN_DEVICE_ADDRESS & LORAWAN_NETWORK_ID_MASK);
|
||||
|
||||
/**
|
||||
*
|
||||
* ABP connection
|
||||
*/
|
||||
connection_params.connect_type = LORAWAN_CONNECTION_ABP;
|
||||
connection_params.connection_u.abp.nwk_id = nwk_id;
|
||||
connection_params.connection_u.abp.dev_addr = dev_addr;
|
||||
connection_params.connection_u.abp.nwk_skey = nwk_skey;
|
||||
connection_params.connection_u.abp.app_skey = app_skey;
|
||||
|
||||
return connect(connection_params);
|
||||
}
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::connect(const lorawan_connect_t &connect)
|
||||
{
|
||||
lora_mac_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 mac_status;
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::disconnect()
|
||||
{
|
||||
stk_obj().shutdown();
|
||||
return LORA_MAC_STATUS_OK;
|
||||
}
|
||||
|
||||
lora_mac_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)
|
||||
{
|
||||
return stk_obj().set_confirmed_msg_retry(count);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::enable_adaptive_datarate()
|
||||
{
|
||||
return stk_obj().enable_adaptive_datarate(true);
|
||||
}
|
||||
|
||||
lora_mac_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)
|
||||
{
|
||||
return stk_obj().add_channels(channel_plan);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::get_channel_plan(lora_channelplan_t &channel_plan)
|
||||
{
|
||||
return stk_obj().get_enabled_channels(channel_plan);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::remove_channel(uint8_t id)
|
||||
{
|
||||
return stk_obj().remove_a_channel(id);
|
||||
}
|
||||
|
||||
lora_mac_status_t LoRaWANInterface::remove_channel_plan()
|
||||
{
|
||||
return stk_obj().drop_channel_list();
|
||||
}
|
||||
|
||||
int16_t LoRaWANInterface::send(uint8_t port, const uint8_t* data,
|
||||
uint16_t length, int flags)
|
||||
{
|
||||
if (data) {
|
||||
return stk_obj().handle_tx(port, data, length, flags);
|
||||
} else {
|
||||
return LORA_MAC_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
int16_t LoRaWANInterface::receive(uint8_t port, uint8_t* data, uint16_t length,
|
||||
int flags)
|
||||
{
|
||||
if (data && length > 0) {
|
||||
return stk_obj().handle_rx(port, data, length, flags);
|
||||
} else {
|
||||
return LORA_MAC_STATUS_PARAMETER_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
void LoRaWANInterface::lora_event_callback(mbed::Callback<void(lora_events_t)> event_cb)
|
||||
{
|
||||
stk_obj().set_lora_event_cb(event_cb);
|
||||
}
|
|
@ -0,0 +1,339 @@
|
|||
/**
|
||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef LORAWANINTERFACE_H_
|
||||
#define LORAWANINTERFACE_H_
|
||||
|
||||
#include "platform/Callback.h"
|
||||
#include "netsocket/LoRaWANBase.h"
|
||||
#include "lorawan/LoRaWANStack.h"
|
||||
#include "netsocket/LoRaRadio.h"
|
||||
|
||||
class LoRaWANInterface: public LoRaWANBase {
|
||||
|
||||
public:
|
||||
|
||||
/** Constructs a LoRaWANInterface using the LoRaWANStack instance underneath.
|
||||
*
|
||||
* Currently, LoRaWANStack is a singleton and you should only
|
||||
* construct a single instance of LoRaWANInterface.
|
||||
*
|
||||
*/
|
||||
LoRaWANInterface(LoRaRadio& radio);
|
||||
virtual ~LoRaWANInterface();
|
||||
|
||||
/** Initialize the LoRa stack.
|
||||
*
|
||||
* You must call this first to be able to use the LoRa stack.
|
||||
*
|
||||
* \return 0 on success, a negative error code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t initialize();
|
||||
|
||||
/** Connect OTAA or ABP using Mbed-OS config system
|
||||
*
|
||||
* Connect by Over The Air Activation or Activation By Personalization.
|
||||
* 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.
|
||||
* 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
|
||||
* all user-configured channels except the Join/Default channels. A CF-List can
|
||||
* configure a maximum of five channels other than the default channels.
|
||||
*
|
||||
* In case of ABP, the CONNECTED event is posted before the call to `connect()` returns.
|
||||
* To configure more channels, we recommend that you use the `set_channel_plan()` API after the connection.
|
||||
* By default, the PHY layers configure only the mandatory Join channels. The retransmission back-off restrictions
|
||||
* on these channels are severe and you may experience long delays or even failures in the confirmed traffic.
|
||||
* If you add more channels, the aggregated duty cycle becomes much more relaxed as compared to the Join (default) channels only.
|
||||
*
|
||||
* **NOTES ON RECONNECTION:**
|
||||
* Currently, the Mbed OS LoRaWAN implementation does not support non-volatile
|
||||
* memory storage. Therefore, the state and frame counters cannot be restored after
|
||||
* a power cycle. However, if you use the `disconnect()` API to shut down the LoRaWAN
|
||||
* protocol, the state and frame counters are saved. Connecting again would try to
|
||||
* restore the previous session. According to the LoRaWAN 1.0.2 specification, the frame counters are always reset
|
||||
* to zero for OTAA and a new Join request lets the network server know
|
||||
* that the counters need a reset. The same is said about the ABP but there
|
||||
* is no way to convey this information to the network server. For a network
|
||||
* server, an ABP device is always connected. That's why storing the frame counters
|
||||
* 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
|
||||
* on success, or a negative error code on failure.
|
||||
*/
|
||||
virtual lora_mac_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.
|
||||
* 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
|
||||
* all user-configured channels except the Join/Default channels. A CF-List can
|
||||
* configure a maximum of five channels other than the default channels.
|
||||
*
|
||||
* In case of ABP, the CONNECTED event is posted before the call to `connect()` returns.
|
||||
* To configure more channels, we recommend that you use the `set_channel_plan()` API after the connection.
|
||||
* By default, the PHY layers configure only the mandatory Join
|
||||
* channels. The retransmission back-off restrictions on these channels
|
||||
* are severe and you may experience long delays or even
|
||||
* failures in the confirmed traffic. If you add more channels, the aggregated duty
|
||||
* cycle becomes much more relaxed as compared to the Join (default) channels only.
|
||||
*
|
||||
* **NOTES ON RECONNECTION:**
|
||||
* Currently, the Mbed OS LoRaWAN implementation does not support non-volatile
|
||||
* memory storage. Therefore, the state and frame counters cannot be restored after
|
||||
* a power cycle. However, if you use the `disconnect()` API to shut down the LoRaWAN
|
||||
* protocol, the state and frame counters are saved. Connecting again would try to
|
||||
* restore the previous session. According to the LoRaWAN 1.0.2 specification, the frame counters are always reset
|
||||
* to zero for OTAA and a new Join request lets the network server know
|
||||
* that the counters need a reset. The same is said about the ABP but there
|
||||
* is no way to convey this information to the network server. For a network
|
||||
* server, an ABP device is always connected. That's why storing the frame counters
|
||||
* is important, at least for ABP. That's why we try to restore frame counters from
|
||||
* session information after a disconnection.
|
||||
*
|
||||
* @param connect Options for an end device connection to the gateway.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or LORA_MAC_STATUS_CONNECT_IN_PROGRESS,
|
||||
* a negative error code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t connect(const lorawan_connect_t &connect);
|
||||
|
||||
/** Disconnect the current session.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error code on
|
||||
* failure.
|
||||
*/
|
||||
virtual lora_mac_status_t disconnect();
|
||||
|
||||
/** Sets up a particular data rate
|
||||
*
|
||||
* `set_datarate()` first verifies whether the data rate given is valid or not.
|
||||
* If it is valid, the system sets the given data rate to the channel.
|
||||
*
|
||||
* @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
|
||||
* a negative error code.
|
||||
*/
|
||||
virtual lora_mac_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.
|
||||
*/
|
||||
virtual lora_mac_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.
|
||||
*/
|
||||
virtual lora_mac_status_t disable_adaptive_datarate();
|
||||
|
||||
/** Sets up the retry counter for confirmed messages.
|
||||
*
|
||||
* Valid for confirmed messages only.
|
||||
*
|
||||
* The number of trials to transmit the frame, if the LoRaMAC layer did not
|
||||
* receive an acknowledgment. The MAC performs a data rate adaptation as in
|
||||
* the LoRaWAN Specification V1.0.2, chapter 18.4, table on page 64.
|
||||
*
|
||||
* Note, that if number of retries is set to 1 or 2, MAC will not decrease
|
||||
* the datarate, if the LoRaMAC layer did not receive an acknowledgment.
|
||||
*
|
||||
* @param count The number of retries for confirmed messages.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK or a negative error code.
|
||||
*/
|
||||
virtual lora_mac_status_t set_confirmed_msg_retries(uint8_t count);
|
||||
|
||||
/** Sets the channel plan.
|
||||
*
|
||||
* You can provide a list of channels with appropriate parameters filled
|
||||
* in. However, this list is not absolute. The stack applies a CF-List whenever
|
||||
* available, which means that the network can overwrite your channel
|
||||
* frequency settings right after Join Accept is received. You may try
|
||||
* to set up any channel or channels after that, and if the channel requested
|
||||
* is already active, the request is silently ignored. A negative error
|
||||
* code is returned if there is any problem with parameters.
|
||||
*
|
||||
* There is no reverse mechanism in the 1.0.2 specification for a node to request
|
||||
* a particular channel. Only the network server can initiate such a request.
|
||||
* You need to ensure that the corresponding base station supports the channel or channels being added.
|
||||
*
|
||||
* If your list includes a default channel (a channel where Join Requests
|
||||
* are received) you cannot fully configure the channel parameters.
|
||||
* Either leave the channel settings to default or check your
|
||||
* corresponding PHY layer implementation. For example, LoRaPHYE868.
|
||||
*
|
||||
* @param channel_plan The channel plan to set.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t set_channel_plan(const lora_channelplan_t &channel_plan);
|
||||
|
||||
/** Gets the channel plans from the LoRa stack.
|
||||
*
|
||||
* Once you have selected a particular PHY layer, a set of channels
|
||||
* is automatically activated. Right after connecting, you can use this API
|
||||
* to see the current plan. Otherwise, this API returns the channel
|
||||
* plan that you have set using `set_channel_plan()`.
|
||||
*
|
||||
* @param channel_plan The current channel plan information.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t get_channel_plan(lora_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
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t remove_channel_plan();
|
||||
|
||||
/** Removes a single channel.
|
||||
*
|
||||
* You cannot remove default channels (the channels the base stations are listening to).
|
||||
*
|
||||
* @param index The channel index.
|
||||
*
|
||||
* @return LORA_MAC_STATUS_OK on success, a negative error
|
||||
* code on failure.
|
||||
*/
|
||||
virtual lora_mac_status_t remove_channel(uint8_t index);
|
||||
|
||||
/** Send message to gateway
|
||||
*
|
||||
* @param port The application port number. Port numbers 0 and 224
|
||||
* are reserved, whereas port numbers from 1 to 223
|
||||
* (0x01 to 0xDF) are valid port numbers.
|
||||
* Anything out of this range is illegal.
|
||||
*
|
||||
* @param data A pointer to the data being sent. The ownership of the
|
||||
* buffer is not transferred. The data is copied to the
|
||||
* internal buffers.
|
||||
*
|
||||
* @param length The size of data in bytes.
|
||||
*
|
||||
* @param flags A flag used to determine what type of
|
||||
* message is being sent, for example:
|
||||
*
|
||||
* MSG_UNCONFIRMED_FLAG = 0x01
|
||||
* MSG_CONFIRMED_FLAG = 0x02
|
||||
* MSG_MULTICAST_FLAG = 0x04
|
||||
* MSG_PROPRIETARY_FLAG = 0x08
|
||||
* MSG_MULTICAST_FLAG and MSG_PROPRIETARY_FLAG can be
|
||||
* used in conjunction with MSG_UNCONFIRMED_FLAG and
|
||||
* MSG_CONFIRMED_FLAG depending on the intended use.
|
||||
*
|
||||
* MSG_PROPRIETARY_FLAG|MSG_CONFIRMED_FLAG mask will set
|
||||
* a confirmed message flag for a proprietary message.
|
||||
* MSG_CONFIRMED_FLAG and MSG_UNCONFIRMED_FLAG are
|
||||
* mutually exclusive.
|
||||
*
|
||||
*
|
||||
* @return The number of bytes sent, or
|
||||
* LORA_MAC_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,
|
||||
int flags);
|
||||
|
||||
/** Receives a message from the Network Server.
|
||||
*
|
||||
* @param port The application port number. Port numbers 0 and 224
|
||||
* are reserved, whereas port numbers from 1 to 223
|
||||
* (0x01 to 0xDF) are valid port numbers.
|
||||
* Anything out of this range is illegal.
|
||||
*
|
||||
* @param data A pointer to buffer where the received data will be
|
||||
* stored.
|
||||
*
|
||||
* @param length The size of data in bytes
|
||||
*
|
||||
* @param flags A flag is used to determine what type of
|
||||
* message is being sent, for example:
|
||||
*
|
||||
* MSG_UNCONFIRMED_FLAG = 0x01,
|
||||
* MSG_CONFIRMED_FLAG = 0x02
|
||||
* MSG_MULTICAST_FLAG = 0x04,
|
||||
* MSG_PROPRIETARY_FLAG = 0x08
|
||||
*
|
||||
* MSG_MULTICAST_FLAG and MSG_PROPRIETARY_FLAG can be
|
||||
* used in conjunction with MSG_UNCONFIRMED_FLAG and
|
||||
* MSG_CONFIRMED_FLAG depending on the intended use.
|
||||
*
|
||||
* MSG_PROPRIETARY_FLAG|MSG_CONFIRMED_FLAG mask will set
|
||||
* a confirmed message flag for a proprietary message.
|
||||
*
|
||||
* MSG_CONFIRMED_FLAG and MSG_UNCONFIRMED_FLAG are
|
||||
* not mutually exclusive, i.e., the user can subscribe to
|
||||
* receive both CONFIRMED AND UNCONFIRMED messages at
|
||||
* the same time.
|
||||
*
|
||||
* @return It could be one of these:
|
||||
* i) 0 if there is nothing else to read.
|
||||
* ii) Number of bytes still pending to read.
|
||||
* iii) LORA_MAC_STATUS_WOULD_BLOCK if there is
|
||||
* nothing available to read at the moment.
|
||||
* iv) A negative error code on failure.
|
||||
*/
|
||||
virtual int16_t receive(uint8_t port, uint8_t* data, uint16_t length,
|
||||
int flags);
|
||||
|
||||
/** Callback handler.
|
||||
*
|
||||
* Events that can be posted to user:
|
||||
*
|
||||
* CONNECTED - When the connection is complete
|
||||
* DISCONNECTED - When the protocol is shut down in response to disconnect()
|
||||
* TX_DONE - When a packet is sent
|
||||
* TX_TIMEOUT, - When stack was unable to send packet in TX window
|
||||
* TX_ERROR, - A general TX error
|
||||
* TX_CRYPTO_ERROR, - If MIC fails, or any other crypto relted error
|
||||
* TX_SCHEDULING_ERROR, - When stack is unable to schedule packet
|
||||
* RX_DONE, - When there is something to receive
|
||||
* RX_TIMEOUT, - Not yet mapped
|
||||
* RX_ERROR - A general RX error
|
||||
*
|
||||
* @param event_cb A callback function for catching events from the stack.
|
||||
*/
|
||||
virtual void lora_event_callback(mbed::Callback<void(lora_events_t)> event_cb);
|
||||
};
|
||||
|
||||
#endif /* LORAWANINTERFACE_H_ */
|
Loading…
Reference in New Issue