Commit 6ec7a46d6179d1c68a9ea8c6d348a9a504f7a5b5
1 parent
36268163
--no commit message
Showing
3 changed files
with
252 additions
and
0 deletions
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 | +[1;35mmain.c:[1;00m [1;35m--------------WI-SENSE STARTED-------------[1;00m | |
2 | +[1;35mmain.c:[1;00m Connecting wifi... | |
3 | +[1;35mmain.c:[1;00m SSID = SERVER_WLAN | |
4 | +[1;35mmain.c:[1;00m Wep key = TGW2YHNKT9TW | |
5 | +[1;35mmain.c:[1;00m Passphrase = TGW2YHNKT9TW | |
6 | +[1;35mmain.c:[1;00m User = | |
7 | +[1;35mmain.c:[1;00m Password = | |
8 | +[1;35mmain.c:[1;00m Encryption type = 4 | |
9 | +[1;35mmain.c:[1;00m Geo Localization = 41.557255 2.096183 | |
10 | +[1;35mmain.c:[1;00m WPA network detected | |
11 | +[1;35mcallbacks.c:[1;00m WiFi Connect indication: [1;32mConnected[1;00m | |
12 | +Connected to: 00:26:5B:D9:0D:18 | |
13 | +[1;35mcallbacks.c:[1;00m IP: 192.168.0.47 | |
14 | +[1;35mbuffer.c:[1;00m Checking available memory... | |
15 | +[1;35mbuffer.c:[1;00m [1;36mAvailable memory: 33320 B[1;00m | |
16 | +[1;35mbuffer.c:[1;00m [1;36mUsed memory: 1384 B[1;00m | |
17 | +[1;35msensors.c:[1;00m Waking up sensors... | |
18 | +[1;35msensors.c:[1;00m Woken Pin 3 | |
19 | +[1;35msensors.c:[1;00m Woken Pin 4 | |
20 | +[1;35msensors.c:[1;00m Woken Pin 5 | |
21 | +[1;35msensors.c:[1;00m Woken Pin 6 | |
22 | +[1;35msensors.c:[1;00m Woken Pin 7 | |
23 | +[1;35mjson.c:[1;00m Registering sensor: Light sensor | |
24 | +[1;35mjson.c:[1;00m Server is lewis.upc.es | |
25 | +[1;35mhttpClient.c:[1;00m Checking params | |
26 | +[1;35mhttpClient.c:[1;00m Calculating header size | |
27 | +[1;35mhttpClient.c:[1;00m Building request head | |
28 | +[1;35mhttpClient.c:[1;00m Adding content to request string | |
29 | +[1;35mhttpClient.c:[1;00m Packet: | |
30 | + | |
31 | +[1;32mPUT /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"}]}[1;00m | |
37 | + | |
38 | +[1;35mhttpClient.c:[1;00m Setting connection | |
39 | +[1;35mhttpClient.c:[1;00m Establishing connection | |
40 | +[1;35mhttpClient.c:[1;00m Sending request | |
41 | +[1;35mhttpClient.c:[1;00m Write returned: 0 | |
42 | +[1;35mhttpClient.c:[1;00m Waiting for response | |
43 | +[1;35mhttpClient.c:[1;00m Receive returned: 0 | |
44 | +[1;35mhttpClient.c:[1;00m Response received. Let's parse the information | |
45 | +[1;35mhttpClient.c:[1;00m Response code: 200 | |
46 | +[1;35mjson.c:[1;00m Success: [1;32mJSON_POST_OK[1;00m | |
47 | +[1;35mjson.c:[1;00m Registering sensor: Pressure sensor | |
48 | +[1;35mjson.c:[1;00m Putting additional info for pressure sensor... | |
49 | +[1;35msensors.c:[1;00m [PRESSURE] Fetching callibration data | |
50 | +[1;35msensors.c:[1;00m [PRESSURE] Got callibration data | |
51 | +[1;35mjson.c:[1;00m callibration_data is: 7453,64557,51006,32123,24742,20239,5498,49,32768,54461,2432 | |
52 | +[1;35mjson.c:[1;00m In prepare_json_register_statement: Detected additional_info | |
53 | +[1;35mjson.c:[1;00m Server is lewis.upc.es | |
54 | +[1;35mhttpClient.c:[1;00m Checking params | |
55 | +[1;35mhttpClient.c:[1;00m Calculating header size | |
56 | +[1;35mhttpClient.c:[1;00m Building request head | |
57 | +[1;35mhttpClient.c:[1;00m Adding content to request string | |
58 | +[1;35mhttpClient.c:[1;00m Packet: | |
59 | + | |
60 | +[1;32mPUT /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"}]}[1;00m | |
66 | + | |
67 | +[1;35mhttpClient.c:[1;00m Setting connection | |
68 | +[1;35mhttpClient.c:[1;00m Establishing connection | |
69 | +[1;35mhttpClient.c:[1;00m Sending request | |
70 | +[1;35mhttpClient.c:[1;00m Write returned: 0 | |
71 | +[1;35mhttpClient.c:[1;00m Waiting for response | |
72 | +[1;35mhttpClient.c:[1;00m Receive returned: 0 | |
73 | +[1;35mhttpClient.c:[1;00m Response received. Let's parse the information | |
74 | +[1;35mhttpClient.c:[1;00m Response code: 200 | |
75 | +[1;35mjson.c:[1;00m Success: [1;32mJSON_POST_OK[1;00m | |
76 | +[1;35mjson.c:[1;00m Registering sensor: Temperature and humidity sensor | |
77 | +[1;35mjson.c:[1;00m Server is lewis.upc.es | |
78 | +[1;35mhttpClient.c:[1;00m Checking params | |
79 | +[1;35mhttpClient.c:[1;00m Calculating header size | |
80 | +[1;35mhttpClient.c:[1;00m Building request head | |
81 | +[1;35mhttpClient.c:[1;00m Adding content to request string | |
82 | +[1;35mhttpClient.c:[1;00m Packet: | |
83 | + | |
84 | +[1;32mPUT /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"}]}[1;00m | |
90 | + | |
91 | +[1;35mhttpClient.c:[1;00m Setting connection | |
92 | +[1;35mhttpClient.c:[1;00m Establishing connection | |
93 | +[1;35mhttpClient.c:[1;00m Sending request | |
94 | +[1;35mhttpClient.c:[1;00m Write returned: 0 | |
95 | +[1;35mhttpClient.c:[1;00m Waiting for response | |
96 | +[1;35mhttpClient.c:[1;00m Receive returned: 0 | |
97 | +[1;35mhttpClient.c:[1;00m Response received. Let's parse the information | |
98 | +[1;35mhttpClient.c:[1;00m Response code: 200 | |
99 | +[1;35mjson.c:[1;00m Success: [1;32mJSON_POST_OK[1;00m | |
100 | +[1;35mjson.c:[1;00m Registering sensor: Battery Level | |
101 | +[1;35mjson.c:[1;00m Server is lewis.upc.es | |
102 | +[1;35mhttpClient.c:[1;00m Checking params | |
103 | +[1;35mhttpClient.c:[1;00m Calculating header size | |
104 | +[1;35mhttpClient.c:[1;00m Building request head | |
105 | +[1;35mhttpClient.c:[1;00m Adding content to request string | |
106 | +[1;35mhttpClient.c:[1;00m Packet: | |
107 | + | |
108 | +[1;32mPUT /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"}]}[1;00m | |
114 | + | |
115 | +[1;35mhttpClient.c:[1;00m Setting connection | |
116 | +[1;35mhttpClient.c:[1;00m Establishing connection | |
117 | +[1;35mhttpClient.c:[1;00m Sending request | |
118 | +[1;35mhttpClient.c:[1;00m Write returned: 0 | |
119 | +[1;35mhttpClient.c:[1;00m Waiting for response | |
120 | +[1;35mhttpClient.c:[1;00m Receive returned: 0 | |
121 | +[1;35mhttpClient.c:[1;00m Response received. Let's parse the information | |
122 | +[1;35mhttpClient.c:[1;00m Response code: 200 | |
123 | +[1;35mjson.c:[1;00m Success: [1;32mJSON_POST_OK[1;00m | |
124 | +[1;35mmain.c:[1;00m 3 sensor detected... | |
125 | +[1;35mmain.c:[1;00m Requesting new NTP time... | |
126 | +[1;35mntp.c:[1;00m Successfully got new time | |
127 | +[1;35mntp.c:[1;00m Received timestamp 3611016270 | |
128 | +[1;35mmain.c:[1;00m Updating new time to 3611016270 | |
129 | +[1;35mmain.c:[1;00m Time updated | |
130 | +[1;35mmain.c:[1;00m Disconnecting wifi... | |
131 | +[1;35mmain.c:[1;00m Disconnecting Successful: WIFI_DISCONNECT_SUCCESS | |
132 | +[1;35mtimer-loop.c:[1;00m Time to sleep! for 30 seconds | |
133 | +[1;35mcallbacks.c:[1;00m WiFi Connect indication: [1;31mFailed[1;00m | |
134 | +[1;35mmain.c:[1;00m Time (absolute): 3611016300 | |
135 | +Time LONG_PERIOD: 0 | |
136 | +Time SHORT_PERIOD: 0 | |
137 | +[1;35msensors.c:[1;00m Collecting data... | |
138 | +[1;35msensors.c:[1;00m Not freeing memory on index 0 | |
139 | +[1;35msensors.c:[1;00m Fetching data from light sensor | |
140 | +[1;35msensors.c:[1;00m [LIGHT] Sent power on command | |
141 | +[1;35msensors.c:[1;00m [LIGHT] Sent start conversion command | |
142 | +[1;35msensors.c:[1;00m [LIGHT] Sent stop conversion command | |
143 | +[1;35msensors.c:[1;00m [LIGHT] Sent fetch command for CH1 | |
144 | +[1;35msensors.c:[1;00m [LIGHT] Got low byte for CH1 | |
145 | +[1;35msensors.c:[1;00m [LIGHT] Got high byte for CH1 | |
146 | +[1;35msensors.c:[1;00m [LIGHT] Got ch1 | |
147 | +[1;35msensors.c:[1;00m [LIGHT] Sent fetch command for CH0 | |
148 | +[1;35msensors.c:[1;00m [LIGHT] Got low byte for CH0 | |
149 | +[1;35msensors.c:[1;00m [LIGHT] Got high byte for CH0 | |
150 | +[1;35msensors.c:[1;00m [LIGHT] Got ch0 | |
151 | +[1;35msensors.c:[1;00m [LIGHT] CH1 = 0B | |
152 | +[1;35msensors.c:[1;00m [LIGHT] CH0 = 74 | |
153 | +[1;35msensors.c:[1;00m Not freeing memory on index 1 | |
154 | +[1;35msensors.c:[1;00m Fetching data from pressure sensor | |
155 | +[1;35msensors.c:[1;00m [PRESSURE] Initialized | |
156 | +[1;35msensors.c:[1;00m [PRESSURE] Got high byte | |
157 | +[1;35msensors.c:[1;00m [PRESSURE] Got low byte | |
158 | +[1;35msensors.c:[1;00m [PRESSURE] Initialized temperature | |
159 | +[1;35msensors.c:[1;00m [PRESSURE] Got temperature high byte | |
160 | +[1;35msensors.c:[1;00m [PRESSURE] Got temperature low byte | |
161 | +[1;35msensors.c:[1;00m Not freeing memory on index 2 | |
162 | +[1;35msensors.c:[1;00m Fetching data from humidity and temperature sensor | |
163 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Initializing sensor | |
164 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Initialized temperature | |
165 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Discarded first humidity byte | |
166 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Discarded second humidity byte | |
167 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Got temperature high byte | |
168 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Got temperature low byte | |
169 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Initializing sensor | |
170 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Initialized humidity | |
171 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Got humidity high byte | |
172 | +[1;35msensors.c:[1;00m [HUMIDITY_TEMP] Got humidity low byte | |
173 | +[1;35msensors.c:[1;00m Data collected | |
174 | +[1;35mmain.c:[1;00m Time (absolute): 3611016301 | |
175 | +Time LONG_PERIOD: 3 | |
176 | +Time SHORT_PERIOD: 1 | |
177 | +[1;35mmain.c:[1;00m Timestamp (absolute): 3611016301 | |
178 | +Timestamp LONG_PERIOD: 3 | |
179 | +Timestamp SHORT_PERIOD: 1 | |
180 | +[1;35mmain.c:[1;00m Timestamping data... | |
181 | +[1;35mntp.c:[1;00m Writing timestamp... | |
182 | +[1;35mmain.c:[1;00m Data is: 721012,6/6/2014T6:5:1 | |
183 | +[1;35mntp.c:[1;00m Writing timestamp... | |
184 | +[1;35mmain.c:[1;00m Data is: 39192,28949,6/6/2014T6:5:1 | |
185 | +[1;35mntp.c:[1;00m Writing timestamp... | |
186 | +[1;35mmain.c:[1;00m Data is: 6466,9197,6/6/2014T6:5:1 | |
187 | +[1;35mmain.c:[1;00m Returning timestamped data... | |
188 | +[1;35mmain.c:[1;00m Putting data in buffers... | |
189 | +[1;35mmain.c:[1;00m Putting data: 721012,6/6/2014T6:5:1 | |
190 | + [1;35mbuffer.c:[1;00m Joining buffer... | |
191 | +[1;35mbuffer.c:[1;00m Data copied | |
192 | +[1;35mmain.c:[1;00m Message put: 721012,6/6/2014T6:5:1 | |
193 | +[1;35mmain.c:[1;00m Memory freed | |
194 | + [1;35mmain.c:[1;00m Putting data: 39192,28949,6/6/2014T6:5:1 | |
195 | + [1;35mbuffer.c:[1;00m Joining buffer... | |
196 | +[1;35mbuffer.c:[1;00m Data copied | |
197 | +[1;35mmain.c:[1;00m Message put: 39192,28949,6/6/2014T6:5:1 | |
198 | +[1;35mmain.c:[1;00m Memory freed | |
199 | + [1;35mmain.c:[1;00m Putting data: 6466,9197,6/6/2014T6:5:1 | |
200 | + [1;35mbuffer.c:[1;00m Joining buffer... | |
201 | +[1;35mbuffer.c:[1;00m Data copied | |
202 | +[1;35mmain.c:[1;00m Message put: 6466,9197,6/6/2014T6:5:1 | |
203 | +[1;35mmain.c:[1;00m Memory freed | |
204 | + [1;35mmain.c:[1;00m Data is now in buffer | |
205 | + [1;35mbuffer.c:[1;00m Checking available memory... | |
206 | +[1;35mbuffer.c:[1;00m [1;36mAvailable memory: 33560 B[1;00m | |
207 | +[1;35mbuffer.c:[1;00m [1;36mUsed memory: 1144 B[1;00m | |
208 | +[1;35mmain.c:[1;00m Time (absolute): 3611016301 | |
209 | +Time LONG_PERIOD: 3 | |
210 | +Time SHORT_PERIOD: 1 | |
211 | +[1;35mtimer-loop.c:[1;00m Time to sleep! for 59 seconds | ... | ... |