![](/media/cache/profiles/2dd26bee3d25f4e22c3db125e415203a.jpg.50x50_q85.jpg)
This program connects to the The Things Network backend in OTAA Mode. It logs sensor values from a BME 280 to the backend. Tried adding support for Grove GPS using SerialGPS library but it is not working - conflicting with mbed-rtos, so it commented. Deep Sleep for mDot implemented BUT avoiding reprogramming of the mDot config is NOT working.
Dependencies: BME280 SerialGPS libmDot mbed-rtos mbed
main.cpp@0:3ec6a7645098, 2016-07-03 (annotated)
- Committer:
- AshuJoshi
- Date:
- Sun Jul 03 15:45:03 2016 +0000
- Revision:
- 0:3ec6a7645098
- Child:
- 1:36e336869699
Basic Hello World on mDot UDK
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AshuJoshi | 0:3ec6a7645098 | 1 | /****************************************************** |
AshuJoshi | 0:3ec6a7645098 | 2 | * A Program to interface the Grove Base Shielf V2 |
AshuJoshi | 0:3ec6a7645098 | 3 | * to the mDot UDK. |
AshuJoshi | 0:3ec6a7645098 | 4 | * Additionally sample code to compress the data |
AshuJoshi | 0:3ec6a7645098 | 5 | * for use with LPWANs such as LoRa |
AshuJoshi | 0:3ec6a7645098 | 6 | *****************************************************/ |
AshuJoshi | 0:3ec6a7645098 | 7 | |
AshuJoshi | 0:3ec6a7645098 | 8 | #include "mbed.h" |
AshuJoshi | 0:3ec6a7645098 | 9 | #include <math.h> |
AshuJoshi | 0:3ec6a7645098 | 10 | |
AshuJoshi | 0:3ec6a7645098 | 11 | // UDK Specific |
AshuJoshi | 0:3ec6a7645098 | 12 | // Uncomment this line if using a full sized UDK2.0 instead of a Micro UDK |
AshuJoshi | 0:3ec6a7645098 | 13 | #define UDK2 1 |
AshuJoshi | 0:3ec6a7645098 | 14 | #ifdef UDK2 |
AshuJoshi | 0:3ec6a7645098 | 15 | DigitalOut led(LED1); |
AshuJoshi | 0:3ec6a7645098 | 16 | #else |
AshuJoshi | 0:3ec6a7645098 | 17 | DigitalOut led(XBEE_RSSI); |
AshuJoshi | 0:3ec6a7645098 | 18 | #endif |
AshuJoshi | 0:3ec6a7645098 | 19 | |
AshuJoshi | 0:3ec6a7645098 | 20 | // Globals |
AshuJoshi | 0:3ec6a7645098 | 21 | Ticker tick; |
AshuJoshi | 0:3ec6a7645098 | 22 | |
AshuJoshi | 0:3ec6a7645098 | 23 | // Function Declarations |
AshuJoshi | 0:3ec6a7645098 | 24 | void endLessTestLoop(); |
AshuJoshi | 0:3ec6a7645098 | 25 | void setUpLEDBlink(); |
AshuJoshi | 0:3ec6a7645098 | 26 | void blink(); |
AshuJoshi | 0:3ec6a7645098 | 27 | |
AshuJoshi | 0:3ec6a7645098 | 28 | |
AshuJoshi | 0:3ec6a7645098 | 29 | /***************************************************** |
AshuJoshi | 0:3ec6a7645098 | 30 | * MAIN |
AshuJoshi | 0:3ec6a7645098 | 31 | *****************************************************/ |
AshuJoshi | 0:3ec6a7645098 | 32 | int main(){ |
AshuJoshi | 0:3ec6a7645098 | 33 | |
AshuJoshi | 0:3ec6a7645098 | 34 | // Simple Test Functions, "Hello World on UDK |
AshuJoshi | 0:3ec6a7645098 | 35 | setUpLEDBlink(); |
AshuJoshi | 0:3ec6a7645098 | 36 | endLessTestLoop(); |
AshuJoshi | 0:3ec6a7645098 | 37 | |
AshuJoshi | 0:3ec6a7645098 | 38 | return 0; |
AshuJoshi | 0:3ec6a7645098 | 39 | } |
AshuJoshi | 0:3ec6a7645098 | 40 | |
AshuJoshi | 0:3ec6a7645098 | 41 | |
AshuJoshi | 0:3ec6a7645098 | 42 | |
AshuJoshi | 0:3ec6a7645098 | 43 | |
AshuJoshi | 0:3ec6a7645098 | 44 | |
AshuJoshi | 0:3ec6a7645098 | 45 | |
AshuJoshi | 0:3ec6a7645098 | 46 | |
AshuJoshi | 0:3ec6a7645098 | 47 | |
AshuJoshi | 0:3ec6a7645098 | 48 | |
AshuJoshi | 0:3ec6a7645098 | 49 | /***************************************************** |
AshuJoshi | 0:3ec6a7645098 | 50 | * FUNCTIONS for Simple Testing |
AshuJoshi | 0:3ec6a7645098 | 51 | *****************************************************/ |
AshuJoshi | 0:3ec6a7645098 | 52 | |
AshuJoshi | 0:3ec6a7645098 | 53 | void setUpLEDBlink(){ |
AshuJoshi | 0:3ec6a7645098 | 54 | // configure the Ticker to blink the LED on 500ms interval |
AshuJoshi | 0:3ec6a7645098 | 55 | tick.attach(&blink, 0.5); |
AshuJoshi | 0:3ec6a7645098 | 56 | } |
AshuJoshi | 0:3ec6a7645098 | 57 | |
AshuJoshi | 0:3ec6a7645098 | 58 | void endLessTestLoop() { |
AshuJoshi | 0:3ec6a7645098 | 59 | while(true) { |
AshuJoshi | 0:3ec6a7645098 | 60 | printf("Hello world!\r\n"); |
AshuJoshi | 0:3ec6a7645098 | 61 | wait(3); |
AshuJoshi | 0:3ec6a7645098 | 62 | } |
AshuJoshi | 0:3ec6a7645098 | 63 | } |
AshuJoshi | 0:3ec6a7645098 | 64 | |
AshuJoshi | 0:3ec6a7645098 | 65 | // Callback function to change LED state |
AshuJoshi | 0:3ec6a7645098 | 66 | void blink() { |
AshuJoshi | 0:3ec6a7645098 | 67 | led = !led; |
AshuJoshi | 0:3ec6a7645098 | 68 | } |