Sensor Demo for CTIA

Dependencies:   LoRaWAN-lib SX1272Lib lib_gps lib_mma8451q lib_mpl3115a2 mbed

Fork of LoRaWAN-NAMote72-Application-Demo by Semtech

Committer:
ubhat
Date:
Tue Aug 30 03:57:19 2016 +0000
Revision:
14:172b8e37168c
Parent:
13:238b23d4025c
Add Application for Sensor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ubhat 0:69f2e28d12c1 1 /*
ubhat 0:69f2e28d12c1 2 / _____) _ | |
ubhat 0:69f2e28d12c1 3 ( (____ _____ ____ _| |_ _____ ____| |__
ubhat 0:69f2e28d12c1 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
ubhat 0:69f2e28d12c1 5 _____) ) ____| | | || |_| ____( (___| | | |
ubhat 0:69f2e28d12c1 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
ubhat 0:69f2e28d12c1 7 (C)2015 Semtech
ubhat 0:69f2e28d12c1 8
ubhat 0:69f2e28d12c1 9 Description: User-defined applications such as GPS, Temp, Accelerometer, LED indications etc.
ubhat 0:69f2e28d12c1 10 Event based actions such as LED blink on Tx, LED toggle on downlink etc
ubhat 0:69f2e28d12c1 11
ubhat 0:69f2e28d12c1 12 License: Revised BSD License, see LICENSE.TXT file include in the project
ubhat 0:69f2e28d12c1 13
ubhat 0:69f2e28d12c1 14 Maintainer: Uttam Bhat
ubhat 0:69f2e28d12c1 15 */
ubhat 0:69f2e28d12c1 16
ubhat 0:69f2e28d12c1 17 #ifndef __APPLICATION_H__
ubhat 0:69f2e28d12c1 18 #define __APPLICATION_H__
ubhat 0:69f2e28d12c1 19
ubhat 0:69f2e28d12c1 20 #include "board.h"
ubhat 0:69f2e28d12c1 21 #include "Common.h"
ubhat 0:69f2e28d12c1 22 #include "SerialDisplay.h"
ubhat 0:69f2e28d12c1 23
ubhat 0:69f2e28d12c1 24 /*!
ubhat 0:69f2e28d12c1 25 * LED ON/OFF definition
ubhat 0:69f2e28d12c1 26 */
ubhat 0:69f2e28d12c1 27 #define LED_ON 0
ubhat 0:69f2e28d12c1 28 #define LED_OFF 1
ubhat 0:69f2e28d12c1 29
ubhat 0:69f2e28d12c1 30 /*!
ubhat 0:69f2e28d12c1 31 * LED types
ubhat 0:69f2e28d12c1 32 */
ubhat 0:69f2e28d12c1 33 enum eLedType
ubhat 0:69f2e28d12c1 34 {
ubhat 0:69f2e28d12c1 35 Red = 0,// Red LED
ubhat 0:69f2e28d12c1 36 Yellow = 1, // Yellow LED
ubhat 0:69f2e28d12c1 37 Green = 2, // Green LED
ubhat 0:69f2e28d12c1 38 Usr = 3, // USR LED
ubhat 0:69f2e28d12c1 39 };
ubhat 0:69f2e28d12c1 40
ubhat 0:69f2e28d12c1 41 /*!
ubhat 0:69f2e28d12c1 42 * user-defined Application names
ubhat 0:69f2e28d12c1 43 */
ubhat 0:69f2e28d12c1 44 enum eAppType
ubhat 0:69f2e28d12c1 45 {
ubhat 0:69f2e28d12c1 46 AppGps = 0, // GPS application
ubhat 13:238b23d4025c 47 AppPrsr, // Pressure measurement application
ubhat 13:238b23d4025c 48 AppTemp, // Temperature measurement application
ubhat 13:238b23d4025c 49 AppBat, // Battery measurement application
ubhat 13:238b23d4025c 50 AppRamp, // Generate Ramp bytes
ubhat 13:238b23d4025c 51 AppAccl, // Accelerometer application
ubhat 13:238b23d4025c 52 AppAcclSenet, // Senet + M2X application example
ubhat 13:238b23d4025c 53 AppAcclSensor, // Sensor XYZ data
ubhat 13:238b23d4025c 54 AppPushButton, // Push button application example
ubhat 0:69f2e28d12c1 55 };
ubhat 0:69f2e28d12c1 56
ubhat 0:69f2e28d12c1 57 /*!
ubhat 0:69f2e28d12c1 58 * Application
ubhat 0:69f2e28d12c1 59 */
ubhat 0:69f2e28d12c1 60 class Application
ubhat 0:69f2e28d12c1 61 {
ubhat 0:69f2e28d12c1 62 public:
ubhat 0:69f2e28d12c1 63 /*!
ubhat 0:69f2e28d12c1 64 * \brief Initializes TX buffer address to private pointer
ubhat 0:69f2e28d12c1 65 *
ubhat 0:69f2e28d12c1 66 * \param [IN] memptr pointer to TX buffer
ubhat 0:69f2e28d12c1 67 */
ubhat 0:69f2e28d12c1 68 Application( uint8_t * memptr );
ubhat 0:69f2e28d12c1 69
ubhat 0:69f2e28d12c1 70 /*!
ubhat 0:69f2e28d12c1 71 * \brief Application Destructor
ubhat 0:69f2e28d12c1 72 */
ubhat 0:69f2e28d12c1 73 ~Application( );
ubhat 0:69f2e28d12c1 74
ubhat 0:69f2e28d12c1 75 /*!
ubhat 0:69f2e28d12c1 76 * \brief Call application type and append to application buffer
ubhat 0:69f2e28d12c1 77 *
ubhat 0:69f2e28d12c1 78 * \param [IN] AppType application type: GPS, Battery, Temp etc.
ubhat 0:69f2e28d12c1 79 */
ubhat 0:69f2e28d12c1 80 void ApplicationCall( eAppType AppType );
ubhat 0:69f2e28d12c1 81
ubhat 0:69f2e28d12c1 82 /*!
ubhat 0:69f2e28d12c1 83 * \brief Append data to the TX buffer
ubhat 0:69f2e28d12c1 84 *
ubhat 0:69f2e28d12c1 85 * \param [IN] pData pointer to the data to be appended to TX buffer
ubhat 0:69f2e28d12c1 86 * \param [IN] Len lenght of the data to be appended to TX buffer
ubhat 0:69f2e28d12c1 87 */
ubhat 0:69f2e28d12c1 88 void ApplicationAppendData( uint8_t *pData, uint8_t len );
ubhat 0:69f2e28d12c1 89
ubhat 0:69f2e28d12c1 90 /*!
ubhat 0:69f2e28d12c1 91 * \brief Point the pointer corresponding to the TX buffer to specified index
ubhat 0:69f2e28d12c1 92 *
ubhat 0:69f2e28d12c1 93 * \param [IN] ptrPos index to where to point to in the TX buffer
ubhat 0:69f2e28d12c1 94 */
ubhat 0:69f2e28d12c1 95 void ApplicationPtrPos( uint8_t ptrPos );
ubhat 0:69f2e28d12c1 96
ubhat 0:69f2e28d12c1 97 private:
ubhat 0:69f2e28d12c1 98 /*!
ubhat 0:69f2e28d12c1 99 * Index to the application buffer
ubhat 0:69f2e28d12c1 100 */
ubhat 0:69f2e28d12c1 101 uint8_t BuffPtr;
ubhat 0:69f2e28d12c1 102 /*!
ubhat 0:69f2e28d12c1 103 * Application buffer address pointer
ubhat 0:69f2e28d12c1 104 */
ubhat 0:69f2e28d12c1 105 uint8_t *BuffAddr;
ubhat 0:69f2e28d12c1 106 };
ubhat 0:69f2e28d12c1 107
ubhat 0:69f2e28d12c1 108 class TimerLed
ubhat 0:69f2e28d12c1 109 {
ubhat 0:69f2e28d12c1 110 public:
ubhat 0:69f2e28d12c1 111 TimerEvent_t LedTimer;
ubhat 0:69f2e28d12c1 112 TimerLed( eLedType );
ubhat 0:69f2e28d12c1 113 ~TimerLed( );
ubhat 0:69f2e28d12c1 114 };
ubhat 0:69f2e28d12c1 115
ubhat 0:69f2e28d12c1 116 extern TimerLed RedLedTimer;
ubhat 0:69f2e28d12c1 117
ubhat 0:69f2e28d12c1 118 extern TimerLed YellowLedTimer;
ubhat 0:69f2e28d12c1 119
ubhat 0:69f2e28d12c1 120 extern TimerLed GreenLedTimer;
ubhat 0:69f2e28d12c1 121
ubhat 0:69f2e28d12c1 122 extern Application LoRaApp;
ubhat 0:69f2e28d12c1 123
ubhat 0:69f2e28d12c1 124 extern bool AppLed;
ubhat 0:69f2e28d12c1 125
ubhat 7:92f4f419f91f 126 extern bool VerticalStatus;
ubhat 7:92f4f419f91f 127
ubhat 0:69f2e28d12c1 128 /*!
ubhat 0:69f2e28d12c1 129 * \brief Blink LED
ubhat 0:69f2e28d12c1 130 *
ubhat 0:69f2e28d12c1 131 * \param [IN] led Red, yellow or green LED
ubhat 0:69f2e28d12c1 132 * \param [IN] time time in usec for which the LED must be ON
ubhat 0:69f2e28d12c1 133 */
ubhat 0:69f2e28d12c1 134 void BlinkLED( eLedType led, uint32_t time );
ubhat 0:69f2e28d12c1 135
ubhat 0:69f2e28d12c1 136 /*!
ubhat 0:69f2e28d12c1 137 * \brief Turn LED ON if OFF; OFF if ON
ubhat 0:69f2e28d12c1 138 *
ubhat 0:69f2e28d12c1 139 * \param [IN] led Red, yellow or green LED
ubhat 0:69f2e28d12c1 140 */
ubhat 0:69f2e28d12c1 141 void ToggleLED( eLedType led );
ubhat 0:69f2e28d12c1 142
ubhat 0:69f2e28d12c1 143 /*!
ubhat 0:69f2e28d12c1 144 * \brief Control the State of the LED
ubhat 0:69f2e28d12c1 145 *
ubhat 0:69f2e28d12c1 146 * \param [IN] led Red, yellow or green LED
ubhat 0:69f2e28d12c1 147 * \param [IN] state ON or OFF
ubhat 0:69f2e28d12c1 148 */
ubhat 0:69f2e28d12c1 149 void CtrlLED( eLedType led, uint8_t state );
ubhat 0:69f2e28d12c1 150
ubhat 7:92f4f419f91f 151 void CheckOrientation( void );
ubhat 7:92f4f419f91f 152
ubhat 0:69f2e28d12c1 153 #endif // __APPLICATION_H__