GDP group 24 node core
Dependencies: EthernetInterface SDFileSystem mbed-rtos mbed snail MbedJSONValue
Diff: main.cpp
- Revision:
- 25:fe273397ebb2
- Parent:
- 23:b57a47c7862a
- Child:
- 26:172b585fbb10
--- a/main.cpp Tue Jan 27 22:20:46 2015 +0000 +++ b/main.cpp Wed Jan 28 20:21:12 2015 +0000 @@ -29,6 +29,10 @@ queue<snail::sensordata> messageQueue; +//commissioning button +DigitalOut commissioningOutput(p30); +InterruptIn commissioningInput(p16); + string addressToString(char address[8]) { string address_str; @@ -199,6 +203,16 @@ networkParametersTimeout.detach(); } +void commissioningFall() +{ + commissioningOutput = 0; +} + +void commissioningRise() +{ + commissioningOutput = 1; +} + int main() { #ifdef DEBUG @@ -225,13 +239,15 @@ #endif sdcard sd = sdcard(); - //TODO: read basenode pin + //commissioning button + commissioningInput.fall(commissioningFall); + commissioningInput.rise(commissioningRise); + + //check if local node is basenode #ifdef DEBUG - pc.printf("[MAIN] Basenode switch: %i\r\n", isBasenode); + pc.printf("[MAIN] Basenode status: %i\r\n", isBasenode); #endif - //TODO: load configuration from SD - getLocalAddress(); if (isBasenode) @@ -268,8 +284,6 @@ { xbee.processIncomingData(); - //TODO: if message queue exceeds MAX_QUEUE SIZE, write older readings to SD card. - //if xbee is awake send contents of message queue if (xbee.isCTS()) { @@ -311,7 +325,6 @@ for (int i = 0; i < data.readings.size(); i++) readings[i] = data.readings[i]; - //TODO: Get real I2C address snail::sensordata message(baseNodeAddress, data.type, data.type, time(NULL), readings, data.readings.size()); messageQueue.push(message);