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
Diff: main.cpp
- Revision:
- 7:9e2454b0318a
- Parent:
- 6:35f934e83c74
- Child:
- 8:c17b68b03791
--- a/main.cpp Fri Jul 08 03:00:43 2016 +0000
+++ b/main.cpp Fri Jul 08 03:09:14 2016 +0000
@@ -11,7 +11,7 @@
#include "MTSText.h"
#include <string>
- //#include "BME280.h"
+ #include "BME280.h"
//#include "SerialGPS.h"
using namespace mts;
@@ -62,7 +62,7 @@
//SerialGPS gps(PA_2, PA_3);
//BME280 sensor(I2C_SDA, I2C_SCL)
// MDot UDK - I2C_SDA and I2C_SCL connected to PC_9/PA_*
-//BME280 b280(PC_9, PA_8);
+BME280 b280(PC_9, PA_8);
// Serial via USB for debugging only
//Serial pc(USBTX,USBRX);
@@ -71,7 +71,7 @@
void endLessTestLoop();
void setUpLEDBlink();
void blink();
-//void readandprintBME280();
+void readandprintBME280();
void mDotConfig();
void mDotGotoDeepSleep(int seconds);
void mDotConfigPrint();
@@ -90,11 +90,10 @@
// Simple Test Functions, "Hello World on UDK
setUpLEDBlink();
- //mDotConfig();
+ mDotConfig();
setupNetwork();
- //mDotConfigPrint();
//wait(15);
- // joinNetwork();
+ joinNetwork();
endLessTestLoop();
return 0;
@@ -136,15 +135,15 @@
std::vector<uint8_t> appKey;
// get a mDot handle
- dot = mDot::getInstance();
+ // dot = mDot::getInstance();
//*******************************************
// configuration
//*******************************************
//dot->setLogLevel(mts::MTSLog::INFO_LEVEL);
- dot->setLogLevel(mts::MTSLog::TRACE_LEVEL);
- logInfo("Checking Config");
+ //dot->setLogLevel(mts::MTSLog::TRACE_LEVEL);
+ //logInfo("Checking Config");
// Test if we've already saved the config
std::string configNetworkName = dot->getNetworkName();
@@ -253,7 +252,13 @@
//char dataBuf[50];
- //int32_t ret;
+
+
+
+}
+
+void joinNetwork() {
+ int32_t ret;
logInfo("Joining Network");
while ((ret = dot->joinNetwork()) != mDot::MDOT_OK) {
@@ -264,7 +269,6 @@
logInfo("Joined Network");
wait(10);
-
}
@@ -333,7 +337,7 @@
* Sensor Functions
****************************************************/
-/*
+
void readandprintBME280() {
float temperature;
float pressure;
@@ -360,7 +364,7 @@
//printf("%2.2f degC, %04.2f hPa, %2.2f %%\n", temperature, pressure, humidity);
}
-*/
+
/*****************************************************
@@ -375,8 +379,8 @@
void endLessTestLoop() {
while(true) {
// printf("Hello world!\r\n");
- printf("BME280 Sensor: \n");
- //readandprintBME280();
+ //printf("BME280 Sensor: \n");
+ readandprintBME280();
wait(5);
//mDotGotoDeepSleep(60);