Official reference client implementation for Cumulocity SmartREST on u-blox C027.
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Revision 20:ef9cc1b42e9d, committed 2014-02-20
- Comitter:
- vwochnik
- Date:
- Thu Feb 20 11:51:54 2014 +0000
- Parent:
- 19:7bee744fe527
- Child:
- 21:f74b80a0cb38
- Commit message:
- fix
Changed in this revision
--- a/io.cpp Tue Feb 18 17:17:48 2014 +0000 +++ b/io.cpp Thu Feb 20 11:51:54 2014 +0000 @@ -28,6 +28,8 @@ puts("Temperature sensor not found."); if (!accFound) puts("Accelerometer not found."); + + lcdDisplay.cls(); } float temperature() @@ -67,6 +69,27 @@ } } +void lcd_signal(int8_t rssi, uint8_t ber) +{ + lcdDisplay.locate(0, 0); + if ((rssi == 0) && (ber == 0)) + lcdDisplay.printf("No signal\n"); + else + lcdDisplay.printf("RSSI: %d dBm BER: %d %%\n", rssi, ber); +} + +void lcd_tenant(const char* tenant) +{ + lcdDisplay.locate(0, 11); + lcdDisplay.printf("Tenant: %s\n", tenant); +} + +void lcd_status(const char* status) +{ + lcdDisplay.locate(0, 22); + lcdDisplay.printf("%s\n", status); +} + void timer_callback(void const*) { if ((!btnPressed) && (button))
--- a/io.h Tue Feb 18 17:17:48 2014 +0000 +++ b/io.h Thu Feb 20 11:51:54 2014 +0000 @@ -16,5 +16,8 @@ acceleration_t acceleration(); uint32_t counter(); double potentiometer(uint8_t n); +void lcd_signal(int8_t rssi, uint8_t ber); +void lcd_tenant(const char* tenant); +void lcd_status(const char* status); #endif \ No newline at end of file
--- a/main.cpp Tue Feb 18 17:17:48 2014 +0000 +++ b/main.cpp Thu Feb 20 11:51:54 2014 +0000 @@ -122,6 +122,8 @@ ATResultBuffer buffer; sigQ.rssi = 0; sigQ.ber = 0; + + lcd_signal(0, 0); if (cmdIface == NULL) return &sigQ; @@ -150,6 +152,8 @@ case 7: sigQ.ber = 7; break; default: sigQ.ber = 0; } + + lcd_signal(sigQ.rssi, sigQ.ber); return &sigQ; }
--- a/program.cpp Tue Feb 18 17:17:48 2014 +0000 +++ b/program.cpp Thu Feb 20 11:51:54 2014 +0000 @@ -57,25 +57,25 @@ { long deviceId = 0; Timer timer; + lcd_tenant("vaillant"); puts("Hello!"); puts("Bootstrapping"); + lcd_status("Bootstrapping"); if (client.bootstrap(srtpl) != SMARTREST_SUCCESS) { puts("Bootstrapping failed."); + lcd_status("Bootstrapping failed."); return 2; } puts("Starting action..."); if ((deviceId = existing()) == 0) { - deviceId = create(); - if (deviceId == 0) + if (((deviceId = create()) == 0) || (!identify(deviceId))) { + lcd_status("Device creation failed."); return 1; - if (!identify(deviceId)) - return 2; + } } - //if (!update(deviceId)) - // return 3; update(deviceId); printf("Device ID: %ld\r\n", deviceId); @@ -85,6 +85,7 @@ timer.reset(); loop(deviceId); + lcd_status("Sleeping..."); // block remaining number of seconds while (timer.read() < interval) { Thread::yield(); @@ -97,6 +98,7 @@ ComposedRecord newMoRec(true); // set copy=true b/c tmp objects ParsedRecord received; + lcd_status("Checking device existance..."); puts("Checking for device existance..."); newMoRec.add(IntegerValue(100)).add(CharValue(imei())); @@ -139,6 +141,7 @@ ComposedRecord newMoRec(true); // set copy=true b/c tmp objects ParsedRecord received; + lcd_status("Creating device..."); puts("Creating device..."); newMoRec.add(IntegerValue(101)).add(CharValue(imei())); @@ -213,6 +216,7 @@ ComposedRecord newMoRec(true); // set copy=true b/c tmp objects ParsedRecord received; + lcd_status("Updating device object..."); puts("Updating device data..."); newMoRec.add(IntegerValue(103)).add(IntegerValue(deviceId)).add(CharValue(imei())).add(CharValue(cellId())).add(CharValue(iccid())); @@ -250,6 +254,7 @@ { Aggregator aggr(5, false, true); + lcd_status("Sending measurements..."); signalMeasurement(deviceId, aggr); if (client.send(aggr) != SMARTREST_SUCCESS) { puts("Send failed.");