Commit 6ec7a46d6179d1c68a9ea8c6d348a9a504f7a5b5

Authored by Imanol-Mikel Barba Sabariego
1 parent 36268163

--no commit message

Project/applications/smartcities/logger/logger 0 โ†’ 100755
No preview for this file type
Project/applications/smartcities/logger/logger.cpp 0 โ†’ 100644
  1 +#include <iostream>
  2 +#include <fstream>
  3 +#include <cstdlib>
  4 +
  5 +using namespace std;
  6 +
  7 +string getName(string path)
  8 +{
  9 + int pos = path.find_last_of("/");
  10 + return path.substr(pos+1);
  11 +}
  12 +
  13 +int main(int argc, char **argv)
  14 +{
  15 + if(argc != 2)
  16 + {
  17 + cout << "Bad usage" << endl << endl << "Example: " << argv[0] << " <file or stream>" << endl;
  18 + exit(1);
  19 + }
  20 +
  21 + string target = argv[1];
  22 + cout << "Reading from " << target << "..." << endl;
  23 +
  24 + ifstream input;
  25 + ofstream output;
  26 +
  27 + input.open(target.c_str(), ifstream::in);
  28 + output.open(getName(target).append(".log").c_str(), ofstream::out);
  29 +
  30 + string line = "";
  31 +
  32 + while(!input.eof())
  33 + {
  34 + getline(input,line);
  35 + if(line != "")
  36 + {
  37 + cout << line << endl;
  38 + output << line << endl;
  39 + }
  40 + }
  41 +}
