Nagaraj Krishnamurthy / LoRaWAN-NAMote72-Application-Demo_IoTium

Dependencies:   LoRaWAN-lib SX1272Lib lib_gps lib_mma8451q lib_mpl3115a2 mbed

Fork of LoRaWAN-NAMote72-Application-Demo_Multitech by Nagaraj Krishnamurthy

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 };
00043 
00044 /*!
00045  * Strucure containing the Downlink status
00046  */
00047 struct sLoRaMacDownlinkStatus 
00048 {
00049     int16_t Rssi;
00050     int8_t Snr;
00051     uint16_t DownlinkCounter;
00052     bool RxData;
00053     uint8_t Port;
00054     uint8_t *Buffer;
00055     uint8_t BufferSize;
00056     uint8_t RxSlot;
00057 };
00058 
00059 /*!
00060  * Device states
00061  */
00062 enum eDevicState
00063 {
00064     DEVICE_STATE_INIT,
00065     DEVICE_STATE_JOIN,
00066     DEVICE_STATE_SEND,
00067     DEVICE_STATE_SLEEP
00068 };
00069 
00070 extern sLoRaMacUplinkStatus  LoRaMacUplinkStatus;
00071 
00072 extern sLoRaMacDownlinkStatus  LoRaMacDownlinkStatus;
00073 
00074 extern eDevicState DeviceState;
00075 
00076 /*!
00077  * \brief Initialize Device: Timer, MAC Services, MAC
00078  */
00079 void DeviceInit( void );
00080 
00081 /*!
00082  * \brief Device Join update
00083  */
00084 void DeviceJoinUpdate( void );
00085 
00086 /*!
00087  * \brief OTA: if device not joined, send JOIN REQUEST to network
00088  *      ABP: Request DevAddr if not already set
00089  */
00090 void DeviceJoin( void );
00091 
00092 /*!
00093  * \brief   Prepares the payload of the frame to be transmitted
00094  *
00095  * \param [IN] port application port corresponding to which payload is generated
00096  */
00097 void PrepareTxFrame( uint8_t port );
00098 
00099 /*!
00100  * \brief   Send the frame
00101  *
00102  */
00103 bool SendFrame( void );
00104 
00105 #endif // __LORA_DEVICE_STATE_H__