LoRaMac.h 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717
  1. /*!
  2. * \file LoRaMac.h
  3. *
  4. * \brief LoRa MAC layer implementation
  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 Gregory Cristian ( Semtech )
  28. *
  29. * \author Daniel Jaeckle ( STACKFORCE )
  30. *
  31. * \author Johannes Bruder ( STACKFORCE )
  32. *
  33. * \defgroup LORAMAC LoRa MAC layer implementation
  34. * This module specifies the API implementation of the LoRaMAC layer.
  35. * This is a placeholder for a detailed description of the LoRaMac
  36. * layer and the supported features.
  37. * \{
  38. *
  39. * \example classA/B-L072Z-LRWAN1/main.c
  40. * LoRaWAN class A application example for the B-L072Z-LRWAN1.
  41. *
  42. * \example classB/B-L072Z-LRWAN1/main.c
  43. * LoRaWAN class B application example for the B-L072Z-LRWAN1.
  44. *
  45. * \example classC/B-L072Z-LRWAN1/main.c
  46. * LoRaWAN class C application example for the B-L072Z-LRWAN1.
  47. *
  48. * \example classA/NAMote72/main.c
  49. * LoRaWAN class A application example for the NAMote72.
  50. *
  51. * \example classB/NAMote72/main.c
  52. * LoRaWAN class B application example for the NAMote72.
  53. *
  54. * \example classC/NAMote72/main.c
  55. * LoRaWAN class C application example for the NAMote72.
  56. *
  57. * \example classA/NucleoL073/main.c
  58. * LoRaWAN class A application example for the NucleoL073.
  59. *
  60. * \example classB/NucleoL073/main.c
  61. * LoRaWAN class B application example for the NucleoL073.
  62. *
  63. * \example classC/NucleoL073/main.c
  64. * LoRaWAN class C application example for the NucleoL073.
  65. *
  66. * \example classA/NucleoL152/main.c
  67. * LoRaWAN class A application example for the NucleoL152.
  68. *
  69. * \example classB/NucleoL152/main.c
  70. * LoRaWAN class B application example for the NucleoL152.
  71. *
  72. * \example classC/NucleoL152/main.c
  73. * LoRaWAN class C application example for the NucleoL152.
  74. *
  75. * \example classA/NucleoL476/main.c
  76. * LoRaWAN class A application example for the NucleoL476.
  77. *
  78. * \example classB/NucleoL476/main.c
  79. * LoRaWAN class B application example for the NucleoL476.
  80. *
  81. * \example classC/NucleoL476/main.c
  82. * LoRaWAN class C application example for the NucleoL476.
  83. *
  84. * \example classA/SAML21/main.c
  85. * LoRaWAN class A application example for the SAML21.
  86. *
  87. * \example classB/SAML21/main.c
  88. * LoRaWAN class B application example for the SAML21.
  89. *
  90. * \example classC/SAML21/main.c
  91. * LoRaWAN class C application example for the SAML21.
  92. *
  93. * \example classA/SKiM880B/main.c
  94. * LoRaWAN class A application example for the SKiM880B.
  95. *
  96. * \example classB/SKiM880B/main.c
  97. * LoRaWAN class B application example for the SKiM880B.
  98. *
  99. * \example classC/SKiM880B/main.c
  100. * LoRaWAN class C application example for the SKiM880B.
  101. *
  102. * \example classA/SKiM881AXL/main.c
  103. * LoRaWAN class A application example for the SKiM881AXL.
  104. *
  105. * \example classB/SKiM881AXL/main.c
  106. * LoRaWAN class B application example for the SKiM881AXL.
  107. *
  108. * \example classC/SKiM881AXL/main.c
  109. * LoRaWAN class C application example for the SKiM881AXL.
  110. *
  111. * \example classA/SKiM980A/main.c
  112. * LoRaWAN class A application example for the SKiM980A.
  113. *
  114. * \example classB/SKiM980A/main.c
  115. * LoRaWAN class B application example for the SKiM980A.
  116. *
  117. * \example classC/SKiM980A/main.c
  118. * LoRaWAN class C application example for the SKiM980A.
  119. *
  120. */
  121. #ifndef __LORAMAC_H__
  122. #define __LORAMAC_H__
  123. #ifdef __cplusplus
  124. extern "C"
  125. {
  126. #endif
  127. #include <stdint.h>
  128. #include <stdbool.h>
  129. #include "utilities.h"
  130. #include "lora-radio-timer.h"
  131. #include "systime.h"
  132. #include "lora-radio.h"
  133. #include "LoRaMacTypes.h"
  134. /*!
  135. * Maximum number of times the MAC layer tries to get an acknowledge.
  136. */
  137. #define MAX_ACK_RETRIES 8
  138. /*!
  139. * Frame direction definition for up-link communications
  140. */
  141. #define UP_LINK 0
  142. /*!
  143. * Frame direction definition for down-link communications
  144. */
  145. #define DOWN_LINK 1
  146. /*!
  147. * Sets the length of the LoRaMAC footer field.
  148. * Mainly indicates the MIC field length
  149. */
  150. #define LORAMAC_MFR_LEN 4
  151. /*!
  152. * LoRaMac MLME-Confirm queue length
  153. */
  154. #define LORA_MAC_MLME_CONFIRM_QUEUE_LEN 5
  155. /*!
  156. * FRMPayload overhead to be used when setting the Radio.SetMaxPayloadLength
  157. * in RxWindowSetup function.
  158. * Maximum PHYPayload = MaxPayloadOfDatarate/MaxPayloadOfDatarateRepeater + LORA_MAC_FRMPAYLOAD_OVERHEAD
  159. */
  160. #define LORA_MAC_FRMPAYLOAD_OVERHEAD 13 // MHDR(1) + FHDR(7) + Port(1) + MIC(4)
  161. /*!
  162. * Maximum number of multicast context
  163. */
  164. #define LORAMAC_MAX_MC_CTX 4
  165. /*!
  166. * Start value for multicast keys enumeration
  167. */
  168. #define LORAMAC_CRYPTO_MULTICAST_KEYS 127
  169. /*!
  170. * End-Device activation type
  171. */
  172. typedef enum eActivationType
  173. {
  174. /*!
  175. * None
  176. */
  177. ACTIVATION_TYPE_NONE = 0,
  178. /*!
  179. * Activation By Personalization (ACTIVATION_TYPE_ABP)
  180. */
  181. ACTIVATION_TYPE_ABP = 1,
  182. /*!
  183. * Over-The-Air Activation (ACTIVATION_TYPE_OTAA)
  184. */
  185. ACTIVATION_TYPE_OTAA = 2,
  186. }ActivationType_t;
  187. /*!
  188. * LoRaMAC channels parameters definition
  189. */
  190. typedef union uDrRange
  191. {
  192. /*!
  193. * Byte-access to the bits
  194. */
  195. int8_t Value;
  196. /*!
  197. * Structure to store the minimum and the maximum datarate
  198. */
  199. struct sFields
  200. {
  201. /*!
  202. * Minimum data rate
  203. *
  204. * LoRaWAN Regional Parameters V1.0.2rB
  205. *
  206. * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details.
  207. */
  208. int8_t Min : 4;
  209. /*!
  210. * Maximum data rate
  211. *
  212. * LoRaWAN Regional Parameters V1.0.2rB
  213. *
  214. * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details.
  215. */
  216. int8_t Max : 4;
  217. }Fields;
  218. }DrRange_t;
  219. /*!
  220. * LoRaMAC channel definition
  221. */
  222. typedef struct sChannelParams
  223. {
  224. /*!
  225. * Frequency in Hz
  226. */
  227. uint32_t Frequency;
  228. /*!
  229. * Alternative frequency for RX window 1
  230. */
  231. uint32_t Rx1Frequency;
  232. /*!
  233. * Data rate definition
  234. */
  235. DrRange_t DrRange;
  236. /*!
  237. * Band index
  238. */
  239. uint8_t Band;
  240. }ChannelParams_t;
  241. /*!
  242. * LoRaMAC receive window channel parameters
  243. */
  244. typedef struct sRxChannelParams
  245. {
  246. /*!
  247. * Frequency in Hz
  248. */
  249. uint32_t Frequency;
  250. /*!
  251. * Data rate
  252. *
  253. * LoRaWAN Regional Parameters V1.0.2rB
  254. *
  255. * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details.
  256. */
  257. uint8_t Datarate;
  258. }RxChannelParams_t;
  259. /*!
  260. * LoRaMAC receive window enumeration
  261. */
  262. typedef enum eLoRaMacRxSlot
  263. {
  264. /*!
  265. * LoRaMAC receive window 1
  266. */
  267. RX_SLOT_WIN_1,
  268. /*!
  269. * LoRaMAC receive window 2
  270. */
  271. RX_SLOT_WIN_2,
  272. /*!
  273. * LoRaMAC receive window 2 for class c - continuous listening
  274. */
  275. RX_SLOT_WIN_CLASS_C,
  276. /*!
  277. * LoRaMAC class c multicast downlink
  278. */
  279. RX_SLOT_WIN_CLASS_C_MULTICAST,
  280. /*!
  281. * LoRaMAC class b ping slot window
  282. */
  283. RX_SLOT_WIN_CLASS_B_PING_SLOT,
  284. /*!
  285. * LoRaMAC class b multicast slot window
  286. */
  287. RX_SLOT_WIN_CLASS_B_MULTICAST_SLOT,
  288. /*!
  289. * LoRaMAC no active receive window
  290. */
  291. RX_SLOT_NONE,
  292. }LoRaMacRxSlot_t;
  293. /*!
  294. * LoRaMAC structure to hold internal context pointers and its lengths
  295. */
  296. typedef struct sLoRaMacCtxs
  297. {
  298. /*!
  299. * \brief Pointer to Mac context
  300. */
  301. void* MacNvmCtx;
  302. /*!
  303. * \brief Size of Mac context
  304. */
  305. size_t MacNvmCtxSize;
  306. /*!
  307. * \brief Pointer to region context
  308. */
  309. void* RegionNvmCtx;
  310. /*!
  311. * \brief Size of region context
  312. */
  313. size_t RegionNvmCtxSize;
  314. /*!
  315. * \brief Pointer to crypto module context
  316. */
  317. void* CryptoNvmCtx;
  318. /*!
  319. * \brief Size of crypto module context
  320. */
  321. size_t CryptoNvmCtxSize;
  322. /*!
  323. * \brief Pointer to secure element driver context
  324. */
  325. void* SecureElementNvmCtx;
  326. /*!
  327. * \brief Size of secure element driver context
  328. */
  329. size_t SecureElementNvmCtxSize;
  330. /*!
  331. * \brief Pointer to MAC commands module context
  332. */
  333. void* CommandsNvmCtx;
  334. /*!
  335. * \brief Size of MAC commands module context
  336. */
  337. size_t CommandsNvmCtxSize;
  338. /*!
  339. * \brief Pointer to Class B module context
  340. */
  341. void* ClassBNvmCtx;
  342. /*!
  343. * \brief Size of MAC Class B module context
  344. */
  345. size_t ClassBNvmCtxSize;
  346. /*!
  347. * \brief Pointer to MLME Confirm queue module context
  348. */
  349. void* ConfirmQueueNvmCtx;
  350. /*!
  351. * \brief Size of MLME Confirm queue module context
  352. */
  353. size_t ConfirmQueueNvmCtxSize;
  354. }LoRaMacCtxs_t;
  355. /*!
  356. * Global MAC layer parameters
  357. */
  358. typedef struct sLoRaMacParams
  359. {
  360. /*!
  361. * Channels TX power
  362. */
  363. int8_t ChannelsTxPower;
  364. /*!
  365. * Channels data rate
  366. */
  367. int8_t ChannelsDatarate;
  368. /*!
  369. * System overall timing error in milliseconds.
  370. * [-SystemMaxRxError : +SystemMaxRxError]
  371. * Default: +/-10 ms
  372. */
  373. uint32_t SystemMaxRxError;
  374. /*!
  375. * Minimum required number of symbols to detect an Rx frame
  376. * Default: 6 symbols
  377. */
  378. uint8_t MinRxSymbols;
  379. /*!
  380. * LoRaMac maximum time a reception window stays open
  381. */
  382. uint32_t MaxRxWindow;
  383. /*!
  384. * Receive delay 1
  385. */
  386. uint32_t ReceiveDelay1;
  387. /*!
  388. * Receive delay 2
  389. */
  390. uint32_t ReceiveDelay2;
  391. /*!
  392. * Join accept delay 1
  393. */
  394. uint32_t JoinAcceptDelay1;
  395. /*!
  396. * Join accept delay 1
  397. */
  398. uint32_t JoinAcceptDelay2;
  399. /*!
  400. * Number of uplink messages repetitions [1:15] (unconfirmed messages only)
  401. */
  402. uint8_t ChannelsNbTrans;
  403. /*!
  404. * Datarate offset between uplink and downlink on first window
  405. */
  406. uint8_t Rx1DrOffset;
  407. /*!
  408. * LoRaMAC 2nd reception window settings
  409. */
  410. RxChannelParams_t Rx2Channel;
  411. /*!
  412. * LoRaMAC continuous reception window settings
  413. */
  414. RxChannelParams_t RxCChannel;
  415. /*!
  416. * Uplink dwell time configuration. 0: No limit, 1: 400ms
  417. */
  418. uint8_t UplinkDwellTime;
  419. /*!
  420. * Downlink dwell time configuration. 0: No limit, 1: 400ms
  421. */
  422. uint8_t DownlinkDwellTime;
  423. /*!
  424. * Maximum possible EIRP
  425. */
  426. float MaxEirp;
  427. /*!
  428. * Antenna gain of the node
  429. */
  430. float AntennaGain;
  431. /*!
  432. * Indicates if the node supports repeaters
  433. */
  434. bool RepeaterSupport;
  435. }LoRaMacParams_t;
  436. /*!
  437. * LoRaMAC data structure for a PingSlotInfoReq \ref MLME_PING_SLOT_INFO
  438. *
  439. * LoRaWAN Specification
  440. */
  441. typedef union uPingSlotInfo
  442. {
  443. /*!
  444. * Parameter for byte access
  445. */
  446. uint8_t Value;
  447. /*!
  448. * Structure containing the parameters for the PingSlotInfoReq
  449. */
  450. struct sInfoFields
  451. {
  452. /*!
  453. * Periodicity = 0: ping slot every second
  454. * Periodicity = 7: ping slot every 128 seconds
  455. */
  456. uint8_t Periodicity : 3;
  457. /*!
  458. * RFU
  459. */
  460. uint8_t RFU : 5;
  461. }Fields;
  462. }PingSlotInfo_t;
  463. /*!
  464. * LoRaMAC data structure for the \ref MLME_BEACON MLME-Indication
  465. *
  466. * LoRaWAN Specification
  467. */
  468. typedef struct sBeaconInfo
  469. {
  470. /*!
  471. * Timestamp in seconds since 00:00:00, Sunday 6th of January 1980
  472. * (start of the GPS epoch) modulo 2^32
  473. */
  474. SysTime_t Time;
  475. /*!
  476. * Frequency
  477. */
  478. uint32_t Frequency;
  479. /*!
  480. * Datarate
  481. */
  482. uint8_t Datarate;
  483. /*!
  484. * RSSI
  485. */
  486. int16_t Rssi;
  487. /*!
  488. * SNR
  489. */
  490. int8_t Snr;
  491. /*!
  492. * Data structure for the gateway specific part. The
  493. * content of the values may differ for each gateway
  494. */
  495. struct sGwSpecific
  496. {
  497. /*!
  498. * Info descriptor - can differ for each gateway
  499. */
  500. uint8_t InfoDesc;
  501. /*!
  502. * Info - can differ for each gateway
  503. */
  504. uint8_t Info[6];
  505. }GwSpecific;
  506. }BeaconInfo_t;
  507. /*!
  508. * Enumeration containing the status of the operation of a MAC service
  509. */
  510. typedef enum eLoRaMacEventInfoStatus
  511. {
  512. /*!
  513. * Service performed successfully
  514. */
  515. LORAMAC_EVENT_INFO_STATUS_OK = 0,
  516. /*!
  517. * An error occurred during the execution of the service
  518. */
  519. LORAMAC_EVENT_INFO_STATUS_ERROR,
  520. /*!
  521. * A Tx timeout occurred
  522. */
  523. LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT,
  524. /*!
  525. * An Rx timeout occurred on receive window 1
  526. */
  527. LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT,
  528. /*!
  529. * An Rx timeout occurred on receive window 2
  530. */
  531. LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT,
  532. /*!
  533. * An Rx error occurred on receive window 1
  534. */
  535. LORAMAC_EVENT_INFO_STATUS_RX1_ERROR,
  536. /*!
  537. * An Rx error occurred on receive window 2
  538. */
  539. LORAMAC_EVENT_INFO_STATUS_RX2_ERROR,
  540. /*!
  541. * An error occurred in the join procedure
  542. */
  543. LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL,
  544. /*!
  545. * A frame with an invalid downlink counter was received. The
  546. * downlink counter of the frame was equal to the local copy
  547. * of the downlink counter of the node.
  548. */
  549. LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED,
  550. /*!
  551. * The MAC could not retransmit a frame since the MAC decreased the datarate. The
  552. * payload size is not applicable for the datarate.
  553. */
  554. LORAMAC_EVENT_INFO_STATUS_TX_DR_PAYLOAD_SIZE_ERROR,
  555. /*!
  556. * The node has lost MAX_FCNT_GAP or more frames.
  557. */
  558. LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS,
  559. /*!
  560. * An address error occurred
  561. */
  562. LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL,
  563. /*!
  564. * Message integrity check failure
  565. */
  566. LORAMAC_EVENT_INFO_STATUS_MIC_FAIL,
  567. /*!
  568. * ToDo
  569. */
  570. LORAMAC_EVENT_INFO_STATUS_MULTICAST_FAIL,
  571. /*!
  572. * ToDo
  573. */
  574. LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED,
  575. /*!
  576. * ToDo
  577. */
  578. LORAMAC_EVENT_INFO_STATUS_BEACON_LOST,
  579. /*!
  580. * ToDo
  581. */
  582. LORAMAC_EVENT_INFO_STATUS_BEACON_NOT_FOUND,
  583. }LoRaMacEventInfoStatus_t;
  584. /*!
  585. * LoRaMac tx/rx operation state
  586. */
  587. typedef union eLoRaMacFlags_t
  588. {
  589. /*!
  590. * Byte-access to the bits
  591. */
  592. uint8_t Value;
  593. /*!
  594. * Structure containing single access to bits
  595. */
  596. struct sMacFlagBits
  597. {
  598. /*!
  599. * MCPS-Req pending
  600. */
  601. uint8_t McpsReq : 1;
  602. /*!
  603. * MCPS-Ind pending
  604. */
  605. uint8_t McpsInd : 1;
  606. /*!
  607. * MLME-Req pending
  608. */
  609. uint8_t MlmeReq : 1;
  610. /*!
  611. * MLME-Ind pending
  612. */
  613. uint8_t MlmeInd : 1;
  614. /*!
  615. * MLME-Ind to schedule an uplink pending
  616. */
  617. uint8_t MlmeSchedUplinkInd : 1;
  618. /*!
  619. * MAC cycle done
  620. */
  621. uint8_t MacDone : 1;
  622. }Bits;
  623. }LoRaMacFlags_t;
  624. /*!
  625. *
  626. * \brief LoRaMAC data services
  627. *
  628. * \details The following table list the primitives which are supported by the
  629. * specific MAC data service:
  630. *
  631. * Name | Request | Indication | Response | Confirm
  632. * --------------------- | :-----: | :--------: | :------: | :-----:
  633. * \ref MCPS_UNCONFIRMED | YES | YES | NO | YES
  634. * \ref MCPS_CONFIRMED | YES | YES | NO | YES
  635. * \ref MCPS_MULTICAST | NO | YES | NO | NO
  636. * \ref MCPS_PROPRIETARY | YES | YES | NO | YES
  637. *
  638. * The following table provides links to the function implementations of the
  639. * related MCPS primitives:
  640. *
  641. * Primitive | Function
  642. * ---------------- | :---------------------:
  643. * MCPS-Request | \ref LoRaMacMlmeRequest
  644. * MCPS-Confirm | MacMcpsConfirm in \ref LoRaMacPrimitives_t
  645. * MCPS-Indication | MacMcpsIndication in \ref LoRaMacPrimitives_t
  646. */
  647. typedef enum eMcps
  648. {
  649. /*!
  650. * Unconfirmed LoRaMAC frame
  651. */
  652. MCPS_UNCONFIRMED,
  653. /*!
  654. * Confirmed LoRaMAC frame
  655. */
  656. MCPS_CONFIRMED,
  657. /*!
  658. * Multicast LoRaMAC frame
  659. */
  660. MCPS_MULTICAST,
  661. /*!
  662. * Proprietary frame
  663. */
  664. MCPS_PROPRIETARY,
  665. }Mcps_t;
  666. /*!
  667. * LoRaMAC MCPS-Request for an unconfirmed frame
  668. */
  669. typedef struct sMcpsReqUnconfirmed
  670. {
  671. /*!
  672. * Frame port field. Must be set if the payload is not empty. Use the
  673. * application specific frame port values: [1...223]
  674. *
  675. * LoRaWAN Specification V1.0.2, chapter 4.3.2
  676. */
  677. uint8_t fPort;
  678. /*!
  679. * Pointer to the buffer of the frame payload
  680. */
  681. void* fBuffer;
  682. /*!
  683. * Size of the frame payload
  684. */
  685. uint16_t fBufferSize;
  686. /*!
  687. * Uplink datarate, if ADR is off
  688. */
  689. int8_t Datarate;
  690. }McpsReqUnconfirmed_t;
  691. /*!
  692. * LoRaMAC MCPS-Request for a confirmed frame
  693. */
  694. typedef struct sMcpsReqConfirmed
  695. {
  696. /*!
  697. * Frame port field. Must be set if the payload is not empty. Use the
  698. * application specific frame port values: [1...223]
  699. *
  700. * LoRaWAN Specification V1.0.2, chapter 4.3.2
  701. */
  702. uint8_t fPort;
  703. /*!
  704. * Pointer to the buffer of the frame payload
  705. */
  706. void* fBuffer;
  707. /*!
  708. * Size of the frame payload
  709. */
  710. uint16_t fBufferSize;
  711. /*!
  712. * Uplink datarate, if ADR is off
  713. */
  714. int8_t Datarate;
  715. /*!
  716. * Number of trials to transmit the frame, if the LoRaMAC layer did not
  717. * receive an acknowledgment. The MAC performs a datarate adaptation,
  718. * according to the LoRaWAN Specification V1.0.2, chapter 18.4, according
  719. * to the following table:
  720. *
  721. * Transmission nb | Data Rate
  722. * ----------------|-----------
  723. * 1 (first) | DR
  724. * 2 | DR
  725. * 3 | max(DR-1,0)
  726. * 4 | max(DR-1,0)
  727. * 5 | max(DR-2,0)
  728. * 6 | max(DR-2,0)
  729. * 7 | max(DR-3,0)
  730. * 8 | max(DR-3,0)
  731. *
  732. * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease
  733. * the datarate, in case the LoRaMAC layer did not receive an acknowledgment
  734. */
  735. uint8_t NbTrials;
  736. }McpsReqConfirmed_t;
  737. /*!
  738. * LoRaMAC MCPS-Request for a proprietary frame
  739. */
  740. typedef struct sMcpsReqProprietary
  741. {
  742. /*!
  743. * Pointer to the buffer of the frame payload
  744. */
  745. void* fBuffer;
  746. /*!
  747. * Size of the frame payload
  748. */
  749. uint16_t fBufferSize;
  750. /*!
  751. * Uplink datarate, if ADR is off
  752. */
  753. int8_t Datarate;
  754. }McpsReqProprietary_t;
  755. /*!
  756. * LoRaMAC MCPS-Request structure
  757. */
  758. typedef struct sMcpsReq
  759. {
  760. /*!
  761. * MCPS-Request type
  762. */
  763. Mcps_t Type;
  764. /*!
  765. * MCPS-Request parameters
  766. */
  767. union uMcpsParam
  768. {
  769. /*!
  770. * MCPS-Request parameters for an unconfirmed frame
  771. */
  772. McpsReqUnconfirmed_t Unconfirmed;
  773. /*!
  774. * MCPS-Request parameters for a confirmed frame
  775. */
  776. McpsReqConfirmed_t Confirmed;
  777. /*!
  778. * MCPS-Request parameters for a proprietary frame
  779. */
  780. McpsReqProprietary_t Proprietary;
  781. }Req;
  782. }McpsReq_t;
  783. /*!
  784. * LoRaMAC MCPS-Confirm
  785. */
  786. typedef struct sMcpsConfirm
  787. {
  788. /*!
  789. * Holds the previously performed MCPS-Request
  790. */
  791. Mcps_t McpsRequest;
  792. /*!
  793. * Status of the operation
  794. */
  795. LoRaMacEventInfoStatus_t Status;
  796. /*!
  797. * Uplink datarate
  798. */
  799. uint8_t Datarate;
  800. /*!
  801. * Transmission power
  802. */
  803. int8_t TxPower;
  804. /*!
  805. * Set if an acknowledgement was received
  806. */
  807. bool AckReceived;
  808. /*!
  809. * Provides the number of retransmissions
  810. */
  811. uint8_t NbRetries;
  812. /*!
  813. * The transmission time on air of the frame
  814. */
  815. TimerTime_t TxTimeOnAir;
  816. /*!
  817. * The uplink counter value related to the frame
  818. */
  819. uint32_t UpLinkCounter;
  820. /*!
  821. * The uplink channel related to the frame
  822. */
  823. uint32_t Channel;
  824. }McpsConfirm_t;
  825. /*!
  826. * LoRaMAC MCPS-Indication primitive
  827. */
  828. typedef struct sMcpsIndication
  829. {
  830. /*!
  831. * MCPS-Indication type
  832. */
  833. Mcps_t McpsIndication;
  834. /*!
  835. * Status of the operation
  836. */
  837. LoRaMacEventInfoStatus_t Status;
  838. /*!
  839. * Multicast
  840. */
  841. uint8_t Multicast;
  842. /*!
  843. * Application port
  844. */
  845. uint8_t Port;
  846. /*!
  847. * Downlink datarate
  848. */
  849. uint8_t RxDatarate;
  850. /*!
  851. * Frame pending status
  852. */
  853. uint8_t FramePending;
  854. /*!
  855. * Pointer to the received data stream
  856. */
  857. uint8_t* Buffer;
  858. /*!
  859. * Size of the received data stream
  860. */
  861. uint8_t BufferSize;
  862. /*!
  863. * Indicates, if data is available
  864. */
  865. bool RxData;
  866. /*!
  867. * Rssi of the received packet
  868. */
  869. int16_t Rssi;
  870. /*!
  871. * Snr of the received packet
  872. */
  873. int8_t Snr;
  874. /*!
  875. * Receive window
  876. */
  877. LoRaMacRxSlot_t RxSlot;
  878. /*!
  879. * Set if an acknowledgement was received
  880. */
  881. bool AckReceived;
  882. /*!
  883. * The downlink counter value for the received frame
  884. */
  885. uint32_t DownLinkCounter;
  886. /*!
  887. * The device address of the frame
  888. */
  889. uint32_t DevAddress;
  890. /*!
  891. * Set if a DeviceTimeAns MAC command was received.
  892. */
  893. bool DeviceTimeAnsReceived;
  894. }McpsIndication_t;
  895. /*!
  896. * \brief LoRaMAC management services
  897. *
  898. * \details The following table list the primitives which are supported by the
  899. * specific MAC management service:
  900. *
  901. * Name | Request | Indication | Response | Confirm
  902. * ---------------------------- | :-----: | :--------: | :------: | :-----:
  903. * \ref MLME_JOIN | YES | NO | NO | YES
  904. * \ref MLME_LINK_CHECK | YES | NO | NO | YES
  905. * \ref MLME_TXCW | YES | NO | NO | YES
  906. * \ref MLME_SCHEDULE_UPLINK | NO | YES | NO | NO
  907. * \ref MLME_DERIVE_MC_KE_KEY | YES | NO | NO | YES
  908. * \ref MLME_DERIVE_MC_KEY_PAIR | YES | NO | NO | YES
  909. *
  910. * The following table provides links to the function implementations of the
  911. * related MLME primitives.
  912. *
  913. * Primitive | Function
  914. * ---------------- | :---------------------:
  915. * MLME-Request | \ref LoRaMacMlmeRequest
  916. * MLME-Confirm | MacMlmeConfirm in \ref LoRaMacPrimitives_t
  917. * MLME-Indication | MacMlmeIndication in \ref LoRaMacPrimitives_t
  918. */
  919. typedef enum eMlme
  920. {
  921. /*!
  922. * Initiates the Over-the-Air activation
  923. *
  924. * LoRaWAN Specification V1.0.2, chapter 6.2
  925. */
  926. MLME_JOIN,
  927. /*!
  928. * Initiates sending a ReJoin-request type 0
  929. *
  930. * LoRaWAN Specification V1.1.0, chapter 6.2.4.1
  931. */
  932. MLME_REJOIN_0,
  933. /*!
  934. * Initiates sending a ReJoin-request type 1
  935. *
  936. * LoRaWAN Specification V1.1.0, chapter 6.2.4.2
  937. */
  938. MLME_REJOIN_1,
  939. /*!
  940. * LinkCheckReq - Connectivity validation
  941. *
  942. * LoRaWAN Specification V1.0.2, chapter 5, table 4
  943. */
  944. MLME_LINK_CHECK,
  945. /*!
  946. * Sets Tx continuous wave mode
  947. *
  948. * LoRaWAN end-device certification
  949. */
  950. MLME_TXCW,
  951. /*!
  952. * Sets Tx continuous wave mode (new LoRa-Alliance CC definition)
  953. *
  954. * LoRaWAN end-device certification
  955. */
  956. MLME_TXCW_1,
  957. /*!
  958. * Indicates that the application shall perform an uplink as
  959. * soon as possible.
  960. */
  961. MLME_SCHEDULE_UPLINK,
  962. /*!
  963. * Derives the McKEKey from the AppKey or NwkKey.
  964. */
  965. MLME_DERIVE_MC_KE_KEY,
  966. /*!
  967. * Derives a Multicast group key pair ( McAppSKey, McNwkSKey ) from McKey
  968. */
  969. MLME_DERIVE_MC_KEY_PAIR,
  970. /*!
  971. * Initiates a DeviceTimeReq
  972. *
  973. * LoRaWAN end-device certification
  974. */
  975. MLME_DEVICE_TIME,
  976. /*!
  977. * The MAC uses this MLME primitive to indicate a beacon reception
  978. * status.
  979. *
  980. * LoRaWAN end-device certification
  981. */
  982. MLME_BEACON,
  983. /*!
  984. * Initiate a beacon acquisition. The MAC will search for a beacon.
  985. * It will search for XX_BEACON_INTERVAL milliseconds.
  986. *
  987. * LoRaWAN end-device certification
  988. */
  989. MLME_BEACON_ACQUISITION,
  990. /*!
  991. * Initiates a PingSlotInfoReq
  992. *
  993. * LoRaWAN end-device certification
  994. */
  995. MLME_PING_SLOT_INFO,
  996. /*!
  997. * Initiates a BeaconTimingReq
  998. *
  999. * LoRaWAN end-device certification
  1000. */
  1001. MLME_BEACON_TIMING,
  1002. /*!
  1003. * Primitive which indicates that the beacon has been lost
  1004. *
  1005. * \remark The upper layer is required to switch the device class to ClassA
  1006. *
  1007. * LoRaWAN end-device certification
  1008. */
  1009. MLME_BEACON_LOST,
  1010. }Mlme_t;
  1011. /*!
  1012. * LoRaMAC MLME-Request for the join service
  1013. */
  1014. typedef struct sMlmeReqJoin
  1015. {
  1016. /*!
  1017. * Datarate used for join request.
  1018. */
  1019. uint8_t Datarate;
  1020. }MlmeReqJoin_t;
  1021. /*!
  1022. * LoRaMAC MLME-Request for Tx continuous wave mode
  1023. */
  1024. typedef struct sMlmeReqTxCw
  1025. {
  1026. /*!
  1027. * Time in seconds while the radio is kept in continuous wave mode
  1028. */
  1029. uint16_t Timeout;
  1030. /*!
  1031. * RF frequency to set (Only used with new way)
  1032. */
  1033. uint32_t Frequency;
  1034. /*!
  1035. * RF output power to set (Only used with new way)
  1036. */
  1037. uint8_t Power;
  1038. }MlmeReqTxCw_t;
  1039. /*!
  1040. * LoRaMAC MLME-Request for the ping slot info service
  1041. */
  1042. typedef struct sMlmeReqPingSlotInfo
  1043. {
  1044. PingSlotInfo_t PingSlot;
  1045. }MlmeReqPingSlotInfo_t;
  1046. /*!
  1047. * LoRaMAC MLME-Request to derive the McKEKey from the AppKey or NwkKey
  1048. */
  1049. typedef struct sMlmeReqDeriveMcKEKey
  1050. {
  1051. /*!
  1052. * Key identifier of the root key to use to perform the derivation ( NwkKey or AppKey )
  1053. */
  1054. KeyIdentifier_t KeyID;
  1055. /*!
  1056. * Nonce value ( nonce <= 15)
  1057. */
  1058. uint16_t Nonce;
  1059. /*!
  1060. * DevEUI Value
  1061. */
  1062. uint8_t* DevEUI;
  1063. }MlmeReqDeriveMcKEKey_t;
  1064. /*!
  1065. * LoRaMAC MLME-Request to derive a Multicast group key pair ( McAppSKey, McNwkSKey ) from McKey
  1066. */
  1067. typedef struct sMlmeReqDeriveMcSessionKeyPair
  1068. {
  1069. /*!
  1070. * Address identifier to select the multicast group
  1071. */
  1072. AddressIdentifier_t GroupID;
  1073. }MlmeReqDeriveMcSessionKeyPair_t;
  1074. /*!
  1075. * LoRaMAC MLME-Request structure
  1076. */
  1077. typedef struct sMlmeReq
  1078. {
  1079. /*!
  1080. * MLME-Request type
  1081. */
  1082. Mlme_t Type;
  1083. /*!
  1084. * MLME-Request parameters
  1085. */
  1086. union uMlmeParam
  1087. {
  1088. /*!
  1089. * MLME-Request parameters for a join request
  1090. */
  1091. MlmeReqJoin_t Join;
  1092. /*!
  1093. * MLME-Request parameters for Tx continuous mode request
  1094. */
  1095. MlmeReqTxCw_t TxCw;
  1096. /*!
  1097. * MLME-Request parameters for a ping slot info request
  1098. */
  1099. MlmeReqPingSlotInfo_t PingSlotInfo;
  1100. /*!
  1101. * MLME-Request to derive the McKEKey from the AppKey or NwkKey
  1102. */
  1103. MlmeReqDeriveMcKEKey_t DeriveMcKEKey;
  1104. /*!
  1105. * MLME-Request to derive a Multicast group key pair ( McAppSKey, McNwkSKey ) from McKey
  1106. */
  1107. MlmeReqDeriveMcSessionKeyPair_t DeriveMcSessionKeyPair;
  1108. }Req;
  1109. }MlmeReq_t;
  1110. /*!
  1111. * LoRaMAC MLME-Confirm primitive
  1112. */
  1113. typedef struct sMlmeConfirm
  1114. {
  1115. /*!
  1116. * Holds the previously performed MLME-Request
  1117. */
  1118. Mlme_t MlmeRequest;
  1119. /*!
  1120. * Status of the operation
  1121. */
  1122. LoRaMacEventInfoStatus_t Status;
  1123. /*!
  1124. * The transmission time on air of the frame
  1125. */
  1126. TimerTime_t TxTimeOnAir;
  1127. /*!
  1128. * Demodulation margin. Contains the link margin [dB] of the last
  1129. * successfully received LinkCheckReq
  1130. */
  1131. uint8_t DemodMargin;
  1132. /*!
  1133. * Number of gateways which received the last LinkCheckReq
  1134. */
  1135. uint8_t NbGateways;
  1136. /*!
  1137. * Provides the number of retransmissions
  1138. */
  1139. uint8_t NbRetries;
  1140. /*!
  1141. * The delay which we have received through the
  1142. * BeaconTimingAns
  1143. */
  1144. TimerTime_t BeaconTimingDelay;
  1145. /*!
  1146. * The channel of the next beacon
  1147. */
  1148. uint8_t BeaconTimingChannel;
  1149. }MlmeConfirm_t;
  1150. /*!
  1151. * LoRaMAC MLME-Indication primitive
  1152. */
  1153. typedef struct sMlmeIndication
  1154. {
  1155. /*!
  1156. * MLME-Indication type
  1157. */
  1158. Mlme_t MlmeIndication;
  1159. /*!
  1160. * Status of the operation
  1161. */
  1162. LoRaMacEventInfoStatus_t Status;
  1163. /*!
  1164. * Beacon information. Only valid for \ref MLME_BEACON,
  1165. * status \ref LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED
  1166. */
  1167. BeaconInfo_t BeaconInfo;
  1168. }MlmeIndication_t;
  1169. /*!
  1170. * LoRa Mac Information Base (MIB)
  1171. *
  1172. * The following table lists the MIB parameters and the related attributes:
  1173. *
  1174. * Attribute | Get | Set
  1175. * ----------------------------------------------| :-: | :-:
  1176. * \ref MIB_DEVICE_CLASS | YES | YES
  1177. * \ref MIB_NETWORK_ACTIVATION | YES | YES
  1178. * \ref MIB_DEV_EUI | YES | YES
  1179. * \ref MIB_JOIN_EUI | YES | YES
  1180. * \ref MIB_ADR | YES | YES
  1181. * \ref MIB_NET_ID | YES | YES
  1182. * \ref MIB_DEV_ADDR | YES | YES
  1183. * \ref MIB_GEN_APP_KEY | NO | YES
  1184. * \ref MIB_APP_KEY | NO | YES
  1185. * \ref MIB_NWK_KEY | NO | YES
  1186. * \ref MIB_J_S_INT_KEY | NO | YES
  1187. * \ref MIB_J_S_ENC_KEY | NO | YES
  1188. * \ref MIB_F_NWK_S_INT_KEY | NO | YES
  1189. * \ref MIB_S_NWK_S_INT_KEY | NO | YES
  1190. * \ref MIB_NWK_S_ENC_KEY | NO | YES
  1191. * \ref MIB_APP_S_KEY | NO | YES
  1192. * \ref MIB_MC_KE_KEY | NO | YES
  1193. * \ref MIB_MC_KEY_0 | NO | YES
  1194. * \ref MIB_MC_APP_S_KEY_0 | NO | YES
  1195. * \ref MIB_MC_NWK_S_KEY_0 | NO | YES
  1196. * \ref MIB_MC_KEY_1 | NO | YES
  1197. * \ref MIB_MC_APP_S_KEY_1 | NO | YES
  1198. * \ref MIB_MC_NWK_S_KEY_1 | NO | YES
  1199. * \ref MIB_MC_KEY_2 | NO | YES
  1200. * \ref MIB_MC_APP_S_KEY_2 | NO | YES
  1201. * \ref MIB_MC_NWK_S_KEY_2 | NO | YES
  1202. * \ref MIB_MC_KEY_3 | NO | YES
  1203. * \ref MIB_MC_APP_S_KEY_3 | NO | YES
  1204. * \ref MIB_MC_NWK_S_KEY_3 | NO | YES
  1205. * \ref MIB_PUBLIC_NETWORK | YES | YES
  1206. * \ref MIB_REPEATER_SUPPORT | YES | YES
  1207. * \ref MIB_CHANNELS | YES | NO
  1208. * \ref MIB_RX2_CHANNEL | YES | YES
  1209. * \ref MIB_RX2_DFAULT_CHANNEL | YES | YES
  1210. * \ref MIB_RXC_CHANNEL | YES | YES
  1211. * \ref MIB_RXC_DFAULT_CHANNEL | YES | YES
  1212. * \ref MIB_CHANNELS_MASK | YES | YES
  1213. * \ref MIB_CHANNELS_DEFAULT_MASK | YES | YES
  1214. * \ref MIB_CHANNELS_NB_TRANS | YES | YES
  1215. * \ref MIB_MAX_RX_WINDOW_DURATION | YES | YES
  1216. * \ref MIB_RECEIVE_DELAY_1 | YES | YES
  1217. * \ref MIB_RECEIVE_DELAY_2 | YES | YES
  1218. * \ref MIB_JOIN_ACCEPT_DELAY_1 | YES | YES
  1219. * \ref MIB_JOIN_ACCEPT_DELAY_2 | YES | YES
  1220. * \ref MIB_CHANNELS_DATARATE | YES | YES
  1221. * \ref MIB_CHANNELS_DEFAULT_DATARATE | YES | YES
  1222. * \ref MIB_CHANNELS_TX_POWER | YES | YES
  1223. * \ref MIB_CHANNELS_DEFAULT_TX_POWER | YES | YES
  1224. * \ref MIB_SYSTEM_MAX_RX_ERROR | YES | YES
  1225. * \ref MIB_MIN_RX_SYMBOLS | YES | YES
  1226. * \ref MIB_BEACON_INTERVAL | YES | YES
  1227. * \ref MIB_BEACON_RESERVED | YES | YES
  1228. * \ref MIB_BEACON_GUARD | YES | YES
  1229. * \ref MIB_BEACON_WINDOW | YES | YES
  1230. * \ref MIB_BEACON_WINDOW_SLOTS | YES | YES
  1231. * \ref MIB_PING_SLOT_WINDOW | YES | YES
  1232. * \ref MIB_BEACON_SYMBOL_TO_DEFAULT | YES | YES
  1233. * \ref MIB_BEACON_SYMBOL_TO_EXPANSION_MAX | YES | YES
  1234. * \ref MIB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX | YES | YES
  1235. * \ref MIB_BEACON_SYMBOL_TO_EXPANSION_FACTOR | YES | YES
  1236. * \ref MIB_PING_SLOT_SYMBOL_TO_EXPANSION_FACTOR | YES | YES
  1237. * \ref MIB_MAX_BEACON_LESS_PERIOD | YES | YES
  1238. * \ref MIB_ANTENNA_GAIN | YES | YES
  1239. * \ref MIB_DEFAULT_ANTENNA_GAIN | YES | YES
  1240. * \ref MIB_NVM_CTXS | YES | YES
  1241. * \ref MIB_ABP_LORAWAN_VERSION | YES | YES
  1242. *
  1243. * The following table provides links to the function implementations of the
  1244. * related MIB primitives:
  1245. *
  1246. * Primitive | Function
  1247. * ---------------- | :---------------------:
  1248. * MIB-Set | \ref LoRaMacMibSetRequestConfirm
  1249. * MIB-Get | \ref LoRaMacMibGetRequestConfirm
  1250. */
  1251. typedef enum eMib
  1252. {
  1253. /*!
  1254. * LoRaWAN device class
  1255. *
  1256. * LoRaWAN Specification V1.0.2
  1257. */
  1258. MIB_DEVICE_CLASS,
  1259. /*!
  1260. * LoRaWAN Network End-Device Activation
  1261. *
  1262. * LoRaWAN Specification V1.0.2
  1263. */
  1264. MIB_NETWORK_ACTIVATION,
  1265. /*!
  1266. * LoRaWAN device EUI
  1267. *
  1268. * LoRaWAN Specification V1.0.2
  1269. */
  1270. MIB_DEV_EUI,
  1271. /*!
  1272. * LoRaWAN join EUI
  1273. *
  1274. * LoRaWAN Specification V1.0.2
  1275. */
  1276. MIB_JOIN_EUI,
  1277. /*!
  1278. * Adaptive data rate
  1279. *
  1280. * LoRaWAN Specification V1.0.2, chapter 4.3.1.1
  1281. *
  1282. * [true: ADR enabled, false: ADR disabled]
  1283. */
  1284. MIB_ADR,
  1285. /*!
  1286. * Network identifier
  1287. *
  1288. * LoRaWAN Specification V1.0.2, chapter 6.1.1
  1289. */
  1290. MIB_NET_ID,
  1291. /*!
  1292. * End-device address
  1293. *
  1294. * LoRaWAN Specification V1.0.2, chapter 6.1.1
  1295. */
  1296. MIB_DEV_ADDR,
  1297. /*!
  1298. * Application root key - 1.0.x devices only.
  1299. *
  1300. * LoRaWAN Remote Multicast Setup v1.0.0 Specification, chapter 4.3
  1301. */
  1302. MIB_GEN_APP_KEY,
  1303. /*!
  1304. * Application root key
  1305. *
  1306. * LoRaWAN Specification V1.1.0, chapter 6.1.1.3
  1307. */
  1308. MIB_APP_KEY,
  1309. /*!
  1310. * Network root key
  1311. *
  1312. * LoRaWAN Specification V1.1.0, chapter 6.1.1.3
  1313. */
  1314. MIB_NWK_KEY,
  1315. /*!
  1316. * Join session integrity key
  1317. *
  1318. * LoRaWAN Specification V1.1.0, chapter 6.1.1.4
  1319. */
  1320. MIB_J_S_INT_KEY,
  1321. /*!
  1322. * Join session encryption key
  1323. *
  1324. * LoRaWAN Specification V1.1.0, chapter 6.1.1.4
  1325. */
  1326. MIB_J_S_ENC_KEY,
  1327. /*!
  1328. * Forwarding Network session integrity key
  1329. *
  1330. * LoRaWAN Specification V1.1.0, chapter 6.1.2.2
  1331. */
  1332. MIB_F_NWK_S_INT_KEY,
  1333. /*!
  1334. * Serving Network session integrity key
  1335. *
  1336. * LoRaWAN Specification V1.1.0, chapter 6.1.2.3
  1337. */
  1338. MIB_S_NWK_S_INT_KEY,
  1339. /*!
  1340. * Network session encryption key
  1341. *
  1342. * LoRaWAN Specification V1.1.0, chapter 6.1.2.4
  1343. */
  1344. MIB_NWK_S_ENC_KEY,
  1345. /*!
  1346. * Application session key
  1347. *
  1348. * LoRaWAN Specification V1.1.0, chapter 6.1.1.3
  1349. */
  1350. MIB_APP_S_KEY,
  1351. /*!
  1352. * Multicast key encryption key
  1353. *
  1354. * LoRaWAN - Secure element specification v1
  1355. */
  1356. MIB_MC_KE_KEY,
  1357. /*!
  1358. * Multicast root key index 0
  1359. *
  1360. * LoRaWAN - Secure element specification v1
  1361. */
  1362. MIB_MC_KEY_0,
  1363. /*!
  1364. * Multicast Application session key index 0
  1365. *
  1366. * LoRaWAN - Secure element specification v1
  1367. */
  1368. MIB_MC_APP_S_KEY_0,
  1369. /*!
  1370. * Multicast Network session key index 0
  1371. *
  1372. * LoRaWAN - Secure element specification v1
  1373. */
  1374. MIB_MC_NWK_S_KEY_0,
  1375. /*!
  1376. * Multicast root key index 1
  1377. *
  1378. * LoRaWAN - Secure element specification v1
  1379. */
  1380. MIB_MC_KEY_1,
  1381. /*!
  1382. * Multicast Application session key index 1
  1383. *
  1384. * LoRaWAN - Secure element specification v1
  1385. */
  1386. MIB_MC_APP_S_KEY_1,
  1387. /*!
  1388. * Multicast Network session key index 1
  1389. *
  1390. * LoRaWAN - Secure element specification v1
  1391. */
  1392. MIB_MC_NWK_S_KEY_1,
  1393. /*!
  1394. * Multicast root key index 2
  1395. *
  1396. * LoRaWAN - Secure element specification v1
  1397. */
  1398. MIB_MC_KEY_2,
  1399. /*!
  1400. * Multicast Application session key index 2
  1401. *
  1402. * LoRaWAN - Secure element specification v1
  1403. */
  1404. MIB_MC_APP_S_KEY_2,
  1405. /*!
  1406. * Multicast Network session key index 2
  1407. *
  1408. * LoRaWAN - Secure element specification v1
  1409. */
  1410. MIB_MC_NWK_S_KEY_2,
  1411. /*!
  1412. * Multicast root key index 3
  1413. *
  1414. * LoRaWAN - Secure element specification v1
  1415. */
  1416. MIB_MC_KEY_3,
  1417. /*!
  1418. * Multicast Application session key index 3
  1419. *
  1420. * LoRaWAN - Secure element specification v1
  1421. */
  1422. MIB_MC_APP_S_KEY_3,
  1423. /*!
  1424. * Multicast Network session key index 3
  1425. *
  1426. * LoRaWAN - Secure element specification v1
  1427. */
  1428. MIB_MC_NWK_S_KEY_3,
  1429. /*!
  1430. * Set the network type to public or private
  1431. *
  1432. * LoRaWAN Regional Parameters V1.0.2rB
  1433. *
  1434. * [true: public network, false: private network]
  1435. */
  1436. MIB_PUBLIC_NETWORK,
  1437. /*!
  1438. * Support the operation with repeaters
  1439. *
  1440. * LoRaWAN Regional Parameters V1.0.2rB
  1441. *
  1442. * [true: repeater support enabled, false: repeater support disabled]
  1443. */
  1444. MIB_REPEATER_SUPPORT,
  1445. /*!
  1446. * Communication channels. A get request will return a
  1447. * pointer which references the first entry of the channel list. The
  1448. * list is of size LORA_MAX_NB_CHANNELS
  1449. *
  1450. * LoRaWAN Regional Parameters V1.0.2rB
  1451. */
  1452. MIB_CHANNELS,
  1453. /*!
  1454. * Set receive window 2 channel
  1455. *
  1456. * LoRaWAN Specification V1.0.2, chapter 3.3.1
  1457. */
  1458. MIB_RX2_CHANNEL,
  1459. /*!
  1460. * Set receive window 2 channel
  1461. *
  1462. * LoRaWAN Specification V1.0.2, chapter 3.3.2
  1463. */
  1464. MIB_RX2_DEFAULT_CHANNEL,
  1465. /*!
  1466. * Set receive window C channel
  1467. *
  1468. * LoRaWAN Specification V1.0.2, chapter 3.3.1
  1469. */
  1470. MIB_RXC_CHANNEL,
  1471. /*!
  1472. * Set receive window C channel
  1473. *
  1474. * LoRaWAN Specification V1.0.2, chapter 3.3.2
  1475. */
  1476. MIB_RXC_DEFAULT_CHANNEL,
  1477. /*!
  1478. * LoRaWAN channels mask
  1479. *
  1480. * LoRaWAN Regional Parameters V1.0.2rB
  1481. */
  1482. MIB_CHANNELS_MASK,
  1483. /*!
  1484. * LoRaWAN default channels mask
  1485. *
  1486. * LoRaWAN Regional Parameters V1.0.2rB
  1487. */
  1488. MIB_CHANNELS_DEFAULT_MASK,
  1489. /*!
  1490. * Set the number of repetitions on a channel
  1491. *
  1492. * LoRaWAN Specification V1.0.2, chapter 5.2
  1493. */
  1494. MIB_CHANNELS_NB_TRANS,
  1495. /*!
  1496. * Maximum receive window duration in [ms]
  1497. *
  1498. * LoRaWAN Specification V1.0.2, chapter 3.3.3
  1499. */
  1500. MIB_MAX_RX_WINDOW_DURATION,
  1501. /*!
  1502. * Receive delay 1 in [ms]
  1503. *
  1504. * LoRaWAN Regional Parameters V1.0.2rB
  1505. */
  1506. MIB_RECEIVE_DELAY_1,
  1507. /*!
  1508. * Receive delay 2 in [ms]
  1509. *
  1510. * LoRaWAN Regional Parameters V1.0.2rB
  1511. */
  1512. MIB_RECEIVE_DELAY_2,
  1513. /*!
  1514. * Join accept delay 1 in [ms]
  1515. *
  1516. * LoRaWAN Regional Parameters V1.0.2rB
  1517. */
  1518. MIB_JOIN_ACCEPT_DELAY_1,
  1519. /*!
  1520. * Join accept delay 2 in [ms]
  1521. *
  1522. * LoRaWAN Regional Parameters V1.0.2rB
  1523. */
  1524. MIB_JOIN_ACCEPT_DELAY_2,
  1525. /*!
  1526. * Default Data rate of a channel
  1527. *
  1528. * LoRaWAN Regional Parameters V1.0.2rB
  1529. *
  1530. * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details.
  1531. */
  1532. MIB_CHANNELS_DEFAULT_DATARATE,
  1533. /*!
  1534. * Data rate of a channel
  1535. *
  1536. * LoRaWAN Regional Parameters V1.0.2rB
  1537. *
  1538. * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details.
  1539. */
  1540. MIB_CHANNELS_DATARATE,
  1541. /*!
  1542. * Transmission power of a channel
  1543. *
  1544. * LoRaWAN Regional Parameters V1.0.2rB
  1545. *
  1546. * The allowed ranges are region specific. Please refer to \ref TX_POWER_0 to \ref TX_POWER_15 for details.
  1547. */
  1548. MIB_CHANNELS_TX_POWER,
  1549. /*!
  1550. * Transmission power of a channel
  1551. *
  1552. * LoRaWAN Regional Parameters V1.0.2rB
  1553. *
  1554. * The allowed ranges are region specific. Please refer to \ref TX_POWER_0 to \ref TX_POWER_15 for details.
  1555. */
  1556. MIB_CHANNELS_DEFAULT_TX_POWER,
  1557. /*!
  1558. * System overall timing error in milliseconds.
  1559. * [-SystemMaxRxError : +SystemMaxRxError]
  1560. * Default: +/-10 ms
  1561. */
  1562. MIB_SYSTEM_MAX_RX_ERROR,
  1563. /*!
  1564. * Minimum required number of symbols to detect an Rx frame
  1565. * Default: 6 symbols
  1566. */
  1567. MIB_MIN_RX_SYMBOLS,
  1568. /*!
  1569. * Antenna gain of the node. Default value is region specific.
  1570. * The antenna gain is used to calculate the TX power of the node.
  1571. * The formula is:
  1572. * radioTxPower = ( int8_t )floor( maxEirp - antennaGain )
  1573. *
  1574. * \remark The antenna gain value is referenced to the isotropic antenna.
  1575. * The value is in dBi.
  1576. * MIB_ANTENNA_GAIN[dBi] = measuredAntennaGain[dBd] + 2.15
  1577. */
  1578. MIB_ANTENNA_GAIN,
  1579. /*!
  1580. * Default antenna gain of the node. Default value is region specific.
  1581. * The antenna gain is used to calculate the TX power of the node.
  1582. * The formula is:
  1583. * radioTxPower = ( int8_t )floor( maxEirp - antennaGain )
  1584. *
  1585. * \remark The antenna gain value is referenced to the isotropic antenna.
  1586. * The value is in dBi.
  1587. * MIB_DEFAULT_ANTENNA_GAIN[dBi] = measuredAntennaGain[dBd] + 2.15
  1588. */
  1589. MIB_DEFAULT_ANTENNA_GAIN,
  1590. /*!
  1591. * Structure holding pointers to internal contexts and its size
  1592. */
  1593. MIB_NVM_CTXS,
  1594. /*!
  1595. * LoRaWAN MAC layer operating version when activated by ABP.
  1596. */
  1597. MIB_ABP_LORAWAN_VERSION,
  1598. /*!
  1599. * Beacon interval in ms
  1600. */
  1601. MIB_BEACON_INTERVAL,
  1602. /*!
  1603. * Beacon reserved time in ms
  1604. */
  1605. MIB_BEACON_RESERVED,
  1606. /*!
  1607. * Beacon guard time in ms
  1608. */
  1609. MIB_BEACON_GUARD,
  1610. /*!
  1611. * Beacon window time in ms
  1612. */
  1613. MIB_BEACON_WINDOW,
  1614. /*!
  1615. * Beacon window time in number of slots
  1616. */
  1617. MIB_BEACON_WINDOW_SLOTS,
  1618. /*!
  1619. * Ping slot length time in ms
  1620. */
  1621. MIB_PING_SLOT_WINDOW,
  1622. /*!
  1623. * Default symbol timeout for beacons and ping slot windows
  1624. */
  1625. MIB_BEACON_SYMBOL_TO_DEFAULT,
  1626. /*!
  1627. * Maximum symbol timeout for beacons
  1628. */
  1629. MIB_BEACON_SYMBOL_TO_EXPANSION_MAX,
  1630. /*!
  1631. * Maximum symbol timeout for ping slots
  1632. */
  1633. MIB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX,
  1634. /*!
  1635. * Symbol expansion value for beacon windows in case of beacon
  1636. * loss in symbols
  1637. */
  1638. MIB_BEACON_SYMBOL_TO_EXPANSION_FACTOR,
  1639. /*!
  1640. * Symbol expansion value for ping slot windows in case of beacon
  1641. * loss in symbols
  1642. */
  1643. MIB_PING_SLOT_SYMBOL_TO_EXPANSION_FACTOR,
  1644. /*!
  1645. * Maximum allowed beacon less time in ms
  1646. */
  1647. MIB_MAX_BEACON_LESS_PERIOD,
  1648. /*!
  1649. * Ping slot data rate
  1650. *
  1651. * LoRaWAN Regional Parameters V1.0.2rB
  1652. *
  1653. * The allowed ranges are region specific. Please refer to \ref DR_0 to \ref DR_15 for details.
  1654. */
  1655. MIB_PING_SLOT_DATARATE,
  1656. }Mib_t;
  1657. /*!
  1658. * LoRaMAC MIB parameters
  1659. */
  1660. typedef union uMibParam
  1661. {
  1662. /*!
  1663. * LoRaWAN device class
  1664. *
  1665. * Related MIB type: \ref MIB_DEVICE_CLASS
  1666. */
  1667. DeviceClass_t Class;
  1668. /*!
  1669. * LoRaWAN Network End-Device Activation ( ACTIVATION_TYPE_NONE, ACTIVATION_TYPE_ABP or OTTA )
  1670. *
  1671. * Related MIB type: \ref MIB_NETWORK_ACTIVATION
  1672. */
  1673. ActivationType_t NetworkActivation;
  1674. /*!
  1675. * LoRaWAN device class
  1676. *
  1677. * Related MIB type: \ref MIB_DEV_EUI
  1678. */
  1679. uint8_t* DevEui;
  1680. /*!
  1681. * LoRaWAN device class
  1682. *
  1683. * Related MIB type: \ref MIB_JOIN_EUI
  1684. */
  1685. uint8_t* JoinEui;
  1686. /*!
  1687. * Activation state of ADR
  1688. *
  1689. * Related MIB type: \ref MIB_ADR
  1690. */
  1691. bool AdrEnable;
  1692. /*!
  1693. * Network identifier
  1694. *
  1695. * Related MIB type: \ref MIB_NET_ID
  1696. */
  1697. uint32_t NetID;
  1698. /*!
  1699. * End-device address
  1700. *
  1701. * Related MIB type: \ref MIB_DEV_ADDR
  1702. */
  1703. uint32_t DevAddr;
  1704. /*!
  1705. * Application root key - 1.0.x device only
  1706. *
  1707. * Related MIB type: \ref MIB_GEN_APP_KEY
  1708. */
  1709. uint8_t* GenAppKey;
  1710. /*!
  1711. * Application root key
  1712. *
  1713. * Related MIB type: \ref MIB_APP_KEY
  1714. */
  1715. uint8_t* AppKey;
  1716. /*!
  1717. * Network root key
  1718. *
  1719. * Related MIB type: \ref MIB_NWK_KEY
  1720. */
  1721. uint8_t* NwkKey;
  1722. /*!
  1723. * Join session integrity key
  1724. *
  1725. * Related MIB type: \ref MIB_J_S_INT_KEY
  1726. */
  1727. uint8_t* JSIntKey;
  1728. /*!
  1729. * Join session encryption key
  1730. *
  1731. * Related MIB type: \ref MIB_J_S_ENC_KEY
  1732. */
  1733. uint8_t* JSEncKey;
  1734. /*!
  1735. * Forwarding Network session integrity key
  1736. *
  1737. * Related MIB type: \ref MIB_F_NWK_S_INT_KEY
  1738. */
  1739. uint8_t* FNwkSIntKey;
  1740. /*!
  1741. * Serving Network session integrity key
  1742. *
  1743. * Related MIB type: \ref MIB_S_NWK_S_INT_KEY
  1744. */
  1745. uint8_t* SNwkSIntKey;
  1746. /*!
  1747. * Network session encryption key
  1748. *
  1749. * Related MIB type: \ref MIB_NWK_S_ENC_KEY
  1750. */
  1751. uint8_t* NwkSEncKey;
  1752. /*!
  1753. * Application session key
  1754. *
  1755. * Related MIB type: \ref MIB_APP_S_KEY
  1756. */
  1757. uint8_t* AppSKey;
  1758. /*!
  1759. * Multicast key encryption key
  1760. *
  1761. * Related MIB type: \ref MIB_MC_KE_KEY
  1762. */
  1763. uint8_t* McKEKey;
  1764. /*!
  1765. * Multicast root key index 0
  1766. *
  1767. * Related MIB type: \ref MIB_MC_KEY_0
  1768. */
  1769. uint8_t* McKey0;
  1770. /*!
  1771. * Multicast Application session key index 0
  1772. *
  1773. * Related MIB type: \ref MIB_MC_APP_S_KEY_0
  1774. */
  1775. uint8_t* McAppSKey0;
  1776. /*!
  1777. * Multicast Network session key index 0
  1778. *
  1779. * Related MIB type: \ref MIB_MC_NWK_S_KEY_0
  1780. */
  1781. uint8_t* McNwkSKey0;
  1782. /*!
  1783. * Multicast root key index 0
  1784. *
  1785. * Related MIB type: \ref MIB_MC_KEY_0
  1786. */
  1787. uint8_t* McKey1;
  1788. /*!
  1789. * Multicast Application session key index 1
  1790. *
  1791. * Related MIB type: \ref MIB_MC_APP_S_KEY_1
  1792. */
  1793. uint8_t* McAppSKey1;
  1794. /*!
  1795. * Multicast Network session key index 1
  1796. *
  1797. * Related MIB type: \ref MIB_MC_NWK_S_KEY_1
  1798. */
  1799. uint8_t* McNwkSKey1;
  1800. /*!
  1801. * Multicast root key index 2
  1802. *
  1803. * Related MIB type: \ref MIB_MC_KEY_2
  1804. */
  1805. uint8_t* McKey2;
  1806. /*!
  1807. * Multicast Application session key index 2
  1808. *
  1809. * Related MIB type: \ref MIB_MC_APP_S_KEY_2
  1810. */
  1811. uint8_t* McAppSKey2;
  1812. /*!
  1813. * Multicast Network session key index 2
  1814. *
  1815. * Related MIB type: \ref MIB_MC_NWK_S_KEY_2
  1816. */
  1817. uint8_t* McNwkSKey2;
  1818. /*!
  1819. * Multicast root key index 2
  1820. *
  1821. * Related MIB type: \ref MIB_MC_KEY_2
  1822. */
  1823. uint8_t* McKey3;
  1824. /*!
  1825. * Multicast Application session key index 2
  1826. *
  1827. * Related MIB type: \ref MIB_MC_APP_S_KEY_2
  1828. */
  1829. uint8_t* McAppSKey3;
  1830. /*!
  1831. * Multicast Network session key index 2
  1832. *
  1833. * Related MIB type: \ref MIB_MC_NWK_S_KEY_2
  1834. */
  1835. uint8_t* McNwkSKey3;
  1836. /*!
  1837. * Enable or disable a public network
  1838. *
  1839. * Related MIB type: \ref MIB_PUBLIC_NETWORK
  1840. */
  1841. bool EnablePublicNetwork;
  1842. /*!
  1843. * Enable or disable repeater support
  1844. *
  1845. * Related MIB type: \ref MIB_REPEATER_SUPPORT
  1846. */
  1847. bool EnableRepeaterSupport;
  1848. /*!
  1849. * LoRaWAN Channel
  1850. *
  1851. * Related MIB type: \ref MIB_CHANNELS
  1852. */
  1853. ChannelParams_t* ChannelList;
  1854. /*!
  1855. * Channel for the receive window 2
  1856. *
  1857. * Related MIB type: \ref MIB_RX2_CHANNEL
  1858. */
  1859. RxChannelParams_t Rx2Channel;
  1860. /*!
  1861. * Channel for the receive window 2
  1862. *
  1863. * Related MIB type: \ref MIB_RX2_DEFAULT_CHANNEL
  1864. */
  1865. RxChannelParams_t Rx2DefaultChannel;
  1866. /*!
  1867. * Channel for the receive window C
  1868. *
  1869. * Related MIB type: \ref MIB_RXC_CHANNEL
  1870. */
  1871. RxChannelParams_t RxCChannel;
  1872. /*!
  1873. * Channel for the receive window C
  1874. *
  1875. * Related MIB type: \ref MIB_RXC_DEFAULT_CHANNEL
  1876. */
  1877. RxChannelParams_t RxCDefaultChannel;
  1878. /*!
  1879. * Channel mask
  1880. *
  1881. * Related MIB type: \ref MIB_CHANNELS_MASK
  1882. */
  1883. uint16_t* ChannelsMask;
  1884. /*!
  1885. * Default channel mask
  1886. *
  1887. * Related MIB type: \ref MIB_CHANNELS_DEFAULT_MASK
  1888. */
  1889. uint16_t* ChannelsDefaultMask;
  1890. /*!
  1891. * Number of frame repetitions
  1892. *
  1893. * Related MIB type: \ref MIB_CHANNELS_NB_TRANS
  1894. */
  1895. uint8_t ChannelsNbTrans;
  1896. /*!
  1897. * Maximum receive window duration
  1898. *
  1899. * Related MIB type: \ref MIB_MAX_RX_WINDOW_DURATION
  1900. */
  1901. uint32_t MaxRxWindow;
  1902. /*!
  1903. * Receive delay 1
  1904. *
  1905. * Related MIB type: \ref MIB_RECEIVE_DELAY_1
  1906. */
  1907. uint32_t ReceiveDelay1;
  1908. /*!
  1909. * Receive delay 2
  1910. *
  1911. * Related MIB type: \ref MIB_RECEIVE_DELAY_2
  1912. */
  1913. uint32_t ReceiveDelay2;
  1914. /*!
  1915. * Join accept delay 1
  1916. *
  1917. * Related MIB type: \ref MIB_JOIN_ACCEPT_DELAY_1
  1918. */
  1919. uint32_t JoinAcceptDelay1;
  1920. /*!
  1921. * Join accept delay 2
  1922. *
  1923. * Related MIB type: \ref MIB_JOIN_ACCEPT_DELAY_2
  1924. */
  1925. uint32_t JoinAcceptDelay2;
  1926. /*!
  1927. * Channels data rate
  1928. *
  1929. * Related MIB type: \ref MIB_CHANNELS_DEFAULT_DATARATE
  1930. */
  1931. int8_t ChannelsDefaultDatarate;
  1932. /*!
  1933. * Channels data rate
  1934. *
  1935. * Related MIB type: \ref MIB_CHANNELS_DATARATE
  1936. */
  1937. int8_t ChannelsDatarate;
  1938. /*!
  1939. * Channels TX power
  1940. *
  1941. * Related MIB type: \ref MIB_CHANNELS_DEFAULT_TX_POWER
  1942. */
  1943. int8_t ChannelsDefaultTxPower;
  1944. /*!
  1945. * Channels TX power
  1946. *
  1947. * Related MIB type: \ref MIB_CHANNELS_TX_POWER
  1948. */
  1949. int8_t ChannelsTxPower;
  1950. /*!
  1951. * Multicast channels
  1952. *
  1953. * Related MIB type: \ref MIB_MULTICAST_CHANNEL
  1954. */
  1955. McChannelParams_t MulticastChannel;
  1956. /*!
  1957. * System overall timing error in milliseconds.
  1958. *
  1959. * Related MIB type: \ref MIB_SYSTEM_MAX_RX_ERROR
  1960. */
  1961. uint32_t SystemMaxRxError;
  1962. /*!
  1963. * Minimum required number of symbols to detect an Rx frame
  1964. *
  1965. * Related MIB type: \ref MIB_MIN_RX_SYMBOLS
  1966. */
  1967. uint8_t MinRxSymbols;
  1968. /*!
  1969. * Antenna gain
  1970. *
  1971. * Related MIB type: \ref MIB_ANTENNA_GAIN
  1972. */
  1973. float AntennaGain;
  1974. /*!
  1975. * Default antenna gain
  1976. *
  1977. * Related MIB type: \ref MIB_DEFAULT_ANTENNA_GAIN
  1978. */
  1979. float DefaultAntennaGain;
  1980. /*!
  1981. * Structure holding pointers to internal non-volatile contexts and its lengths.
  1982. *
  1983. * Related MIB type: \ref MIB_NVM_CTXS
  1984. */
  1985. LoRaMacCtxs_t* Contexts;
  1986. /*
  1987. * LoRaWAN MAC layer operating version when activated by ABP.
  1988. *
  1989. * Related MIB type: \ref MIB_ABP_LORAWAN_VERSION
  1990. */
  1991. Version_t AbpLrWanVersion;
  1992. /*!
  1993. * Beacon interval in ms
  1994. *
  1995. * Related MIB type: \ref MIB_BEACON_INTERVAL
  1996. */
  1997. uint32_t BeaconInterval;
  1998. /*!
  1999. * Beacon reserved time in ms
  2000. *
  2001. * Related MIB type: \ref MIB_BEACON_RESERVED
  2002. */
  2003. uint32_t BeaconReserved;
  2004. /*!
  2005. * Beacon guard time in ms
  2006. *
  2007. * Related MIB type: \ref MIB_BEACON_GUARD
  2008. */
  2009. uint32_t BeaconGuard;
  2010. /*!
  2011. * Beacon window time in ms
  2012. *
  2013. * Related MIB type: \ref MIB_BEACON_WINDOW
  2014. */
  2015. uint32_t BeaconWindow;
  2016. /*!
  2017. * Beacon window time in number of slots
  2018. *
  2019. * Related MIB type: \ref MIB_BEACON_WINDOW_SLOTS
  2020. */
  2021. uint32_t BeaconWindowSlots;
  2022. /*!
  2023. * Ping slot length time in ms
  2024. *
  2025. * Related MIB type: \ref MIB_PING_SLOT_WINDOW
  2026. */
  2027. uint32_t PingSlotWindow;
  2028. /*!
  2029. * Default symbol timeout for beacons and ping slot windows
  2030. *
  2031. * Related MIB type: \ref MIB_BEACON_SYMBOL_TO_DEFAULT
  2032. */
  2033. uint32_t BeaconSymbolToDefault;
  2034. /*!
  2035. * Maximum symbol timeout for beacons
  2036. *
  2037. * Related MIB type: \ref MIB_BEACON_SYMBOL_TO_EXPANSION_MAX
  2038. */
  2039. uint32_t BeaconSymbolToExpansionMax;
  2040. /*!
  2041. * Maximum symbol timeout for ping slots
  2042. *
  2043. * Related MIB type: \ref MIB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX
  2044. */
  2045. uint32_t PingSlotSymbolToExpansionMax;
  2046. /*!
  2047. * Symbol expansion value for beacon windows in case of beacon
  2048. * loss in symbols
  2049. *
  2050. * Related MIB type: \ref MIB_BEACON_SYMBOL_TO_EXPANSION_FACTOR
  2051. */
  2052. uint32_t BeaconSymbolToExpansionFactor;
  2053. /*!
  2054. * Symbol expansion value for ping slot windows in case of beacon
  2055. * loss in symbols
  2056. *
  2057. * Related MIB type: \ref MIB_PING_SLOT_SYMBOL_TO_EXPANSION_FACTOR
  2058. */
  2059. uint32_t PingSlotSymbolToExpansionFactor;
  2060. /*!
  2061. * Maximum allowed beacon less time in ms
  2062. *
  2063. * Related MIB type: \ref MIB_MAX_BEACON_LESS_PERIOD
  2064. */
  2065. uint32_t MaxBeaconLessPeriod;
  2066. /*!
  2067. * Ping slots data rate
  2068. *
  2069. * Related MIB type: \ref MIB_PING_SLOT_DATARATE
  2070. */
  2071. int8_t PingSlotDatarate;
  2072. }MibParam_t;
  2073. /*!
  2074. * LoRaMAC MIB-RequestConfirm structure
  2075. */
  2076. typedef struct eMibRequestConfirm
  2077. {
  2078. /*!
  2079. * MIB-Request type
  2080. */
  2081. Mib_t Type;
  2082. /*!
  2083. * MLME-RequestConfirm parameters
  2084. */
  2085. MibParam_t Param;
  2086. }MibRequestConfirm_t;
  2087. /*!
  2088. * LoRaMAC tx information
  2089. */
  2090. typedef struct sLoRaMacTxInfo
  2091. {
  2092. /*!
  2093. * Size of the application data payload which can be transmitted.
  2094. */
  2095. uint8_t MaxPossibleApplicationDataSize;
  2096. /*!
  2097. * The current maximum possible payload size without MAC commands
  2098. * which is dependent on the current datarate.
  2099. */
  2100. uint8_t CurrentPossiblePayloadSize;
  2101. }LoRaMacTxInfo_t;
  2102. /*!
  2103. * LoRaMAC Status
  2104. */
  2105. typedef enum eLoRaMacStatus
  2106. {
  2107. /*!
  2108. * Service started successfully
  2109. */
  2110. LORAMAC_STATUS_OK,
  2111. /*!
  2112. * Service not started - LoRaMAC is busy
  2113. */
  2114. LORAMAC_STATUS_BUSY,
  2115. /*!
  2116. * Service unknown
  2117. */
  2118. LORAMAC_STATUS_SERVICE_UNKNOWN,
  2119. /*!
  2120. * Service not started - invalid parameter
  2121. */
  2122. LORAMAC_STATUS_PARAMETER_INVALID,
  2123. /*!
  2124. * Service not started - invalid frequency
  2125. */
  2126. LORAMAC_STATUS_FREQUENCY_INVALID,
  2127. /*!
  2128. * Service not started - invalid datarate
  2129. */
  2130. LORAMAC_STATUS_DATARATE_INVALID,
  2131. /*!
  2132. * Service not started - invalid frequency and datarate
  2133. */
  2134. LORAMAC_STATUS_FREQ_AND_DR_INVALID,
  2135. /*!
  2136. * Service not started - the device is not in a LoRaWAN
  2137. */
  2138. LORAMAC_STATUS_NO_NETWORK_JOINED,
  2139. /*!
  2140. * Service not started - payload length error
  2141. */
  2142. LORAMAC_STATUS_LENGTH_ERROR,
  2143. /*!
  2144. * Service not started - the specified region is not supported
  2145. * or not activated with preprocessor definitions.
  2146. */
  2147. LORAMAC_STATUS_REGION_NOT_SUPPORTED,
  2148. /*!
  2149. * The application data was not transmitted
  2150. * because prioritized pending MAC commands had to be sent.
  2151. */
  2152. LORAMAC_STATUS_SKIPPED_APP_DATA,
  2153. /*!
  2154. * ToDo
  2155. */
  2156. LORAMAC_STATUS_DUTYCYCLE_RESTRICTED,
  2157. /*!
  2158. *
  2159. */
  2160. LORAMAC_STATUS_NO_CHANNEL_FOUND,
  2161. /*!
  2162. *
  2163. */
  2164. LORAMAC_STATUS_NO_FREE_CHANNEL_FOUND,
  2165. /*!
  2166. * ToDo
  2167. */
  2168. LORAMAC_STATUS_BUSY_BEACON_RESERVED_TIME,
  2169. /*!
  2170. * ToDo
  2171. */
  2172. LORAMAC_STATUS_BUSY_PING_SLOT_WINDOW_TIME,
  2173. /*!
  2174. * ToDo
  2175. */
  2176. LORAMAC_STATUS_BUSY_UPLINK_COLLISION,
  2177. /*!
  2178. * An error in the cryptographic module is occurred
  2179. */
  2180. LORAMAC_STATUS_CRYPTO_ERROR,
  2181. /*!
  2182. * An error in the frame counter handler module is occurred
  2183. */
  2184. LORAMAC_STATUS_FCNT_HANDLER_ERROR,
  2185. /*!
  2186. * An error in the MAC command module is occurred
  2187. */
  2188. LORAMAC_STATUS_MAC_COMMAD_ERROR,
  2189. /*!
  2190. * An error in the Class B module is occurred
  2191. */
  2192. LORAMAC_STATUS_CLASS_B_ERROR,
  2193. /*!
  2194. * An error in the Confirm Queue module is occurred
  2195. */
  2196. LORAMAC_STATUS_CONFIRM_QUEUE_ERROR,
  2197. /*!
  2198. * The multicast group doesn't exist
  2199. */
  2200. LORAMAC_STATUS_MC_GROUP_UNDEFINED,
  2201. /*!
  2202. * Undefined error occurred
  2203. */
  2204. LORAMAC_STATUS_ERROR
  2205. }LoRaMacStatus_t;
  2206. /*!
  2207. * LoRaMAC region enumeration
  2208. */
  2209. typedef enum eLoRaMacRegion_t
  2210. {
  2211. /*!
  2212. * AS band on 923MHz
  2213. */
  2214. LORAMAC_REGION_AS923,
  2215. /*!
  2216. * Australian band on 915MHz
  2217. */
  2218. LORAMAC_REGION_AU915,
  2219. /*!
  2220. * Chinese band on 470MHz
  2221. */
  2222. LORAMAC_REGION_CN470,
  2223. /*!
  2224. * Chinese band on 779MHz
  2225. */
  2226. LORAMAC_REGION_CN779,
  2227. /*!
  2228. * European band on 433MHz
  2229. */
  2230. LORAMAC_REGION_EU433,
  2231. /*!
  2232. * European band on 868MHz
  2233. */
  2234. LORAMAC_REGION_EU868,
  2235. /*!
  2236. * South korean band on 920MHz
  2237. */
  2238. LORAMAC_REGION_KR920,
  2239. /*!
  2240. * India band on 865MHz
  2241. */
  2242. LORAMAC_REGION_IN865,
  2243. /*!
  2244. * North american band on 915MHz
  2245. */
  2246. LORAMAC_REGION_US915,
  2247. /*!
  2248. * Russia band on 864MHz
  2249. */
  2250. LORAMAC_REGION_RU864,
  2251. }LoRaMacRegion_t;
  2252. /*!
  2253. * Enumeration of modules which have a context
  2254. */
  2255. typedef enum LoRaMacNvmCtxModule_e
  2256. {
  2257. /*!
  2258. * Context for the MAC
  2259. */
  2260. LORAMAC_NVMCTXMODULE_MAC,
  2261. /*!
  2262. * Context for the regions
  2263. */
  2264. LORAMAC_NVMCTXMODULE_REGION,
  2265. /*!
  2266. * Context for the crypto module
  2267. */
  2268. LORAMAC_NVMCTXMODULE_CRYPTO,
  2269. /*!
  2270. * Context for the secure element
  2271. */
  2272. LORAMAC_NVMCTXMODULE_SECURE_ELEMENT,
  2273. /*!
  2274. * Context for the command queue
  2275. */
  2276. LORAMAC_NVMCTXMODULE_COMMANDS,
  2277. /*!
  2278. * Context for class b
  2279. */
  2280. LORAMAC_NVMCTXMODULE_CLASS_B,
  2281. /*!
  2282. * Context for the confirm queue
  2283. */
  2284. LORAMAC_NVMCTXMODULE_CONFIRM_QUEUE,
  2285. }LoRaMacNvmCtxModule_t;
  2286. /*!
  2287. * LoRaMAC events structure
  2288. * Used to notify upper layers of MAC events
  2289. */
  2290. typedef struct sLoRaMacPrimitives
  2291. {
  2292. /*!
  2293. * \brief MCPS-Confirm primitive
  2294. *
  2295. * \param [OUT] MCPS-Confirm parameters
  2296. */
  2297. void ( *MacMcpsConfirm )( McpsConfirm_t* McpsConfirm );
  2298. /*!
  2299. * \brief MCPS-Indication primitive
  2300. *
  2301. * \param [OUT] MCPS-Indication parameters
  2302. */
  2303. void ( *MacMcpsIndication )( McpsIndication_t* McpsIndication );
  2304. /*!
  2305. * \brief MLME-Confirm primitive
  2306. *
  2307. * \param [OUT] MLME-Confirm parameters
  2308. */
  2309. void ( *MacMlmeConfirm )( MlmeConfirm_t* MlmeConfirm );
  2310. /*!
  2311. * \brief MLME-Indication primitive
  2312. *
  2313. * \param [OUT] MLME-Indication parameters
  2314. */
  2315. void ( *MacMlmeIndication )( MlmeIndication_t* MlmeIndication );
  2316. }LoRaMacPrimitives_t;
  2317. /*!
  2318. * LoRaMAC callback structure
  2319. */
  2320. typedef struct sLoRaMacCallback
  2321. {
  2322. /*!
  2323. * \brief Measures the battery level
  2324. *
  2325. * \retval Battery level [0: node is connected to an external
  2326. * power source, 1..254: battery level, where 1 is the minimum
  2327. * and 254 is the maximum value, 255: the node was not able
  2328. * to measure the battery level]
  2329. */
  2330. uint8_t ( *GetBatteryLevel )( void );
  2331. /*!
  2332. * \brief Measures the temperature level
  2333. *
  2334. * \retval Temperature level
  2335. */
  2336. float ( *GetTemperatureLevel )( void );
  2337. /*!
  2338. * \brief Will be called when an attribute has changed in one of the context.
  2339. *
  2340. * \param Context that changed
  2341. */
  2342. void ( *NvmContextChange )( LoRaMacNvmCtxModule_t module );
  2343. /*!
  2344. *\brief Will be called each time a Radio IRQ is handled by the MAC
  2345. * layer.
  2346. *
  2347. *\warning Runs in a IRQ context. Should only change variables state.
  2348. */
  2349. void ( *MacProcessNotify )( void );
  2350. }LoRaMacCallback_t;
  2351. /*!
  2352. * LoRaMAC Max EIRP (dBm) table
  2353. */
  2354. static const uint8_t LoRaMacMaxEirpTable[] = { 8, 10, 12, 13, 14, 16, 18, 20, 21, 24, 26, 27, 29, 30, 33, 36 };
  2355. /*!
  2356. * \brief LoRaMAC layer initialization
  2357. *
  2358. * \details In addition to the initialization of the LoRaMAC layer, this
  2359. * function initializes the callback primitives of the MCPS and
  2360. * MLME services. Every data field of \ref LoRaMacPrimitives_t must be
  2361. * set to a valid callback function.
  2362. *
  2363. * \param [IN] primitives - Pointer to a structure defining the LoRaMAC
  2364. * event functions. Refer to \ref LoRaMacPrimitives_t.
  2365. *
  2366. * \param [IN] callbacks - Pointer to a structure defining the LoRaMAC
  2367. * callback functions. Refer to \ref LoRaMacCallback_t.
  2368. *
  2369. * \param [IN] region - The region to start.
  2370. *
  2371. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2372. * returns are:
  2373. * \ref LORAMAC_STATUS_OK,
  2374. * \ref LORAMAC_STATUS_PARAMETER_INVALID,
  2375. * \ref LORAMAC_STATUS_REGION_NOT_SUPPORTED.
  2376. */
  2377. LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacCallback_t* callbacks, LoRaMacRegion_t region );
  2378. /*!
  2379. * \brief Starts LoRaMAC layer
  2380. *
  2381. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2382. * returns are:
  2383. * \ref LORAMAC_STATUS_OK,
  2384. */
  2385. LoRaMacStatus_t LoRaMacStart( void );
  2386. /*!
  2387. * \brief Stops LoRaMAC layer
  2388. *
  2389. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2390. * returns are:
  2391. * \ref LORAMAC_STATUS_OK,
  2392. */
  2393. LoRaMacStatus_t LoRaMacStop( void );
  2394. /*!
  2395. * \brief Returns a value indicating if the MAC layer is busy or not.
  2396. *
  2397. * \retval isBusy Mac layer is busy.
  2398. */
  2399. bool LoRaMacIsBusy( void );
  2400. /*!
  2401. * Processes the LoRaMac events.
  2402. *
  2403. * \remark This function must be called in the main loop.
  2404. */
  2405. void LoRaMacProcess( void );
  2406. /*!
  2407. * \brief Queries the LoRaMAC if it is possible to send the next frame with
  2408. * a given application data payload size. The LoRaMAC takes scheduled
  2409. * MAC commands into account and reports, when the frame can be send or not.
  2410. *
  2411. * \param [IN] size - Size of application data payload to be send next
  2412. *
  2413. * \param [OUT] txInfo - The structure \ref LoRaMacTxInfo_t contains
  2414. * information about the actual maximum payload possible
  2415. * ( according to the configured datarate or the next
  2416. * datarate according to ADR ), and the maximum frame
  2417. * size, taking the scheduled MAC commands into account.
  2418. *
  2419. * \retval LoRaMacStatus_t Status of the operation. When the parameters are
  2420. * not valid, the function returns \ref LORAMAC_STATUS_PARAMETER_INVALID.
  2421. * In case of a length error caused by the application data payload in combination
  2422. * with the MAC commands, the function returns \ref LORAMAC_STATUS_LENGTH_ERROR.
  2423. * In this case its recommended to send a frame without application data to flush
  2424. * the MAC commands. Otherwise the LoRaMAC will prioritize the MAC commands and
  2425. * if needed it will skip the application data. Please note that if MAC commands do
  2426. * not fit at all into the payload size on the related datarate, the LoRaMAC will
  2427. * automatically clip the MAC commands.
  2428. * In case the query is valid, and the LoRaMAC is able to send the frame,
  2429. * the function returns \ref LORAMAC_STATUS_OK.
  2430. */
  2431. LoRaMacStatus_t LoRaMacQueryTxPossible( uint8_t size, LoRaMacTxInfo_t* txInfo );
  2432. /*!
  2433. * \brief LoRaMAC channel add service
  2434. *
  2435. * \details Adds a new channel to the channel list and activates the id in
  2436. * the channel mask. Please note that this functionality is not available
  2437. * on all regions. Information about allowed ranges are available at the LoRaWAN Regional Parameters V1.0.2rB
  2438. *
  2439. * \param [IN] id - Id of the channel.
  2440. *
  2441. * \param [IN] params - Channel parameters to set.
  2442. *
  2443. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2444. * \ref LORAMAC_STATUS_OK,
  2445. * \ref LORAMAC_STATUS_BUSY,
  2446. * \ref LORAMAC_STATUS_PARAMETER_INVALID.
  2447. */
  2448. LoRaMacStatus_t LoRaMacChannelAdd( uint8_t id, ChannelParams_t params );
  2449. /*!
  2450. * \brief LoRaMAC channel remove service
  2451. *
  2452. * \details Deactivates the id in the channel mask.
  2453. *
  2454. * \param [IN] id - Id of the channel.
  2455. *
  2456. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2457. * \ref LORAMAC_STATUS_OK,
  2458. * \ref LORAMAC_STATUS_BUSY,
  2459. * \ref LORAMAC_STATUS_PARAMETER_INVALID.
  2460. */
  2461. LoRaMacStatus_t LoRaMacChannelRemove( uint8_t id );
  2462. /*!
  2463. * \brief LoRaMAC multicast channel setup service
  2464. *
  2465. * \details Sets up a multicast channel.
  2466. *
  2467. * \param [IN] channel - Multicast channel to set.
  2468. *
  2469. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2470. * \ref LORAMAC_STATUS_OK,
  2471. * \ref LORAMAC_STATUS_BUSY,
  2472. * \ref LORAMAC_STATUS_PARAMETER_INVALID,
  2473. * \ref LORAMAC_STATUS_MC_GROUP_UNDEFINED.
  2474. */
  2475. LoRaMacStatus_t LoRaMacMcChannelSetup( McChannelParams_t *channel );
  2476. /*!
  2477. * \brief LoRaMAC multicast channel removal service
  2478. *
  2479. * \details Removes/Disables a multicast channel.
  2480. *
  2481. * \param [IN] groupID - Multicast channel ID to be removed/disabled
  2482. *
  2483. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2484. * \ref LORAMAC_STATUS_OK,
  2485. * \ref LORAMAC_STATUS_BUSY,
  2486. * \ref LORAMAC_STATUS_MC_GROUP_UNDEFINED.
  2487. */
  2488. LoRaMacStatus_t LoRaMacMcChannelDelete( AddressIdentifier_t groupID );
  2489. /*!
  2490. * \brief LoRaMAC multicast channel get groupId from MC address.
  2491. *
  2492. * \param [IN] mcAddress - Multicast address to be checked
  2493. *
  2494. * \retval groupID Multicast channel ID associated to the address.
  2495. * Returns 0xFF if the address isn't found.
  2496. */
  2497. uint8_t LoRaMacMcChannelGetGroupId( uint32_t mcAddress );
  2498. /*!
  2499. * \brief LoRaMAC multicast channel Rx parameters setup service
  2500. *
  2501. * \details Sets up a multicast channel reception parameters.
  2502. *
  2503. * \param [IN] groupID - Multicast channel ID
  2504. * \param [IN] rxParams - Reception parameters
  2505. * \param [OUT] status - Status mask [UNDEF_ID | FREQ_ERR | DR_ERR | GROUP_ID]
  2506. *
  2507. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2508. * \ref LORAMAC_STATUS_OK,
  2509. * \ref LORAMAC_STATUS_BUSY,
  2510. * \ref LORAMAC_STATUS_PARAMETER_INVALID,
  2511. * \ref LORAMAC_STATUS_MC_GROUP_UNDEFINED.
  2512. */
  2513. LoRaMacStatus_t LoRaMacMcChannelSetupRxParams( AddressIdentifier_t groupID, McRxParams_t *rxParams, uint8_t *status );
  2514. /*!
  2515. * \brief LoRaMAC MIB-Get
  2516. *
  2517. * \details The mac information base service to get attributes of the LoRaMac
  2518. * layer.
  2519. *
  2520. * The following code-snippet shows how to use the API to get the
  2521. * parameter AdrEnable, defined by the enumeration type
  2522. * \ref MIB_ADR.
  2523. * \code
  2524. * MibRequestConfirm_t mibReq;
  2525. * mibReq.Type = MIB_ADR;
  2526. *
  2527. * if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK )
  2528. * {
  2529. * // LoRaMAC updated the parameter mibParam.AdrEnable
  2530. * }
  2531. * \endcode
  2532. *
  2533. * \param [IN] mibRequest - MIB-GET-Request to perform. Refer to \ref MibRequestConfirm_t.
  2534. *
  2535. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2536. * \ref LORAMAC_STATUS_OK,
  2537. * \ref LORAMAC_STATUS_SERVICE_UNKNOWN,
  2538. * \ref LORAMAC_STATUS_PARAMETER_INVALID.
  2539. */
  2540. LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t* mibGet );
  2541. /*!
  2542. * \brief LoRaMAC MIB-Set
  2543. *
  2544. * \details The mac information base service to set attributes of the LoRaMac
  2545. * layer.
  2546. *
  2547. * The following code-snippet shows how to use the API to set the
  2548. * parameter AdrEnable, defined by the enumeration type
  2549. * \ref MIB_ADR.
  2550. *
  2551. * \code
  2552. * MibRequestConfirm_t mibReq;
  2553. * mibReq.Type = MIB_ADR;
  2554. * mibReq.Param.AdrEnable = true;
  2555. *
  2556. * if( LoRaMacMibGetRequestConfirm( &mibReq ) == LORAMAC_STATUS_OK )
  2557. * {
  2558. * // LoRaMAC updated the parameter
  2559. * }
  2560. * \endcode
  2561. *
  2562. * \param [IN] mibRequest - MIB-SET-Request to perform. Refer to \ref MibRequestConfirm_t.
  2563. *
  2564. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2565. * \ref LORAMAC_STATUS_OK,
  2566. * \ref LORAMAC_STATUS_BUSY,
  2567. * \ref LORAMAC_STATUS_SERVICE_UNKNOWN,
  2568. * \ref LORAMAC_STATUS_PARAMETER_INVALID.
  2569. */
  2570. LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t* mibSet );
  2571. /*!
  2572. * \brief LoRaMAC MLME-Request
  2573. *
  2574. * \details The Mac layer management entity handles management services. The
  2575. * following code-snippet shows how to use the API to perform a
  2576. * network join request. Please note that for a join request, the
  2577. * DevEUI and the JoinEUI must be set previously via the MIB. Please
  2578. * also refer to the sample implementations.
  2579. *
  2580. * \code
  2581. *
  2582. * MlmeReq_t mlmeReq;
  2583. * mlmeReq.Type = MLME_JOIN;
  2584. * mlmeReq.Req.Join.Datarate = LORAWAN_DEFAULT_DATARATE;
  2585. *
  2586. * if( LoRaMacMlmeRequest( &mlmeReq ) == LORAMAC_STATUS_OK )
  2587. * {
  2588. * // Service started successfully. Waiting for the Mlme-Confirm event
  2589. * }
  2590. * \endcode
  2591. *
  2592. * \param [IN] mlmeRequest - MLME-Request to perform. Refer to \ref MlmeReq_t.
  2593. *
  2594. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2595. * \ref LORAMAC_STATUS_OK,
  2596. * \ref LORAMAC_STATUS_BUSY,
  2597. * \ref LORAMAC_STATUS_SERVICE_UNKNOWN,
  2598. * \ref LORAMAC_STATUS_PARAMETER_INVALID,
  2599. * \ref LORAMAC_STATUS_NO_NETWORK_JOINED,
  2600. * \ref LORAMAC_STATUS_LENGTH_ERROR,
  2601. */
  2602. LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest );
  2603. /*!
  2604. * \brief LoRaMAC MCPS-Request
  2605. *
  2606. * \details The Mac Common Part Sublayer handles data services. The following
  2607. * code-snippet shows how to use the API to send an unconfirmed
  2608. * LoRaMAC frame.
  2609. *
  2610. * \code
  2611. * uint8_t myBuffer[] = { 1, 2, 3 };
  2612. *
  2613. * McpsReq_t mcpsReq;
  2614. * mcpsReq.Type = MCPS_UNCONFIRMED;
  2615. * mcpsReq.Req.Unconfirmed.fPort = 1;
  2616. * mcpsReq.Req.Unconfirmed.fBuffer = myBuffer;
  2617. * mcpsReq.Req.Unconfirmed.fBufferSize = sizeof( myBuffer );
  2618. *
  2619. * if( LoRaMacMcpsRequest( &mcpsReq ) == LORAMAC_STATUS_OK )
  2620. * {
  2621. * // Service started successfully. Waiting for the MCPS-Confirm event
  2622. * }
  2623. * \endcode
  2624. *
  2625. * \param [IN] mcpsRequest - MCPS-Request to perform. Refer to \ref McpsReq_t.
  2626. *
  2627. * \retval LoRaMacStatus_t Status of the operation. Possible returns are:
  2628. * \ref LORAMAC_STATUS_OK,
  2629. * \ref LORAMAC_STATUS_BUSY,
  2630. * \ref LORAMAC_STATUS_SERVICE_UNKNOWN,
  2631. * \ref LORAMAC_STATUS_PARAMETER_INVALID,
  2632. * \ref LORAMAC_STATUS_NO_NETWORK_JOINED,
  2633. * \ref LORAMAC_STATUS_LENGTH_ERROR,
  2634. */
  2635. LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t* mcpsRequest );
  2636. /*!
  2637. * Automatically add the Region.h file at the end of LoRaMac.h file.
  2638. * This is required because Region.h uses definitions from LoRaMac.h
  2639. */
  2640. #include "Region.h"
  2641. /*! \} defgroup LORAMAC */
  2642. #ifdef __cplusplus
  2643. }
  2644. #endif
  2645. #endif // __LORAMAC_H__