diff --git a/Project/applications/smartcities/logger/logger b/Project/applications/smartcities/logger/logger new file mode 100755 index 0000000..f22d235 --- /dev/null +++ b/Project/applications/smartcities/logger/logger diff --git a/Project/applications/smartcities/logger/logger.cpp b/Project/applications/smartcities/logger/logger.cpp new file mode 100644 index 0000000..e2d38ff --- /dev/null +++ b/Project/applications/smartcities/logger/logger.cpp @@ -0,0 +1,41 @@ +#include +#include +#include + +using namespace std; + +string getName(string path) +{ + int pos = path.find_last_of("/"); + return path.substr(pos+1); +} + +int main(int argc, char **argv) +{ + if(argc != 2) + { + cout << "Bad usage" << endl << endl << "Example: " << argv[0] << " " << endl; + exit(1); + } + + string target = argv[1]; + cout << "Reading from " << target << "..." << endl; + + ifstream input; + ofstream output; + + input.open(target.c_str(), ifstream::in); + output.open(getName(target).append(".log").c_str(), ofstream::out); + + string line = ""; + + while(!input.eof()) + { + getline(input,line); + if(line != "") + { + cout << line << endl; + output << line << endl; + } + } +} diff --git a/Project/applications/smartcities/logger/ttyS0.log b/Project/applications/smartcities/logger/ttyS0.log new file mode 100644 index 0000000..44cdb64 --- /dev/null +++ b/Project/applications/smartcities/logger/ttyS0.log @@ -0,0 +1,211 @@ +main.c: --------------WI-SENSE STARTED------------- +main.c: Connecting wifi... +main.c: SSID = SERVER_WLAN +main.c: Wep key = TGW2YHNKT9TW +main.c: Passphrase = TGW2YHNKT9TW +main.c: User = +main.c: Password = +main.c: Encryption type = 4 +main.c: Geo Localization = 41.557255 2.096183 +main.c: WPA network detected +callbacks.c: WiFi Connect indication: Connected +Connected to: 00:26:5B:D9:0D:18 +callbacks.c: IP: 192.168.0.47 +buffer.c: Checking available memory... +buffer.c: Available memory: 33320 B +buffer.c: Used memory: 1384 B +sensors.c: Waking up sensors... +sensors.c: Woken Pin 3 +sensors.c: Woken Pin 4 +sensors.c: Woken Pin 5 +sensors.c: Woken Pin 6 +sensors.c: Woken Pin 7 +json.c: Registering sensor: Light sensor +json.c: Server is lewis.upc.es +httpClient.c: Checking params +httpClient.c: Calculating header size +httpClient.c: Building request head +httpClient.c: Adding content to request string +httpClient.c: Packet: + +PUT /modularsense/wordpress/opendata/catalog/register HTTP/1.1 +Host: 147.83.39.240 +Content-Type: application/json; charset=UTF-8 +Content-Length: 131 + +{"sensors":[{"sensor":"00000139","description":"Light sensor","type":"illumination","unit":"lux","location":"41.557255 2.096183"}]} + +httpClient.c: Setting connection +httpClient.c: Establishing connection +httpClient.c: Sending request +httpClient.c: Write returned: 0 +httpClient.c: Waiting for response +httpClient.c: Receive returned: 0 +httpClient.c: Response received. Let's parse the information +httpClient.c: Response code: 200 +json.c: Success: JSON_POST_OK +json.c: Registering sensor: Pressure sensor +json.c: Putting additional info for pressure sensor... +sensors.c: [PRESSURE] Fetching callibration data +sensors.c: [PRESSURE] Got callibration data +json.c: callibration_data is: 7453,64557,51006,32123,24742,20239,5498,49,32768,54461,2432 +json.c: In prepare_json_register_statement: Detected additional_info +json.c: Server is lewis.upc.es +httpClient.c: Checking params +httpClient.c: Calculating header size +httpClient.c: Building request head +httpClient.c: Adding content to request string +httpClient.c: Packet: + +PUT /modularsense/wordpress/opendata/catalog/register HTTP/1.1 +Host: 147.83.39.240 +Content-Type: application/json; charset=UTF-8 +Content-Length: 209 + +{"sensors":[{"sensor":"00000177","description":"Pressure sensor","type":"pressure","unit":"hPa","location":"41.557255 2.096183","additionalInfo":"7453,64557,51006,32123,24742,20239,5498,49,32768,54461,2432"}]} + +httpClient.c: Setting connection +httpClient.c: Establishing connection +httpClient.c: Sending request +httpClient.c: Write returned: 0 +httpClient.c: Waiting for response +httpClient.c: Receive returned: 0 +httpClient.c: Response received. Let's parse the information +httpClient.c: Response code: 200 +json.c: Success: JSON_POST_OK +json.c: Registering sensor: Temperature and humidity sensor +json.c: Server is lewis.upc.es +httpClient.c: Checking params +httpClient.c: Calculating header size +httpClient.c: Building request head +httpClient.c: Adding content to request string +httpClient.c: Packet: + +PUT /modularsense/wordpress/opendata/catalog/register HTTP/1.1 +Host: 147.83.39.240 +Content-Type: application/json; charset=UTF-8 +Content-Length: 161 + +{"sensors":[{"sensor":"00000127","description":"Temperature and humidity sensor","type":"temperature,humidity","unit":"ÂșC,RH","location":"41.557255 2.096183"}]} + +httpClient.c: Setting connection +httpClient.c: Establishing connection +httpClient.c: Sending request +httpClient.c: Write returned: 0 +httpClient.c: Waiting for response +httpClient.c: Receive returned: 0 +httpClient.c: Response received. Let's parse the information +httpClient.c: Response code: 200 +json.c: Success: JSON_POST_OK +json.c: Registering sensor: Battery Level +json.c: Server is lewis.upc.es +httpClient.c: Checking params +httpClient.c: Calculating header size +httpClient.c: Building request head +httpClient.c: Adding content to request string +httpClient.c: Packet: + +PUT /modularsense/wordpress/opendata/catalog/register HTTP/1.1 +Host: 147.83.39.240 +Content-Type: application/json; charset=UTF-8 +Content-Length: 124 + +{"sensors":[{"sensor":"00000100","description":"Battery Level","type":"power","unit":"mV","location":"41.557255 2.096183"}]} + +httpClient.c: Setting connection +httpClient.c: Establishing connection +httpClient.c: Sending request +httpClient.c: Write returned: 0 +httpClient.c: Waiting for response +httpClient.c: Receive returned: 0 +httpClient.c: Response received. Let's parse the information +httpClient.c: Response code: 200 +json.c: Success: JSON_POST_OK +main.c: 3 sensor detected... +main.c: Requesting new NTP time... +ntp.c: Successfully got new time +ntp.c: Received timestamp 3611016270 +main.c: Updating new time to 3611016270 +main.c: Time updated +main.c: Disconnecting wifi... +main.c: Disconnecting Successful: WIFI_DISCONNECT_SUCCESS +timer-loop.c: Time to sleep! for 30 seconds +callbacks.c: WiFi Connect indication: Failed +main.c: Time (absolute): 3611016300 +Time LONG_PERIOD: 0 +Time SHORT_PERIOD: 0 +sensors.c: Collecting data... +sensors.c: Not freeing memory on index 0 +sensors.c: Fetching data from light sensor +sensors.c: [LIGHT] Sent power on command +sensors.c: [LIGHT] Sent start conversion command +sensors.c: [LIGHT] Sent stop conversion command +sensors.c: [LIGHT] Sent fetch command for CH1 +sensors.c: [LIGHT] Got low byte for CH1 +sensors.c: [LIGHT] Got high byte for CH1 +sensors.c: [LIGHT] Got ch1 +sensors.c: [LIGHT] Sent fetch command for CH0 +sensors.c: [LIGHT] Got low byte for CH0 +sensors.c: [LIGHT] Got high byte for CH0 +sensors.c: [LIGHT] Got ch0 +sensors.c: [LIGHT] CH1 = 0B +sensors.c: [LIGHT] CH0 = 74 +sensors.c: Not freeing memory on index 1 +sensors.c: Fetching data from pressure sensor +sensors.c: [PRESSURE] Initialized +sensors.c: [PRESSURE] Got high byte +sensors.c: [PRESSURE] Got low byte +sensors.c: [PRESSURE] Initialized temperature +sensors.c: [PRESSURE] Got temperature high byte +sensors.c: [PRESSURE] Got temperature low byte +sensors.c: Not freeing memory on index 2 +sensors.c: Fetching data from humidity and temperature sensor +sensors.c: [HUMIDITY_TEMP] Initializing sensor +sensors.c: [HUMIDITY_TEMP] Initialized temperature +sensors.c: [HUMIDITY_TEMP] Discarded first humidity byte +sensors.c: [HUMIDITY_TEMP] Discarded second humidity byte +sensors.c: [HUMIDITY_TEMP] Got temperature high byte +sensors.c: [HUMIDITY_TEMP] Got temperature low byte +sensors.c: [HUMIDITY_TEMP] Initializing sensor +sensors.c: [HUMIDITY_TEMP] Initialized humidity +sensors.c: [HUMIDITY_TEMP] Got humidity high byte +sensors.c: [HUMIDITY_TEMP] Got humidity low byte +sensors.c: Data collected +main.c: Time (absolute): 3611016301 +Time LONG_PERIOD: 3 +Time SHORT_PERIOD: 1 +main.c: Timestamp (absolute): 3611016301 +Timestamp LONG_PERIOD: 3 +Timestamp SHORT_PERIOD: 1 +main.c: Timestamping data... +ntp.c: Writing timestamp... +main.c: Data is: 721012,6/6/2014T6:5:1 +ntp.c: Writing timestamp... +main.c: Data is: 39192,28949,6/6/2014T6:5:1 +ntp.c: Writing timestamp... +main.c: Data is: 6466,9197,6/6/2014T6:5:1 +main.c: Returning timestamped data... +main.c: Putting data in buffers... +main.c: Putting data: 721012,6/6/2014T6:5:1 + buffer.c: Joining buffer... +buffer.c: Data copied +main.c: Message put: 721012,6/6/2014T6:5:1 +main.c: Memory freed + main.c: Putting data: 39192,28949,6/6/2014T6:5:1 + buffer.c: Joining buffer... +buffer.c: Data copied +main.c: Message put: 39192,28949,6/6/2014T6:5:1 +main.c: Memory freed + main.c: Putting data: 6466,9197,6/6/2014T6:5:1 + buffer.c: Joining buffer... +buffer.c: Data copied +main.c: Message put: 6466,9197,6/6/2014T6:5:1 +main.c: Memory freed + main.c: Data is now in buffer + buffer.c: Checking available memory... +buffer.c: Available memory: 33560 B +buffer.c: Used memory: 1144 B +main.c: Time (absolute): 3611016301 +Time LONG_PERIOD: 3 +Time SHORT_PERIOD: 1 +timer-loop.c: Time to sleep! for 59 seconds