... ...
Project/applications/smartcities/logger/ttyS0.log 0 โ†’ 100644
  1 +main.c: --------------WI-SENSE STARTED-------------
  2 +main.c: Connecting wifi...
  3 +main.c: SSID = SERVER_WLAN
  4 +main.c: Wep key = TGW2YHNKT9TW
  5 +main.c: Passphrase = TGW2YHNKT9TW
  6 +main.c: User =
  7 +main.c: Password =
  8 +main.c: Encryption type = 4
  9 +main.c: Geo Localization = 41.557255 2.096183
  10 +main.c: WPA network detected
  11 +callbacks.c: WiFi Connect indication: Connected
  12 +Connected to: 00:26:5B:D9:0D:18
  13 +callbacks.c: IP: 192.168.0.47
  14 +buffer.c: Checking available memory...
  15 +buffer.c: Available memory: 33320 B
  16 +buffer.c: Used memory: 1384 B
  17 +sensors.c: Waking up sensors...
  18 +sensors.c: Woken Pin 3
  19 +sensors.c: Woken Pin 4
  20 +sensors.c: Woken Pin 5
  21 +sensors.c: Woken Pin 6
  22 +sensors.c: Woken Pin 7
  23 +json.c: Registering sensor: Light sensor
  24 +json.c: Server is lewis.upc.es
  25 +httpClient.c: Checking params
  26 +httpClient.c: Calculating header size
  27 +httpClient.c: Building request head
  28 +httpClient.c: Adding content to request string
  29 +httpClient.c: Packet:
  30 +
  31 +PUT /modularsense/wordpress/opendata/catalog/register HTTP/1.1
  32 +Host: 147.83.39.240
  33 +Content-Type: application/json; charset=UTF-8
  34 +Content-Length: 131
  35 +
  36 +{"sensors":[{"sensor":"00000139","description":"Light sensor","type":"illumination","unit":"lux","location":"41.557255 2.096183"}]}
  37 +
  38 +httpClient.c: Setting connection
  39 +httpClient.c: Establishing connection
  40 +httpClient.c: Sending request
  41 +httpClient.c: Write returned: 0
  42 +httpClient.c: Waiting for response
  43 +httpClient.c: Receive returned: 0
  44 +httpClient.c: Response received. Let's parse the information
  45 +httpClient.c: Response code: 200
  46 +json.c: Success: JSON_POST_OK
  47 +json.c: Registering sensor: Pressure sensor
  48 +json.c: Putting additional info for pressure sensor...
  49 +sensors.c: [PRESSURE] Fetching callibration data
  50 +sensors.c: [PRESSURE] Got callibration data
  51 +json.c: callibration_data is: 7453,64557,51006,32123,24742,20239,5498,49,32768,54461,2432
  52 +json.c: In prepare_json_register_statement: Detected additional_info
  53 +json.c: Server is lewis.upc.es
  54 +httpClient.c: Checking params
  55 +httpClient.c: Calculating header size
  56 +httpClient.c: Building request head
  57 +httpClient.c: Adding content to request string
  58 +httpClient.c: Packet:
  59 +
  60 +PUT /modularsense/wordpress/opendata/catalog/register HTTP/1.1
  61 +Host: 147.83.39.240
  62 +Content-Type: application/json; charset=UTF-8
  63 +Content-Length: 209
  64 +
  65 +{"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"}]}
  66 +
  67 +httpClient.c: Setting connection
  68 +httpClient.c: Establishing connection
  69 +httpClient.c: Sending request
  70 +httpClient.c: Write returned: 0
  71 +httpClient.c: Waiting for response
  72 +httpClient.c: Receive returned: 0
  73 +httpClient.c: Response received. Let's parse the information
  74 +httpClient.c: Response code: 200
  75 +json.c: Success: JSON_POST_OK
  76 +json.c: Registering sensor: Temperature and humidity sensor
  77 +json.c: Server is lewis.upc.es
  78 +httpClient.c: Checking params
  79 +httpClient.c: Calculating header size
  80 +httpClient.c: Building request head
  81 +httpClient.c: Adding content to request string
  82 +httpClient.c: Packet:
  83 +
  84 +PUT /modularsense/wordpress/opendata/catalog/register HTTP/1.1
  85 +Host: 147.83.39.240
  86 +Content-Type: application/json; charset=UTF-8
  87 +Content-Length: 161
  88 +
  89 +{"sensors":[{"sensor":"00000127","description":"Temperature and humidity sensor","type":"temperature,humidity","unit":"ยบC,RH","location":"41.557255 2.096183"}]}
  90 +
  91 +httpClient.c: Setting connection
  92 +httpClient.c: Establishing connection
  93 +httpClient.c: Sending request
  94 +httpClient.c: Write returned: 0
  95 +httpClient.c: Waiting for response
  96 +httpClient.c: Receive returned: 0
  97 +httpClient.c: Response received. Let's parse the information
  98 +httpClient.c: Response code: 200
  99 +json.c: Success: JSON_POST_OK
  100 +json.c: Registering sensor: Battery Level
  101 +json.c: Server is lewis.upc.es
  102 +httpClient.c: Checking params
  103 +httpClient.c: Calculating header size
  104 +httpClient.c: Building request head
  105 +httpClient.c: Adding content to request string
  106 +httpClient.c: Packet:
  107 +
  108 +PUT /modularsense/wordpress/opendata/catalog/register HTTP/1.1
  109 +Host: 147.83.39.240
  110 +Content-Type: application/json; charset=UTF-8
  111 +Content-Length: 124
  112 +
  113 +{"sensors":[{"sensor":"00000100","description":"Battery Level","type":"power","unit":"mV","location":"41.557255 2.096183"}]}
  114 +
  115 +httpClient.c: Setting connection
  116 +httpClient.c: Establishing connection
  117 +httpClient.c: Sending request
  118 +httpClient.c: Write returned: 0
  119 +httpClient.c: Waiting for response
  120 +httpClient.c: Receive returned: 0
  121 +httpClient.c: Response received. Let's parse the information
  122 +httpClient.c: Response code: 200
  123 +json.c: Success: JSON_POST_OK
  124 +main.c: 3 sensor detected...
  125 +main.c: Requesting new NTP time...
  126 +ntp.c: Successfully got new time
  127 +ntp.c: Received timestamp 3611016270
  128 +main.c: Updating new time to 3611016270
  129 +main.c: Time updated
  130 +main.c: Disconnecting wifi...
  131 +main.c: Disconnecting Successful: WIFI_DISCONNECT_SUCCESS
  132 +timer-loop.c: Time to sleep! for 30 seconds
  133 +callbacks.c: WiFi Connect indication: Failed
  134 +main.c: Time (absolute): 3611016300
  135 +Time LONG_PERIOD: 0
  136 +Time SHORT_PERIOD: 0
  137 +sensors.c: Collecting data...
  138 +sensors.c: Not freeing memory on index 0
  139 +sensors.c: Fetching data from light sensor
  140 +sensors.c: [LIGHT] Sent power on command
  141 +sensors.c: [LIGHT] Sent start conversion command
  142 +sensors.c: [LIGHT] Sent stop conversion command
  143 +sensors.c: [LIGHT] Sent fetch command for CH1
  144 +sensors.c: [LIGHT] Got low byte for CH1
  145 +sensors.c: [LIGHT] Got high byte for CH1
  146 +sensors.c: [LIGHT] Got ch1
  147 +sensors.c: [LIGHT] Sent fetch command for CH0
  148 +sensors.c: [LIGHT] Got low byte for CH0
  149 +sensors.c: [LIGHT] Got high byte for CH0
  150 +sensors.c: [LIGHT] Got ch0
  151 +sensors.c: [LIGHT] CH1 = 0B
  152 +sensors.c: [LIGHT] CH0 = 74
  153 +sensors.c: Not freeing memory on index 1
  154 +sensors.c: Fetching data from pressure sensor
  155 +sensors.c: [PRESSURE] Initialized
  156 +sensors.c: [PRESSURE] Got high byte
  157 +sensors.c: [PRESSURE] Got low byte
  158 +sensors.c: [PRESSURE] Initialized temperature
  159 +sensors.c: [PRESSURE] Got temperature high byte
  160 +sensors.c: [PRESSURE] Got temperature low byte
  161 +sensors.c: Not freeing memory on index 2
  162 +sensors.c: Fetching data from humidity and temperature sensor
  163 +sensors.c: [HUMIDITY_TEMP] Initializing sensor
  164 +sensors.c: [HUMIDITY_TEMP] Initialized temperature
  165 +sensors.c: [HUMIDITY_TEMP] Discarded first humidity byte
  166 +sensors.c: [HUMIDITY_TEMP] Discarded second humidity byte
  167 +sensors.c: [HUMIDITY_TEMP] Got temperature high byte
  168 +sensors.c: [HUMIDITY_TEMP] Got temperature low byte
  169 +sensors.c: [HUMIDITY_TEMP] Initializing sensor
  170 +sensors.c: [HUMIDITY_TEMP] Initialized humidity
  171 +sensors.c: [HUMIDITY_TEMP] Got humidity high byte
  172 +sensors.c: [HUMIDITY_TEMP] Got humidity low byte
  173 +sensors.c: Data collected
  174 +main.c: Time (absolute): 3611016301
  175 +Time LONG_PERIOD: 3
  176 +Time SHORT_PERIOD: 1
  177 +main.c: Timestamp (absolute): 3611016301
  178 +Timestamp LONG_PERIOD: 3
  179 +Timestamp SHORT_PERIOD: 1
  180 +main.c: Timestamping data...
  181 +ntp.c: Writing timestamp...
  182 +main.c: Data is: 721012,6/6/2014T6:5:1
  183 +ntp.c: Writing timestamp...
  184 +main.c: Data is: 39192,28949,6/6/2014T6:5:1
  185 +ntp.c: Writing timestamp...
  186 +main.c: Data is: 6466,9197,6/6/2014T6:5:1
  187 +main.c: Returning timestamped data...
  188 +main.c: Putting data in buffers...
  189 +main.c: Putting data: 721012,6/6/2014T6:5:1
  190 + buffer.c: Joining buffer...
  191 +buffer.c: Data copied
  192 +main.c: Message put: 721012,6/6/2014T6:5:1
  193 +main.c: Memory freed
  194 + main.c: Putting data: 39192,28949,6/6/2014T6:5:1
  195 + buffer.c: Joining buffer...
  196 +buffer.c: Data copied
  197 +main.c: Message put: 39192,28949,6/6/2014T6:5:1
  198 +main.c: Memory freed
  199 + main.c: Putting data: 6466,9197,6/6/2014T6:5:1
  200 + buffer.c: Joining buffer...
  201 +buffer.c: Data copied
  202 +main.c: Message put: 6466,9197,6/6/2014T6:5:1
  203 +main.c: Memory freed
  204 + main.c: Data is now in buffer
  205 + buffer.c: Checking available memory...
  206 +buffer.c: Available memory: 33560 B
  207 +buffer.c: Used memory: 1144 B
  208 +main.c: Time (absolute): 3611016301
  209 +Time LONG_PERIOD: 3
  210 +Time SHORT_PERIOD: 1
  211 +timer-loop.c: Time to sleep! for 59 seconds
... ...