WizziLab / modem_ref

Dependents:   modem_ref_helper

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lwan.h Source File

lwan.h

Go to the documentation of this file.
00001 /// @copyright
00002 /// ========================================================================={{{
00003 /// Copyright (c) 2012-2020 WizziLab                                           /
00004 /// All rights reserved                                                        /
00005 /// =========================================================================}}}
00006 /// @endcopyright
00007 
00008 //  =======================================================================
00009 /// @file           lwan.h
00010 /// @brief          LWAN Module headers
00011 //  =======================================================================
00012 
00013 #ifndef __LWAN_H__
00014 #define __LWAN_H__
00015 
00016 // =======================================================================
00017 /// LoRa ISM Bands
00018 // =======================================================================
00019 typedef enum
00020 {
00021     ISM_BAND_470,
00022     ISM_BAND_780,
00023     ISM_BAND_433,
00024     ISM_BAND_868,
00025     ISM_BAND_915,
00026     ISM_BAND_QTY,
00027 
00028 } lwan_ism_band_t;
00029 
00030 // =======================================================================
00031 /// 
00032 // =======================================================================
00033 TYPEDEF_STRUCT_PACKED 
00034 {
00035     // LoRaWAN device class
00036     u8 dev_class;
00037     // Activation state of adaptativeDatarate
00038     u8 adr_enable;
00039     // Uplink datarate, if adr_enable is off
00040     s8 tx_datarate;
00041     // ISM Band
00042     u8 ism_band;
00043     // Number of join attempts;
00044     u8 join_trials;
00045     // Rejoin period (hours)
00046     u8 rejoin_period;
00047 
00048 } lwan_cfg_t;
00049 #define FS_LWAN_CFG_SIZE    (sizeof(lwan_cfg_t))
00050 
00051 // =======================================================================
00052 /// 
00053 // =======================================================================
00054 TYPEDEF_STRUCT_PACKED 
00055 {
00056     // Application identifier
00057     u8  app_id[8];
00058     // Application key
00059     u8  app_key[16];
00060 
00061 } lwan_nls_t;
00062 #define FS_LWAN_NLS_SIZE    (sizeof(lwan_nls_t))
00063 
00064 // =======================================================================
00065 /// 
00066 // =======================================================================
00067 #define FS_LWAN_STATUS_FREQS    8
00068 TYPEDEF_STRUCT_PACKED 
00069 {
00070     // Indicates if the MAC layer has already joined a network.
00071     bool        IsNetworkJoined;
00072 
00073     // Network ID ( 3 bytes )
00074     uint32_t    NetID;
00075 
00076     // ISM Band
00077     uint8_t     IsmBand;
00078     
00079     // Indicates if the node is connected to a _private or network
00080     bool        PublicNetwork;
00081 
00082     // ADR control status
00083     bool        AdrCtrlOn;
00084 
00085     // Enables/Disables duty cycle management (Test only)
00086     bool        DutyCycleOn;
00087 
00088     // Maximum duty cycle
00089     uint8_t     MaxDCycle;
00090 
00091     // frame counter. Each time a packet is sent the counter is incremented. Only the 16 LSB bits are sent
00092     uint32_t    UpLinkCounter;
00093 
00094     // frame counter. Each time a packet is received the counter is incremented. Only the 16 LSB bits are received
00095     uint32_t    DownLinkCounter;
00096 
00097     // Counts the number of missed ADR acknowledgements
00098     uint32_t    AdrAckCounter;
00099 
00100     // Channels TX power
00101     int8_t      TxPower;
00102 
00103     // Channels data rate
00104     int8_t      TxDr;
00105 
00106     // Datarate offset between uplink and downlink on first window
00107     uint8_t     Rx1DrOffset;
00108 
00109     // 2nd reception window frequency
00110     uint32_t    Rx2ChannelFreq;
00111 
00112     // 2nd reception window Datarate frequency
00113     uint8_t     Rx2ChannelDr;
00114 
00115      // Mask indicating which channels are enabled
00116     uint32_t    TxFreqs[FS_LWAN_STATUS_FREQS];    
00117 
00118 } lwan_status_t;
00119 #define FS_LWAN_STATUS_SIZE    (sizeof(lwan_status_t))
00120 
00121 // =======================================================================
00122 /// Classes
00123 // =======================================================================
00124 typedef enum
00125 {
00126     // LoRaWAN device class A
00127     // LoRaWAN Specification V1.0, chapter 3ff
00128     LWAN_CLASS_A,
00129     // LoRaWAN device class B
00130     // LoRaWAN Specification V1.0, chapter 8ff
00131     LWAN_CLASS_B,
00132     // LoRaWAN device class C
00133     // LoRaWAN Specification V1.0, chapter 17ff
00134     LWAN_CLASS_C,
00135 
00136 } lwan_dev_class_t;
00137 
00138 #endif // __LWAN_H__