Semtech / LoRaWAN-NAMote72-Application-Demo

Dependencies:   LoRaWAN-lib mbed lib_mpl3115a2 lib_mma8451q lib_gps SX1272Lib

Dependents:   LoRaWAN-NAMote72-BVS-confirmed-tester-0-7v1_copy

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRaDeviceStateProc.h Source File

LoRaDeviceStateProc.h

00001 /*
00002  / _____)             _              | |
00003 ( (____  _____ ____ _| |_ _____  ____| |__
00004  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00005  _____) ) ____| | | || |_| ____( (___| | | |
00006 (______/|_____)_|_|_| \__)_____)\____)_| |_|
00007     (C)2015 Semtech
00008 
00009 Description: Process function calls from various Device states
00010 
00011 License: Revised BSD License, see LICENSE.TXT file include in the project
00012 
00013 Maintainer: Uttam Bhat
00014 */
00015 #ifndef __LORA_DEVICE_STATE_H__
00016 #define __LORA_DEVICE_STATE_H__
00017 
00018 #include "Common.h"
00019 #include "board.h"
00020 #include "LoRaMac.h"
00021 #include "LoRaEventProc.h"
00022 #include "SerialDisplay.h"
00023 #include "mbed.h"
00024 #include "LoRaMacLayerService.h"
00025 
00026 /*!
00027  * Strucure containing the Uplink status
00028  */
00029 struct sLoRaMacUplinkStatus 
00030 {
00031     /*!
00032      * MCPS-Request type
00033      */
00034     Mcps_t Type ;
00035     uint8_t Acked;
00036     int8_t Datarate;
00037     uint16_t UplinkCounter;
00038     uint8_t Port;
00039     uint8_t *Buffer;
00040     uint8_t BufferSize;
00041     int8_t TxPower;
00042     uint32_t UpLinkFrequency;
00043 };
00044 
00045 /*!
00046  * Strucure containing the Downlink status
00047  */
00048 struct sLoRaMacDownlinkStatus 
00049 {
00050     int16_t Rssi;
00051     int8_t Snr;
00052     uint16_t DownlinkCounter;
00053     bool RxData;
00054     uint8_t Port;
00055     uint8_t *Buffer;
00056     uint8_t BufferSize;
00057     uint8_t RxSlot;
00058 };
00059 
00060 /*!
00061  * Structure containing OTAA Join status
00062  */ 
00063 struct sLoRaMacJoinStatus 
00064 {
00065     int8_t LastDatarate;
00066     int8_t Status;
00067 };
00068 
00069 /*!
00070  * Device states
00071  */
00072 enum eDevicState
00073 {
00074     DEVICE_STATE_INIT,
00075     DEVICE_STATE_JOIN,
00076     DEVICE_STATE_SEND,
00077     DEVICE_STATE_SLEEP
00078 };
00079 
00080 extern sLoRaMacUplinkStatus  LoRaMacUplinkStatus;
00081 
00082 extern sLoRaMacDownlinkStatus  LoRaMacDownlinkStatus;
00083 
00084 extern eDevicState DeviceState;
00085 
00086 extern sLoRaMacJoinStatus  LoRaMacJoinStatus;
00087 
00088 /*!
00089  * \brief Initialize Device: Timer, MAC Services, MAC
00090  */
00091 void DeviceInit( void );
00092 
00093 /*!
00094  * \brief Device Join update
00095  */
00096 void DeviceJoinUpdate( void );
00097 
00098 /*!
00099  * \brief OTA: if device not joined, send JOIN REQUEST to network
00100  *      ABP: Request DevAddr if not already set
00101  */
00102 void DeviceJoin( void );
00103 
00104 /*!
00105  * \brief   Prepares the payload of the frame to be transmitted
00106  *
00107  * \param [IN] port application port corresponding to which payload is generated
00108  */
00109 void PrepareTxFrame( uint8_t port );
00110 
00111 /*!
00112  * \brief   Send the frame
00113  *
00114  */
00115 bool SendFrame( void );
00116 
00117 #endif // __LORA_DEVICE_STATE_H__