Test Fork

Dependencies:   LoRaWAN-lib SX1272Lib lib_gps lib_mma8451q lib_mpl3115a2 mbed

Fork of LoRaWAN-NAMote72-Application-Demo by Semtech

Committer:
ubhat
Date:
Tue May 17 00:21:55 2016 +0000
Revision:
0:69f2e28d12c1
Child:
6:f8194e691dd4
Project for LoRa Bootcamp

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 0:69f2e28d12c1 47 AppTemp = 1, // Temperature measurement application
ubhat 0:69f2e28d12c1 48 AppBat = 2, // Battery measurement application
ubhat 0:69f2e28d12c1 49 AppRamp = 3, // Generate Ramp bytes
ubhat 0:69f2e28d12c1 50 AppAccl = 4, // Accelerometer application
ubhat 0:69f2e28d12c1 51 AppAcclSenet = 5, // Senet + M2X application example
ubhat 0:69f2e28d12c1 52 };
ubhat 0:69f2e28d12c1 53
ubhat 0:69f2e28d12c1 54 /*!
ubhat 0:69f2e28d12c1 55 * Application
ubhat 0:69f2e28d12c1 56 */
ubhat 0:69f2e28d12c1 57 class Application
ubhat 0:69f2e28d12c1 58 {
ubhat 0:69f2e28d12c1 59 public:
ubhat 0:69f2e28d12c1 60 /*!
ubhat 0:69f2e28d12c1 61 * \brief Initializes TX buffer address to private pointer
ubhat 0:69f2e28d12c1 62 *
ubhat 0:69f2e28d12c1 63 * \param [IN] memptr pointer to TX buffer
ubhat 0:69f2e28d12c1 64 */
ubhat 0:69f2e28d12c1 65 Application( uint8_t * memptr );
ubhat 0:69f2e28d12c1 66
ubhat 0:69f2e28d12c1 67 /*!
ubhat 0:69f2e28d12c1 68 * \brief Application Destructor
ubhat 0:69f2e28d12c1 69 */
ubhat 0:69f2e28d12c1 70 ~Application( );
ubhat 0:69f2e28d12c1 71
ubhat 0:69f2e28d12c1 72 /*!
ubhat 0:69f2e28d12c1 73 * \brief Call application type and append to application buffer
ubhat 0:69f2e28d12c1 74 *
ubhat 0:69f2e28d12c1 75 * \param [IN] AppType application type: GPS, Battery, Temp etc.
ubhat 0:69f2e28d12c1 76 */
ubhat 0:69f2e28d12c1 77 void ApplicationCall( eAppType AppType );
ubhat 0:69f2e28d12c1 78
ubhat 0:69f2e28d12c1 79 /*!
ubhat 0:69f2e28d12c1 80 * \brief Append data to the TX buffer
ubhat 0:69f2e28d12c1 81 *
ubhat 0:69f2e28d12c1 82 * \param [IN] pData pointer to the data to be appended to TX buffer
ubhat 0:69f2e28d12c1 83 * \param [IN] Len lenght of the data to be appended to TX buffer
ubhat 0:69f2e28d12c1 84 */
ubhat 0:69f2e28d12c1 85 void ApplicationAppendData( uint8_t *pData, uint8_t len );
ubhat 0:69f2e28d12c1 86
ubhat 0:69f2e28d12c1 87 /*!
ubhat 0:69f2e28d12c1 88 * \brief Point the pointer corresponding to the TX buffer to specified index
ubhat 0:69f2e28d12c1 89 *
ubhat 0:69f2e28d12c1 90 * \param [IN] ptrPos index to where to point to in the TX buffer
ubhat 0:69f2e28d12c1 91 */
ubhat 0:69f2e28d12c1 92 void ApplicationPtrPos( uint8_t ptrPos );
ubhat 0:69f2e28d12c1 93
ubhat 0:69f2e28d12c1 94 private:
ubhat 0:69f2e28d12c1 95 /*!
ubhat 0:69f2e28d12c1 96 * Index to the application buffer
ubhat 0:69f2e28d12c1 97 */
ubhat 0:69f2e28d12c1 98 uint8_t BuffPtr;
ubhat 0:69f2e28d12c1 99 /*!
ubhat 0:69f2e28d12c1 100 * Application buffer address pointer
ubhat 0:69f2e28d12c1 101 */
ubhat 0:69f2e28d12c1 102 uint8_t *BuffAddr;
ubhat 0:69f2e28d12c1 103 };
ubhat 0:69f2e28d12c1 104
ubhat 0:69f2e28d12c1 105 class TimerLed
ubhat 0:69f2e28d12c1 106 {
ubhat 0:69f2e28d12c1 107 public:
ubhat 0:69f2e28d12c1 108 TimerEvent_t LedTimer;
ubhat 0:69f2e28d12c1 109 TimerLed( eLedType );
ubhat 0:69f2e28d12c1 110 ~TimerLed( );
ubhat 0:69f2e28d12c1 111 };
ubhat 0:69f2e28d12c1 112
ubhat 0:69f2e28d12c1 113 extern TimerLed RedLedTimer;
ubhat 0:69f2e28d12c1 114
ubhat 0:69f2e28d12c1 115 extern TimerLed YellowLedTimer;
ubhat 0:69f2e28d12c1 116
ubhat 0:69f2e28d12c1 117 extern TimerLed GreenLedTimer;
ubhat 0:69f2e28d12c1 118
ubhat 0:69f2e28d12c1 119 extern Application LoRaApp;
ubhat 0:69f2e28d12c1 120
ubhat 0:69f2e28d12c1 121 extern bool AppLed;
ubhat 0:69f2e28d12c1 122
ubhat 0:69f2e28d12c1 123 /*!
ubhat 0:69f2e28d12c1 124 * \brief Blink LED
ubhat 0:69f2e28d12c1 125 *
ubhat 0:69f2e28d12c1 126 * \param [IN] led Red, yellow or green LED
ubhat 0:69f2e28d12c1 127 * \param [IN] time time in usec for which the LED must be ON
ubhat 0:69f2e28d12c1 128 */
ubhat 0:69f2e28d12c1 129 void BlinkLED( eLedType led, uint32_t time );
ubhat 0:69f2e28d12c1 130
ubhat 0:69f2e28d12c1 131 /*!
ubhat 0:69f2e28d12c1 132 * \brief Turn LED ON if OFF; OFF if ON
ubhat 0:69f2e28d12c1 133 *
ubhat 0:69f2e28d12c1 134 * \param [IN] led Red, yellow or green LED
ubhat 0:69f2e28d12c1 135 */
ubhat 0:69f2e28d12c1 136 void ToggleLED( eLedType led );
ubhat 0:69f2e28d12c1 137
ubhat 0:69f2e28d12c1 138 /*!
ubhat 0:69f2e28d12c1 139 * \brief Control the State of the LED
ubhat 0:69f2e28d12c1 140 *
ubhat 0:69f2e28d12c1 141 * \param [IN] led Red, yellow or green LED
ubhat 0:69f2e28d12c1 142 * \param [IN] state ON or OFF
ubhat 0:69f2e28d12c1 143 */
ubhat 0:69f2e28d12c1 144 void CtrlLED( eLedType led, uint8_t state );
ubhat 0:69f2e28d12c1 145
ubhat 0:69f2e28d12c1 146 #endif // __APPLICATION_H__