Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRaMac.h Source File

LoRaMac.h

Go to the documentation of this file.
00001 /**
00002  * \file      LoRaMac.h
00003  *
00004  * \brief     LoRa MAC layer implementation
00005  *
00006  * \copyright Revised BSD License, see LICENSE.TXT file include in the project
00007  *
00008  * \code
00009  *                ______                              _
00010  *               / _____)             _              | |
00011  *              ( (____  _____ ____ _| |_ _____  ____| |__
00012  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00013  *               _____) ) ____| | | || |_| ____( (___| | | |
00014  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
00015  *              (C)2013 Semtech
00016  *
00017  *               ___ _____ _   ___ _  _____ ___  ___  ___ ___
00018  *              / __|_   _/_\ / __| |/ / __/ _ \| _ \/ __| __|
00019  *              \__ \ | |/ _ \ (__| ' <| _| (_) |   / (__| _|
00020  *              |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
00021  *              embedded.connectivity.solutions===============
00022  *
00023  * \endcode
00024  *
00025  * \author    Miguel Luis ( Semtech )
00026  *
00027  * \author    Gregory Cristian ( Semtech )
00028  *
00029  * \author    Daniel Jaeckle ( STACKFORCE )
00030  *
00031  * \defgroup  LORAMAC LoRa MAC layer implementation
00032  *            This module specifies the API implementation of the LoRaMAC layer.
00033  *            This is a placeholder for a detailed description of the LoRaMac
00034  *            layer and the supported features.
00035  *
00036  * Copyright (c) 2017, Arm Limited and affiliates.
00037  * SPDX-License-Identifier: BSD-3-Clause
00038  *
00039  */
00040 #ifndef MBED_LORAWAN_MAC_H__
00041 #define MBED_LORAWAN_MAC_H__
00042 
00043 #include "lorawan/system/LoRaWANTimer.h"
00044 #include "lorastack/phy/LoRaPHY.h"
00045 #include "lorawan/system/lorawan_data_structures.h"
00046 #include "lorastack/mac/LoRaMacCommand.h"
00047 #include "events/EventQueue.h"
00048 #include "lorastack/mac/LoRaMacMlme.h"
00049 #include "lorastack/mac/LoRaMacMcps.h"
00050 #include "lorastack/mac/LoRaMacMib.h"
00051 #include "lorastack/mac/LoRaMacChannelPlan.h"
00052 
00053 class LoRaMac {
00054 
00055 public:
00056 
00057     /**
00058      * Constructor
00059      */
00060     LoRaMac(LoRaWANTimeHandler &lora_time);
00061 
00062     /**
00063      * Destructor
00064      */
00065     ~LoRaMac();
00066 
00067     /**
00068      * @brief   LoRaMAC layer initialization
00069      *
00070      * @details In addition to the initialization of the LoRaMAC layer, this
00071      *          function initializes the callback primitives of the MCPS and
00072      *          MLME services. Every data field of \ref loramac_primitives_t must be
00073      *          set to a valid callback function.
00074      *
00075      * @param   primitives [in]   A pointer to the structure defining the LoRaMAC
00076      *                            event functions. Refer to \ref loramac_primitives_t.
00077      *
00078      * @param   phy [in]          A pointer to the selected PHY layer.
00079      *
00080      * @param   queue [in]        A pointer to the application provided EventQueue.
00081      *
00082      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00083      *          \ref LORAWAN_STATUS_OK
00084      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00085      */
00086     lorawan_status_t initialize(loramac_primitives_t  *primitives, LoRaPHY *phy,
00087                                 events::EventQueue *queue);
00088 
00089     /**
00090      * @brief   Disconnect LoRaMac layer
00091      *
00092      * @details Cancels all outstanding requests and sets LoRaMac's
00093      *          internal state to idle.
00094      */
00095     void disconnect(void);
00096 
00097     /**
00098      * @brief   Queries the LoRaMAC whether it is possible to send the next frame with
00099      *          a given payload size. The LoRaMAC takes the scheduled MAC commands into
00100      *          account and reports when the frame can be sent.
00101      *
00102      * @param   size     [in]    The size of the applicable payload to be sent next.
00103      * @param   tx_info  [out]   The structure \ref loramac_tx_info_t contains
00104      *                           information on the actual maximum payload possible
00105      *                           (according to the configured datarate or the next
00106      *                           datarate according to ADR), and the maximum frame
00107      *                           size, taking the scheduled MAC commands into account.
00108      *
00109      * @return  `lorawan_status_t` The status of the operation. When the parameters are
00110      *          not valid, the function returns \ref LORAWAN_STATUS_PARAMETER_INVALID.
00111      *          In case of a length error caused by the applicable payload in combination
00112      *          with the MAC commands, the function returns \ref LORAWAN_STATUS_LENGTH_ERROR.
00113      *          Please note that if the size of the MAC commands in the queue do
00114      *          not fit into the payload size on the related datarate, the LoRaMAC will
00115      *          omit the MAC commands.
00116      *          If the query is valid, and the LoRaMAC is able to send the frame,
00117      *          the function returns \ref LORAWAN_STATUS_OK.
00118      */
00119     lorawan_status_t query_tx_possible(uint8_t size, loramac_tx_info_t * tx_info);
00120 
00121     /**
00122      * @brief   Adds a channel plan to the system.
00123      *
00124      * @details Adds a whole channel plan or a single new channel if the plan
00125      *          contains only one channel and 'plan.nb_channels' is set to 1.
00126      *          Please note that this functionality is not available in all regions.
00127      *          Information on the allowed ranges is available at the
00128      *          LoRaWAN Regional Parameters V1.0.2rB.
00129      *
00130      * @param   plan [in]    A reference to application provided channel plan.
00131      *
00132      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00133      *          \ref LORAWAN_STATUS_OK
00134      *          \ref LORAWAN_STATUS_BUSY
00135      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00136      */
00137     lorawan_status_t add_channel_plan(const lorawan_channelplan_t& plan);
00138 
00139     /**
00140      * @brief   Removes a channel plan from the system.
00141      *
00142      * @details Removes the whole active channel plan except the 'Default Channels'.
00143      *          Please note that this functionality is not available in all regions.
00144      *          Information on the allowed ranges is available at the
00145      *          LoRaWAN Regional Parameters V1.0.2rB.
00146      *
00147      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00148      *          \ref LORAWAN_STATUS_OK
00149      *          \ref LORAWAN_STATUS_BUSY
00150      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00151      */
00152     lorawan_status_t remove_channel_plan();
00153 
00154     /**
00155      * @brief   Access active channel plan.
00156      *
00157      * @details Provides access to the current active channel plan.
00158      *
00159      * @param   plan [out]    A reference to application provided channel plan data
00160      *                        structure which will be filled in with active channel
00161      *                        plan.
00162      *
00163      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00164      *          \ref LORAWAN_STATUS_OK
00165      *          \ref LORAWAN_STATUS_BUSY
00166      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00167      */
00168     lorawan_status_t get_channel_plan(lorawan_channelplan_t& plan);
00169 
00170     /**
00171      * @brief   Remove a given channel from the active plan.
00172      *
00173      * @details Deactivates the given channel.
00174      *
00175      * @param id    Id of the channel.
00176      *
00177      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00178      *          \ref LORAWAN_STATUS_OK
00179      *          \ref LORAWAN_STATUS_BUSY
00180      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00181      */
00182     lorawan_status_t remove_single_channel(uint8_t id);
00183 
00184     /**
00185      * @brief   LoRaMAC multicast channel link service.
00186      *
00187      * @details Links a multicast channel into the linked list.
00188      *
00189      * @param [in] channel_param    The multicast channel parameters to link.
00190      *
00191      * @return  `lorawan_status_t` The  status of the operation. The possible values are:
00192      *          \ref LORAWAN_STATUS_OK
00193      *          \ref LORAWAN_STATUS_BUSY
00194      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00195      */
00196     lorawan_status_t multicast_channel_link(multicast_params_t  *channel_param);
00197 
00198     /**
00199      * @brief   LoRaMAC multicast channel unlink service.
00200      *
00201      * @details Unlinks a multicast channel from the linked list.
00202      *
00203      * @param [in] channel_param    The multicast channel parameters to unlink.
00204      *
00205      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00206      *          \ref LORAWAN_STATUS_OK
00207      *          \ref LORAWAN_STATUS_BUSY
00208      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00209      */
00210     lorawan_status_t multicast_channel_unlink(multicast_params_t  *channel_param);
00211 
00212     /**
00213      * @brief   Get parameter values from MIB service.
00214      *
00215      * @details The MAC information base service to get the attributes of the LoRaMac layer.
00216      *
00217      *          The following code-snippet shows how to use the API to get the
00218      *          parameter `AdrEnable`, defined by the enumeration type
00219      *          \ref MIB_ADR.
00220      *
00221      * @code
00222      *
00223      * loramac_mib_req_confirm_t mib_get;
00224      * mib_get.type = MIB_ADR;
00225      *
00226      * if (mib_get_request_confirm(&mib_get) == LORAWAN_STATUS_OK) {
00227      *   // LoRaMAC updated the parameter mibParam.AdrEnable
00228      * }
00229      *
00230      * @endcode
00231      *
00232      * @param [in] mib_get    The MIB-GET request to perform. Refer to
00233      *                        \ref loramac_mib_req_confirm_t.
00234      *
00235      * @return  `lorawan_status_t` The status of the operation.
00236      *          The possible values are:
00237      *          \ref LORAWAN_STATUS_OK
00238      *          \ref LORAWAN_STATUS_SERVICE_UNKNOWN
00239      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00240      */
00241     lorawan_status_t mib_get_request_confirm(loramac_mib_req_confirm_t  *mib_get);
00242 
00243     /**
00244      * @brief   Set attributes for MAC layer using MIB service.
00245      *
00246      * @details The MAC information base service to set the attributes of the LoRaMac layer.
00247      *
00248      *          The following code-snippet shows how to use the API to set the
00249      *          parameter `adr_enable`, defined by the enumeration type
00250      *          \ref MIB_ADR.
00251      *
00252      * @code
00253      *
00254      * loramac_mib_req_confirm_t mib_set;
00255      * mib_set.Type = MIB_ADR;
00256      * mib_set.param.adr_enable = true;
00257      *
00258      * if (mib_set_request_confirm(&mib_set) == LORAWAN_STATUS_OK) {
00259      *   // LoRaMAC updated the parameter
00260      * }
00261      *
00262      * @endcode
00263      *
00264      * @param [in] mib_set    The MIB-SET request to perform. Refer to
00265      *                        \ref loramac_mib_req_confirm_t.
00266      *
00267      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00268      *          \ref LORAWAN_STATUS_OK
00269      *          \ref LORAWAN_STATUS_BUSY
00270      *          \ref LORAWAN_STATUS_SERVICE_UNKNOWN
00271      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00272      */
00273     lorawan_status_t mib_set_request_confirm(loramac_mib_req_confirm_t  *mib_set);
00274 
00275     /**
00276      * @brief   Set forth an MLME request.
00277      *
00278      * @details The MAC layer management entity handles the management services. The
00279      *          following code-snippet shows how to use the API to perform a
00280      *          network join request.
00281      *
00282      * @code
00283      *
00284      * static uint8_t dev_eui[] =
00285      * {
00286      *   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
00287      * };
00288      * static uint8_t app_eui[] =
00289      * {
00290      *   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
00291      * };
00292      * static uint8_t app_key[] =
00293      * {
00294      *   0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
00295      *   0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
00296      * };
00297      *
00298      * loramac_mlme_req_t mlme_req;
00299      * mlme_req.Type = MLME_JOIN;
00300      * mlme_req.req.join.dev_eui = dev_eui;
00301      * mlme_req.req.join.app_eui = app_eui;
00302      * mlme_req.req.join.app_key = app_key;
00303      *
00304      * if (LoRaMacMlmeRequest(&mlme_req) == LORAWAN_STATUS_OK) {
00305      *   // Service started successfully. Waiting for the Mlme-Confirm event
00306      * }
00307      *
00308      * @endcode
00309      *
00310      * @param [in] request    The MLME request to perform.
00311      *                        Refer to \ref loramac_mlme_req_t.
00312      *
00313      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00314      *          \ref LORAWAN_STATUS_OK
00315      *          \ref LORAWAN_STATUS_BUSY
00316      *          \ref LORAWAN_STATUS_SERVICE_UNKNOWN
00317      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00318      *          \ref LORAWAN_STATUS_NO_NETWORK_JOINED
00319      *          \ref LORAWAN_STATUS_LENGTH_ERROR
00320      *          \ref LORAWAN_STATUS_DEVICE_OFF
00321      */
00322     lorawan_status_t mlme_request(loramac_mlme_req_t  *request);
00323 
00324     /**
00325      * @brief   Set forth an MCPS request.
00326      *
00327      * @details The MAC Common Part Sublayer handles the data services. The following
00328      *          code-snippet shows how to use the API to send an unconfirmed
00329      *          LoRaMAC frame.
00330      *
00331      * @code
00332      *
00333      * uint8_t buffer[] = {1, 2, 3};
00334      *
00335      * loramac_mcps_req_t request;
00336      * request.type = MCPS_UNCONFIRMED;
00337      * request.fport = 1;
00338      * request.f_buffer = buffer;
00339      * request.f_buffer_size = sizeof(buffer);
00340      *
00341      * if (mcps_request(&request) == LORAWAN_STATUS_OK) {
00342      *   // Service started successfully. Waiting for the MCPS-Confirm event
00343      * }
00344      *
00345      * @endcode
00346      *
00347      * @param [in] request    The MCPS request to perform.
00348      *                        Refer to \ref loramac_mcps_req_t.
00349      *
00350      * @return  `lorawan_status_t` The status of the operation. The possible values are:
00351      *          \ref LORAWAN_STATUS_OK
00352      *          \ref LORAWAN_STATUS_BUSY
00353      *          \ref LORAWAN_STATUS_SERVICE_UNKNOWN
00354      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00355      *          \ref LORAWAN_STATUS_NO_NETWORK_JOINED
00356      *          \ref LORAWAN_STATUS_LENGTH_ERROR
00357      *          \ref LORAWAN_STATUS_DEVICE_OFF
00358      */
00359     lorawan_status_t mcps_request(loramac_mcps_req_t  *request);
00360 
00361     /**
00362      * @brief LoRaMAC layer provides its callback functions for
00363      *        PHY layer.
00364      *
00365      * @return Pointer to callback functions for radio events
00366      */
00367     radio_events_t *get_phy_event_handlers();
00368 
00369     /**
00370      * @brief Configures the events to trigger an MLME-Indication with
00371      *        a MLME type of MLME_SCHEDULE_UPLINK.
00372      */
00373     void set_mlme_schedule_ul_indication(void);
00374 
00375     /**
00376      * @brief Schedules the frame for sending.
00377      *
00378      * @details Prepares a full MAC frame and schedules it for physical
00379      *          transmission.
00380      *
00381      * @param [in] mac_hdr      MAC frame header field
00382      * @param [in] fport        Payload port
00383      * @param [in] fbuffer      MAC frame data buffer to be sent
00384      * @param [in] fbuffer_size MAC frame data buffer size
00385      *
00386      * @return status          Status of the operation. LORAWAN_STATUS_OK in case
00387      *                         of success and a negative error code in case of
00388      *                         failure.
00389      */
00390     lorawan_status_t send(loramac_mhdr_t  *mac_hdr, uint8_t fport, void *fbuffer,
00391                           uint16_t fbuffer_size);
00392 
00393     /**
00394      * @brief Puts the system in continuous transmission mode
00395      *
00396      * @remark Uses the radio parameters set on the previous transmission.
00397      *
00398      * @param [in] timeout    Time in seconds while the radio is kept in continuous wave mode
00399      *
00400      * @return status          Status of the operation. LORAWAN_STATUS_OK in case
00401      *                         of success and a negative error code in case of
00402      *                         failure.
00403      */
00404     lorawan_status_t set_tx_continuous_wave(uint16_t timeout);
00405 
00406     /**
00407      * @brief Puts the system in continuous transmission mode
00408      *
00409      * @param [in] timeout     Time in seconds while the radio is kept in continuous wave mode
00410      * @param [in] frequency   RF frequency to be set.
00411      * @param [in] power       RF output power to be set.
00412      *
00413      * @return status          Status of the operation. LORAWAN_STATUS_OK in case
00414      *                         of success and a negative error code in case of
00415      *                         failure.
00416      */
00417     lorawan_status_t set_tx_continuous_wave1(uint16_t timeout, uint32_t frequency, uint8_t power);
00418 
00419     /**
00420      * @brief Resets MAC specific parameters to default
00421      */
00422     void reset_mac_parameters(void);
00423 
00424     /**
00425      * @brief Opens up a continuous RX 2 window. This is used for
00426      *        class c devices.
00427      */
00428     void open_continuous_rx2_window(void);
00429 
00430 
00431 
00432 private:
00433     /**
00434      * Function to be executed on Radio Tx Done event
00435      */
00436     void on_radio_tx_done(void);
00437 
00438     /**
00439      * This function prepares the MAC to abort the execution of function
00440      * on_radio_rx_done() in case of a reception error.
00441      */
00442     void prepare_rx_done_abort(void);
00443 
00444     /**
00445      * Function to be executed on Radio Rx Done event
00446      */
00447     void on_radio_rx_done(uint8_t *payload, uint16_t size, int16_t rssi,
00448                           int8_t snr);
00449 
00450     /**
00451      * Function executed on Radio Tx Timeout event
00452      */
00453     void on_radio_tx_timeout(void);
00454 
00455     /**
00456      * Function executed on Radio Rx error event
00457      */
00458     void on_radio_rx_error(void);
00459 
00460     /**
00461      * Function executed on Radio Rx Timeout event
00462      */
00463     void on_radio_rx_timeout(void);
00464 
00465     /**
00466      *Function executed on Resend Frame timer event.
00467      */
00468     void on_mac_state_check_timer_event(void);
00469 
00470     /**
00471      * Function executed on duty cycle delayed Tx  timer event
00472      */
00473     void on_tx_delayed_timer_event(void);
00474 
00475     /**
00476      * Function executed on first Rx window timer event
00477      */
00478     void on_rx_window1_timer_event(void);
00479 
00480     /**
00481      * Function executed on second Rx window timer event
00482      */
00483     void on_rx_window2_timer_event(void);
00484 
00485     /**
00486      * Function executed on AckTimeout timer event
00487      */
00488     void on_ack_timeout_timer_event(void);
00489 
00490     /**
00491      * Initializes and opens the reception window
00492      */
00493     void rx_window_setup(bool rx_continuous, uint32_t max_rx_window_time);
00494 
00495     /**
00496      * Validates if the payload fits into the frame, taking the datarate
00497      * into account.
00498      *
00499      * Please Refer to chapter 4.3.2 of the LoRaWAN specification, v1.0.2
00500      */
00501     bool validate_payload_length(uint8_t length, int8_t datarate, uint8_t fopts_len);
00502 
00503     /**
00504      * Prepares MAC frame on the behest of send() API.
00505      */
00506     lorawan_status_t prepare_frame(loramac_mhdr_t  *mac_hdr,
00507                                    loramac_frame_ctrl_t  *fctrl, uint8_t fport,
00508                                    void *fbuffer, uint16_t fbuffer_size);
00509 
00510     /**
00511      * Schedules a transmission on the behest of send() API.
00512      */
00513     lorawan_status_t schedule_tx(void);
00514 
00515     /**
00516      * Calculates the back-off time for the band of a channel.
00517      * Takes in the last used channel id as a parameter.
00518      */
00519     void calculate_backOff(uint8_t channel_id);
00520 
00521     /**
00522      * Hands over the MAC frame to PHY layer.
00523      */
00524     lorawan_status_t send_frame_on_channel(uint8_t channel);
00525 
00526     /**
00527      * Checks for Port validity.
00528      */
00529     bool is_fPort_allowed(uint8_t fPort);
00530 
00531     /**
00532      * Prototypes for ISR handlers
00533      */
00534     void handle_cad_done(bool cad);
00535     void handle_tx_done(void);
00536     void handle_rx_done(uint8_t *payload, uint16_t size, int16_t rssi,
00537                         int8_t snr);
00538     void handle_rx_error(void);
00539     void handle_rx_timeout(void);
00540     void handle_tx_timeout(void);
00541     void handle_fhss_change_channel(uint8_t cur_channel);
00542     void handle_rx1_timer_event(void);
00543     void handle_rx2_timer_event(void);
00544     void handle_ack_timeout(void);
00545     void handle_delayed_tx_timer_event(void);
00546     void handle_mac_state_check_timer_event(void);
00547     void handle_next_tx_timer_event(void);
00548 
00549 private:
00550     /**
00551      * LoRa PHY layer object storage
00552      */
00553     LoRaPHY *lora_phy;
00554 
00555     /**
00556      * MAC command handle
00557      */
00558     LoRaMacCommand mac_commands;
00559 
00560     /**
00561      * MLME subsystem handle
00562      */
00563     LoRaMacMlme mlme;
00564 
00565     /**
00566      * MCPS subsystem handle
00567      */
00568     LoRaMacMcps mcps;
00569 
00570     /**
00571      * MCPS subsystem handle
00572      */
00573     LoRaMacMib mib;
00574 
00575     /**
00576      * Channel planning subsystem
00577      */
00578     LoRaMacChannelPlan channel_plan;
00579 
00580     /**
00581      * Timer subsystem handle
00582      */
00583     LoRaWANTimeHandler &_lora_time;
00584 
00585     /**
00586      * Central MAC layer data storage
00587      */
00588     loramac_protocol_params _params;
00589 
00590     /**
00591      * Radio event callback handlers for MAC
00592      */
00593     radio_events_t radio_events;
00594 
00595     /**
00596      * LoRaMac upper layer event functions
00597      */
00598     loramac_primitives_t  *mac_primitives;
00599 
00600     /**
00601      * EventQueue object storage
00602      */
00603     events::EventQueue *ev_queue;
00604 
00605 #if defined(LORAWAN_COMPLIANCE_TEST)
00606 public: // Test interface
00607 
00608     /**
00609      * \brief   LoRaMAC set tx timer.
00610      *
00611      * \details Sets up a timer for next transmission (application specific timers).
00612      *
00613      * \param   [in] NextTxTime - Periodic time for next uplink.
00614 
00615      * \retval  `lorawan_status_t` The status of the operation. The possible values are:
00616      *          \ref LORAWAN_STATUS_OK
00617      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00618      */
00619     lorawan_status_t LoRaMacSetTxTimer( uint32_t NextTxTime );
00620 
00621     /**
00622      * \brief   LoRaMAC stop tx timer.
00623      *
00624      * \details Stops the next tx timer.
00625      *
00626      * \retval  `lorawan_status_t` The status of the operation. The possible values are:
00627      *          \ref LORAWAN_STATUS_OK
00628      *          \ref LORAWAN_STATUS_PARAMETER_INVALID
00629      */
00630     lorawan_status_t LoRaMacStopTxTimer( );
00631 
00632     /**
00633      * \brief   Enabled or disables the reception windows
00634      *
00635      * \details This is a test function. It shall be used for testing purposes only.
00636      *          Changing this attribute may lead to a non-conformance LoRaMac operation.
00637      *
00638      * \param   [in] enable - Enabled or disables the reception windows
00639      */
00640     void LoRaMacTestRxWindowsOn( bool enable );
00641 
00642     /**
00643      * \brief   Enables the MIC field test
00644      *
00645      * \details This is a test function. It shall be used for testing purposes only.
00646      *          Changing this attribute may lead to a non-conformance LoRaMac operation.
00647      *
00648      * \param   [in] txPacketCounter - Fixed Tx packet counter value
00649      */
00650     void LoRaMacTestSetMic( uint16_t txPacketCounter );
00651 
00652     /**
00653      * \brief   Enabled or disables the duty cycle
00654      *
00655      * \details This is a test function. It shall be used for testing purposes only.
00656      *          Changing this attribute may lead to a non-conformance LoRaMac operation.
00657      *
00658      * \param   [in] enable - Enabled or disables the duty cycle
00659      */
00660     void LoRaMacTestSetDutyCycleOn( bool enable );
00661 
00662     /**
00663      * \brief   Sets the channel index
00664      *
00665      * \details This is a test function. It shall be used for testing purposes only.
00666      *          Changing this attribute may lead to a non-conformance LoRaMac operation.
00667      *
00668      * \param   [in] channel - Channel index
00669      */
00670     void LoRaMacTestSetChannel( uint8_t channel );
00671 
00672 private:
00673     /**
00674      * Timer to handle the application data transmission duty cycle
00675      */
00676     timer_event_t tx_next_packet_timer;
00677 #endif
00678 };
00679 
00680 #endif // MBED_LORAWAN_MAC_H__