Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRaPHYUS915.h Source File

LoRaPHYUS915.h

Go to the documentation of this file.
00001 /**
00002  *  @file LoRaPHYUS915.h
00003  *
00004  *  @brief Implements LoRaPHY for US 915 MHz band
00005  *
00006  *  \code
00007  *   ______                              _
00008  *  / _____)             _              | |
00009  * ( (____  _____ ____ _| |_ _____  ____| |__
00010  *  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00011  *  _____) ) ____| | | || |_| ____( (___| | | |
00012  * (______/|_____)_|_|_| \__)_____)\____)_| |_|
00013  *   (C)2013 Semtech
00014  *  ___ _____ _   ___ _  _____ ___  ___  ___ ___
00015  * / __|_   _/_\ / __| |/ / __/ _ \| _ \/ __| __|
00016  * \__ \ | |/ _ \ (__| ' <| _| (_) |   / (__| _|
00017  * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
00018  * embedded.connectivity.solutions===============
00019  *
00020  * \endcode
00021  *
00022  *
00023  * License: Revised BSD License, see LICENSE.TXT file include in the project
00024  *
00025  * Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE )
00026  *
00027  * Copyright (c) 2017, Arm Limited and affiliates.
00028  * SPDX-License-Identifier: BSD-3-Clause
00029  *
00030  */
00031 
00032 #ifndef MBED_OS_LORAPHYUS_915_H_
00033 #define MBED_OS_LORAPHYUS_915_H_
00034 
00035 #if !(DOXYGEN_ONLY)
00036 
00037 #include "LoRaPHY.h"
00038 
00039 /*!
00040  * LoRaMac maximum number of channels
00041  */
00042 #define US915_MAX_NB_CHANNELS                       72
00043 
00044 /*!
00045  * LoRaMac maximum number of bands
00046  */
00047 #define US915_MAX_NB_BANDS                          1
00048 
00049 #define US915_CHANNEL_MASK_SIZE                    5
00050 
00051 
00052 class LoRaPHYUS915 : public LoRaPHY {
00053 
00054 public:
00055 
00056     LoRaPHYUS915();
00057     virtual ~LoRaPHYUS915();
00058 
00059     virtual void restore_default_channels();
00060 
00061     virtual bool rx_config(rx_config_params_t  *config);
00062 
00063     virtual bool tx_config(tx_config_params_t *config, int8_t *tx_power,
00064                            lorawan_time_t *tx_toa);
00065 
00066     virtual uint8_t link_ADR_request(adr_req_params_t *params,
00067                                      int8_t *dr_out, int8_t *tx_power_out,
00068                                      uint8_t *nb_rep_out,
00069                                      uint8_t *nb_bytes_parsed);
00070 
00071     virtual uint8_t accept_rx_param_setup_req(rx_param_setup_req_t *params);
00072 
00073     virtual int8_t get_alternate_DR(uint8_t nb_trials);
00074 
00075     virtual lorawan_status_t set_next_channel(channel_selection_params_t *params, uint8_t *channel,
00076                                               lorawan_time_t *time, lorawan_time_t *aggregate_timeOff);
00077 
00078     virtual void set_tx_cont_mode(cw_mode_params_t  *continuousWave,
00079                                   uint32_t frequency = 0);
00080 
00081     virtual uint8_t apply_DR_offset(int8_t dr, int8_t dr_offset);
00082 
00083 private:
00084 
00085     /**
00086      * Sets the intersection of source and destination channel masks
00087      * into the destination.
00088      */
00089     void intersect_channel_mask(const uint16_t *source, uint16_t *destination,
00090                                 uint8_t size);
00091 
00092     /**
00093      * Fills channel mask array based upon the provided FSB mask
00094      */
00095     void fill_channel_mask_with_fsb(const uint16_t *expectation,
00096                                     const uint16_t *fsb_mask,
00097                                     uint16_t *channel_mask, uint8_t size);
00098 
00099     /**
00100      * Fills channel mask array with a given value
00101      */
00102     void fill_channel_mask_with_value(uint16_t *channel_mask,
00103                                       uint16_t value, uint8_t size);
00104 
00105     int8_t limit_tx_power(int8_t tx_power, int8_t max_band_tx_power,
00106                           int8_t datarate);
00107 
00108     /*!
00109      * LoRaMAC channels
00110      */
00111     channel_params_t channels[US915_MAX_NB_CHANNELS];
00112 
00113     /*!
00114      * LoRaMac bands
00115      */
00116     band_t  bands[US915_MAX_NB_BANDS];
00117 
00118     /*!
00119      * LoRaMac channel mask
00120      */
00121     uint16_t channel_mask[US915_CHANNEL_MASK_SIZE];
00122 
00123     /*!
00124      * Previously used channel mask
00125      */
00126     uint16_t current_channel_mask[US915_CHANNEL_MASK_SIZE];
00127 
00128     /*!
00129      * LoRaMac default channel mask
00130      */
00131     uint16_t default_channel_mask[US915_CHANNEL_MASK_SIZE];
00132 };
00133 
00134 #endif /* DOXYGEN_ONLY */
00135 #endif /* MBED_OS_LORAPHY_US915_H_ */