mQ Branch for NA mote testing

Dependencies:   LoRaWAN-lib SX1272Lib-mQ lib_gps lib_mma8451q lib_mpl3115a2 mbed

Fork of LoRaWAN-NAMote72-Application-Demo by Semtech

Committer:
mluis
Date:
Mon Apr 24 13:47:27 2017 +0000
Revision:
18:18408c3c2d0c
Parent:
13:6b6f4be13633
WARNING: Radio API timings changed from micro-seconds to milliseconds; ; Synchronized with https://github.com/Lora-net/LoRaMac-node git revision e506c246652fa44c3f24cecb89d0707b49ece739; Updated all libraries to the latest versions

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