Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

212 lines
5.7 KiB

  1. /*!
  2. * \file RegionCN470B26.h
  3. *
  4. * \brief Specific implementations of Channel plan type B, 26MHz.
  5. *
  6. * \copyright Revised BSD License, see section \ref LICENSE.
  7. *
  8. * \code
  9. * ______ _
  10. * / _____) _ | |
  11. * ( (____ _____ ____ _| |_ _____ ____| |__
  12. * \____ \| ___ | (_ _) ___ |/ ___) _ \
  13. * _____) ) ____| | | || |_| ____( (___| | | |
  14. * (______/|_____)_|_|_| \__)_____)\____)_| |_|
  15. * (C)2013-2017 Semtech
  16. *
  17. * ___ _____ _ ___ _ _____ ___ ___ ___ ___
  18. * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
  19. * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
  20. * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
  21. * embedded.connectivity.solutions===============
  22. *
  23. * \endcode
  24. *
  25. * \author Miguel Luis ( Semtech )
  26. *
  27. * \author Daniel Jaeckle ( STACKFORCE )
  28. *
  29. * \defgroup REGIONCN470
  30. *
  31. * \{
  32. */
  33. #ifndef __REGION_CN470_B26_H__
  34. #define __REGION_CN470_B26_H__
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. #include "region/Region.h"
  40. /*!
  41. * The maximum number of channels.
  42. * Channel plan type B, 26MHz.
  43. */
  44. #define CN470_B26_CHANNELS_MASK_SIZE 3
  45. /*!
  46. * The number of entries in the join accept list.
  47. * Channel plan type B, 26MHz.
  48. */
  49. #define CN470_B26_JOIN_ACCEPT_LIST_SIZE 3
  50. /*!
  51. * The number of channels available for the beacon.
  52. * Channel plan type B, 26MHz.
  53. */
  54. #define CN470_B26_BEACON_NB_CHANNELS 1
  55. /*!
  56. * The number of channels available for the ping slots.
  57. * Channel plan type B, 26MHz.
  58. */
  59. #define CN470_B26_PING_SLOT_NB_CHANNELS 1
  60. /*!
  61. * The first RX channel, downstream group 1.
  62. * Channel plan type B, 26MHz.
  63. */
  64. #define CN470_B26_FIRST_RX_CHANNEL 500100000
  65. /*!
  66. * The last RX channel, downstream group 1.
  67. * Channel plan type B, 26MHz.
  68. */
  69. #define CN470_B26_LAST_RX_CHANNEL 504700000
  70. /*!
  71. * The frequency stepwidth between RX channels,
  72. * downstream group 1 and 2.
  73. * Channel plan type B, 26MHz.
  74. */
  75. #define CN470_B26_STEPWIDTH_RX_CHANNEL 200000
  76. /*!
  77. * The first TX channel, upstream group 1.
  78. * Channel plan type B, 26MHz.
  79. */
  80. #define CN470_B26_FIRST_TX_CHANNEL 480300000
  81. /*!
  82. * The last TX channel, upstream group 1.
  83. * Channel plan type B, 26MHz.
  84. */
  85. #define CN470_B26_LAST_TX_CHANNEL 489700000
  86. /*!
  87. * The frequency stepwidth between RX channels,
  88. * upstream group 1.
  89. * Channel plan type B, 26MHz.
  90. */
  91. #define CN470_B26_STEPWIDTH_TX_CHANNEL 200000
  92. /*!
  93. * The default frequency for RX window 2,
  94. * Channel plan type B, 26MHz.
  95. */
  96. #define CN470_B26_RX_WND_2_FREQ 502500000
  97. /*!
  98. * The default frequency for beacon,
  99. * Channel plan type B, 26MHz.
  100. */
  101. #define CN470_B26_BEACON_FREQ 504900000
  102. /*!
  103. * \brief Calculation of the beacon frequency.
  104. *
  105. * \param [IN] channel The Beacon channel number.
  106. *
  107. * \param [IN] joinChannelIndex The join channel index.
  108. *
  109. * \param [IN] isPingSlot Set to true, if its a ping slot.
  110. *
  111. * \retval Returns the beacon frequency.
  112. */
  113. uint32_t RegionCN470B26GetDownlinkFrequency( uint8_t channel, uint8_t joinChannelIndex, bool isPingSlot );
  114. /*!
  115. * \brief Performs the update of the channelsMask based on the input parameters
  116. * for the Channel plan type B, 26MHz.
  117. *
  118. * \param [IN] joinChannelIndex The join channel index.
  119. *
  120. * \retval Returns the offset for the given join channel.
  121. */
  122. uint8_t RegionCN470B26GetBeaconChannelOffset( uint8_t joinChannelIndex );
  123. /*!
  124. * \brief Performs the update of the channelsMask based on the input parameters
  125. * for the Channel plan type B, 26MHz.
  126. *
  127. * \param [IN] channelsMask A pointer to the channels mask.
  128. *
  129. * \param [IN] chMaskCntl The value of the chMaskCntl field of the LinkAdrReq.
  130. *
  131. * \param [IN] chanMask The value of the chanMask field of the LinkAdrReq.
  132. *
  133. * \param [IN] channels A pointer to the available channels.
  134. *
  135. * \retval Status of the operation. Return 0x07 if the channels mask is valid.
  136. */
  137. uint8_t RegionCN470B26LinkAdrChMaskUpdate( uint16_t* channelsMask, uint8_t chMaskCntl,
  138. uint16_t chanMask, ChannelParams_t* channels );
  139. /*!
  140. * \brief Verifies if the frequency provided is valid
  141. * for the Channel plan type B, 26MHz.
  142. *
  143. * \param [IN] frequency The frequency to verify.
  144. *
  145. * \retval Returns true, if the frequency is valid.
  146. */
  147. bool RegionCN470B26VerifyRfFreq( uint32_t frequency );
  148. /*!
  149. * \brief Initializes all channels, datarates, frequencies and bands
  150. * for the Channel plan type B, 26MHz.
  151. *
  152. * \param [IN] channels A pointer to the available channels.
  153. */
  154. void RegionCN470B26InitializeChannels( ChannelParams_t* channels );
  155. /*!
  156. * \brief Initializes the channels mask and the channels default mask
  157. * for the Channel plan type B, 26MHz.
  158. *
  159. * \param [IN] channelsDefaultMask A pointer to the channels default mask.
  160. */
  161. void RegionCN470B26InitializeChannelsMask( uint16_t* channelsDefaultMask );
  162. /*!
  163. * \brief Computes the frequency for the RX1 window
  164. * for the Channel plan type B, 26MHz.
  165. *
  166. * \param [IN] channel The channel utilized currently.
  167. *
  168. * \retval Returns the frequency which shall be used.
  169. */
  170. uint32_t RegionCN470B26GetRx1Frequency( uint8_t channel );
  171. /*!
  172. * \brief Computes the frequency for the RX2 window
  173. * for the Channel plan type B, 26MHz.
  174. *
  175. * \param [IN] joinChannelIndex The join channel index.
  176. *
  177. * \param [IN] isOtaaDevice Set to true, if the device is an OTAA device.
  178. *
  179. * \retval Returns the frequency which shall be used.
  180. */
  181. uint32_t RegionCN470B26GetRx2Frequency( uint8_t joinChannelIndex, bool isOtaaDevice );
  182. /*! \} defgroup REGIONCN470 */
  183. #ifdef __cplusplus
  184. }
  185. #endif
  186. #endif // __REGION_CN470_B26_H__