mbed Weather Platform firmware http://mbed.org/users/okini3939/notebook/mbed-weather-platform-firmware/

Dependencies:   EthernetNetIf SDHCFileSystem I2CLEDDisp Agentbed NTPClient_NetServices mbed BMP085 HTTPClient ConfigFile I2CLCD

Committer:
okini3939
Date:
Wed May 18 15:01:56 2011 +0000
Revision:
0:d7b4484099bf

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 0:d7b4484099bf 1 /** @file
okini3939 0:d7b4484099bf 2 * @brief mbed Weather Platform
okini3939 0:d7b4484099bf 3 */
okini3939 0:d7b4484099bf 4 #include "mbed.h"
okini3939 0:d7b4484099bf 5 #include "conf.h"
okini3939 0:d7b4484099bf 6 #include "ConfigFile.h"
okini3939 0:d7b4484099bf 7
okini3939 0:d7b4484099bf 8 extern Serial xbee;
okini3939 0:d7b4484099bf 9 extern Config conf;
okini3939 0:d7b4484099bf 10 extern Sensor sensor, offset, sensor_old;
okini3939 0:d7b4484099bf 11
okini3939 0:d7b4484099bf 12 void int_counter();
okini3939 0:d7b4484099bf 13
okini3939 0:d7b4484099bf 14 char* chop (char *s) {
okini3939 0:d7b4484099bf 15 int i;
okini3939 0:d7b4484099bf 16
okini3939 0:d7b4484099bf 17 for (i = strlen(s) - 1; i >= 0; i --) {
okini3939 0:d7b4484099bf 18 if (s[i] == ' ' || s[i] == '\n' || s[i] == '\r') {
okini3939 0:d7b4484099bf 19 s[i] = 0;
okini3939 0:d7b4484099bf 20 } else {
okini3939 0:d7b4484099bf 21 break;
okini3939 0:d7b4484099bf 22 }
okini3939 0:d7b4484099bf 23 }
okini3939 0:d7b4484099bf 24 return s;
okini3939 0:d7b4484099bf 25 }
okini3939 0:d7b4484099bf 26
okini3939 0:d7b4484099bf 27 int check_action (char type) {
okini3939 0:d7b4484099bf 28 int i, j, count;
okini3939 0:d7b4484099bf 29 float value, vold;
okini3939 0:d7b4484099bf 30 time_t sec = time(NULL) + (60 * 60 * 9);
okini3939 0:d7b4484099bf 31 struct tm *tim = localtime(&sec);
okini3939 0:d7b4484099bf 32
okini3939 0:d7b4484099bf 33 for(i = 0; i < conf.actionscount; i ++) {
okini3939 0:d7b4484099bf 34 if (conf.actions[i].action != type) continue;
okini3939 0:d7b4484099bf 35
okini3939 0:d7b4484099bf 36 count = 0;
okini3939 0:d7b4484099bf 37 for (j = 0; j < conf.actions[i].count; j ++) {
okini3939 0:d7b4484099bf 38 switch (conf.actions[i].exps[j].key) {
okini3939 0:d7b4484099bf 39 case 'P':
okini3939 0:d7b4484099bf 40 value = sensor.pres;
okini3939 0:d7b4484099bf 41 vold = sensor_old.pres;
okini3939 0:d7b4484099bf 42 break;
okini3939 0:d7b4484099bf 43 case 'T':
okini3939 0:d7b4484099bf 44 value = sensor.temp;
okini3939 0:d7b4484099bf 45 vold = sensor_old.temp;
okini3939 0:d7b4484099bf 46 break;
okini3939 0:d7b4484099bf 47 case 'H':
okini3939 0:d7b4484099bf 48 value = sensor.humi;
okini3939 0:d7b4484099bf 49 vold = sensor_old.humi;
okini3939 0:d7b4484099bf 50 break;
okini3939 0:d7b4484099bf 51 case 'A':
okini3939 0:d7b4484099bf 52 value = sensor.anemo;
okini3939 0:d7b4484099bf 53 vold = sensor_old.anemo;
okini3939 0:d7b4484099bf 54 break;
okini3939 0:d7b4484099bf 55 case 'V':
okini3939 0:d7b4484099bf 56 value = sensor.vane;
okini3939 0:d7b4484099bf 57 vold = sensor_old.vane;
okini3939 0:d7b4484099bf 58 break;
okini3939 0:d7b4484099bf 59 case 'R':
okini3939 0:d7b4484099bf 60 value = sensor.rain;
okini3939 0:d7b4484099bf 61 vold = sensor_old.rain;
okini3939 0:d7b4484099bf 62 break;
okini3939 0:d7b4484099bf 63 case 'L':
okini3939 0:d7b4484099bf 64 value = sensor.light;
okini3939 0:d7b4484099bf 65 vold = sensor_old.light;
okini3939 0:d7b4484099bf 66 break;
okini3939 0:d7b4484099bf 67 case 'U':
okini3939 0:d7b4484099bf 68 value = sensor.uv;
okini3939 0:d7b4484099bf 69 vold = sensor_old.uv;
okini3939 0:d7b4484099bf 70 break;
okini3939 0:d7b4484099bf 71 case 'M':
okini3939 0:d7b4484099bf 72 value = sensor.moist;
okini3939 0:d7b4484099bf 73 vold = sensor_old.moist;
okini3939 0:d7b4484099bf 74 break;
okini3939 0:d7b4484099bf 75
okini3939 0:d7b4484099bf 76 case 'y':
okini3939 0:d7b4484099bf 77 value = tim->tm_year + 1900;
okini3939 0:d7b4484099bf 78 break;
okini3939 0:d7b4484099bf 79 case 'm':
okini3939 0:d7b4484099bf 80 value = tim->tm_mon;
okini3939 0:d7b4484099bf 81 break;
okini3939 0:d7b4484099bf 82 case 'd':
okini3939 0:d7b4484099bf 83 value = tim->tm_mday;
okini3939 0:d7b4484099bf 84 break;
okini3939 0:d7b4484099bf 85 case 'h':
okini3939 0:d7b4484099bf 86 value = tim->tm_hour;
okini3939 0:d7b4484099bf 87 break;
okini3939 0:d7b4484099bf 88 case 'i':
okini3939 0:d7b4484099bf 89 value = tim->tm_min;
okini3939 0:d7b4484099bf 90 break;
okini3939 0:d7b4484099bf 91 case 's':
okini3939 0:d7b4484099bf 92 value = tim->tm_sec;
okini3939 0:d7b4484099bf 93 break;
okini3939 0:d7b4484099bf 94
okini3939 0:d7b4484099bf 95 default:
okini3939 0:d7b4484099bf 96 value = 0;
okini3939 0:d7b4484099bf 97 break;
okini3939 0:d7b4484099bf 98 }
okini3939 0:d7b4484099bf 99
okini3939 0:d7b4484099bf 100 switch (conf.actions[i].exps[j].expression) {
okini3939 0:d7b4484099bf 101 case EXP_EQ:
okini3939 0:d7b4484099bf 102 if (value == conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 103 count ++;
okini3939 0:d7b4484099bf 104 }
okini3939 0:d7b4484099bf 105 break;
okini3939 0:d7b4484099bf 106 case EXP_NE:
okini3939 0:d7b4484099bf 107 if (value != conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 108 count ++;
okini3939 0:d7b4484099bf 109 }
okini3939 0:d7b4484099bf 110 break;
okini3939 0:d7b4484099bf 111 case EXP_LE:
okini3939 0:d7b4484099bf 112 if (value <= conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 113 count ++;
okini3939 0:d7b4484099bf 114 }
okini3939 0:d7b4484099bf 115 break;
okini3939 0:d7b4484099bf 116 case EXP_LT:
okini3939 0:d7b4484099bf 117 if (value < conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 118 count ++;
okini3939 0:d7b4484099bf 119 }
okini3939 0:d7b4484099bf 120 break;
okini3939 0:d7b4484099bf 121 case EXP_GE:
okini3939 0:d7b4484099bf 122 if (value >= conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 123 count ++;
okini3939 0:d7b4484099bf 124 }
okini3939 0:d7b4484099bf 125 break;
okini3939 0:d7b4484099bf 126 case EXP_GT:
okini3939 0:d7b4484099bf 127 if (value > conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 128 count ++;
okini3939 0:d7b4484099bf 129 }
okini3939 0:d7b4484099bf 130 break;
okini3939 0:d7b4484099bf 131 case EXP_MOD:
okini3939 0:d7b4484099bf 132 if ((int)value % (int)conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 133 count ++;
okini3939 0:d7b4484099bf 134 }
okini3939 0:d7b4484099bf 135 break;
okini3939 0:d7b4484099bf 136 case EXP_NMOD:
okini3939 0:d7b4484099bf 137 if (! (int)value % (int)conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 138 count ++;
okini3939 0:d7b4484099bf 139 }
okini3939 0:d7b4484099bf 140 break;
okini3939 0:d7b4484099bf 141 case EXP_FALL:
okini3939 0:d7b4484099bf 142 if (value < conf.actions[i].exps[j].value && vold >= conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 143 count ++;
okini3939 0:d7b4484099bf 144 }
okini3939 0:d7b4484099bf 145 break;
okini3939 0:d7b4484099bf 146 case EXP_RISE:
okini3939 0:d7b4484099bf 147 if (value > conf.actions[i].exps[j].value && vold <= conf.actions[i].exps[j].value) {
okini3939 0:d7b4484099bf 148 count ++;
okini3939 0:d7b4484099bf 149 }
okini3939 0:d7b4484099bf 150 break;
okini3939 0:d7b4484099bf 151
okini3939 0:d7b4484099bf 152 default:
okini3939 0:d7b4484099bf 153 count ++;
okini3939 0:d7b4484099bf 154 break;
okini3939 0:d7b4484099bf 155 }
okini3939 0:d7b4484099bf 156 }
okini3939 0:d7b4484099bf 157 if (count == conf.actions[i].count) {
okini3939 0:d7b4484099bf 158 return conf.actions[i].sub ? conf.actions[i].sub : ' ';
okini3939 0:d7b4484099bf 159 }
okini3939 0:d7b4484099bf 160 }
okini3939 0:d7b4484099bf 161 return 0;
okini3939 0:d7b4484099bf 162 }
okini3939 0:d7b4484099bf 163
okini3939 0:d7b4484099bf 164 void add_actionsub (struct tExpression *exp, char *buf) {
okini3939 0:d7b4484099bf 165
okini3939 0:d7b4484099bf 166 exp->key = buf[0];
okini3939 0:d7b4484099bf 167
okini3939 0:d7b4484099bf 168 switch (buf[1]) {
okini3939 0:d7b4484099bf 169 case '=':
okini3939 0:d7b4484099bf 170 if (buf[2] == '=') {
okini3939 0:d7b4484099bf 171 exp->expression = EXP_EQ;
okini3939 0:d7b4484099bf 172 exp->value = atof(&buf[3]);
okini3939 0:d7b4484099bf 173 }
okini3939 0:d7b4484099bf 174 break;
okini3939 0:d7b4484099bf 175
okini3939 0:d7b4484099bf 176 case '!':
okini3939 0:d7b4484099bf 177 if (buf[2] == '=') {
okini3939 0:d7b4484099bf 178 exp->expression = EXP_NE;
okini3939 0:d7b4484099bf 179 exp->value = atof(&buf[3]);
okini3939 0:d7b4484099bf 180 } else
okini3939 0:d7b4484099bf 181 if (buf[2] == '%') {
okini3939 0:d7b4484099bf 182 exp->expression = EXP_NMOD;
okini3939 0:d7b4484099bf 183 exp->value = atof(&buf[3]);
okini3939 0:d7b4484099bf 184 }
okini3939 0:d7b4484099bf 185 break;
okini3939 0:d7b4484099bf 186
okini3939 0:d7b4484099bf 187 case '<':
okini3939 0:d7b4484099bf 188 if (buf[2] == '=') {
okini3939 0:d7b4484099bf 189 exp->expression = EXP_LE;
okini3939 0:d7b4484099bf 190 exp->value = atof(&buf[3]);
okini3939 0:d7b4484099bf 191 } else {
okini3939 0:d7b4484099bf 192 exp->expression = EXP_LT;
okini3939 0:d7b4484099bf 193 exp->value = atof(&buf[2]);
okini3939 0:d7b4484099bf 194 }
okini3939 0:d7b4484099bf 195 break;
okini3939 0:d7b4484099bf 196
okini3939 0:d7b4484099bf 197 case '>':
okini3939 0:d7b4484099bf 198 if (buf[2] == '=') {
okini3939 0:d7b4484099bf 199 exp->expression = EXP_GE;
okini3939 0:d7b4484099bf 200 exp->value = atof(&buf[3]);
okini3939 0:d7b4484099bf 201 } else {
okini3939 0:d7b4484099bf 202 exp->expression = EXP_GT;
okini3939 0:d7b4484099bf 203 exp->value = atof(&buf[2]);
okini3939 0:d7b4484099bf 204 }
okini3939 0:d7b4484099bf 205 break;
okini3939 0:d7b4484099bf 206
okini3939 0:d7b4484099bf 207 case '%':
okini3939 0:d7b4484099bf 208 exp->expression = EXP_MOD;
okini3939 0:d7b4484099bf 209 exp->value = atof(&buf[2]);
okini3939 0:d7b4484099bf 210 break;
okini3939 0:d7b4484099bf 211
okini3939 0:d7b4484099bf 212 case '_':
okini3939 0:d7b4484099bf 213 exp->expression = EXP_FALL;
okini3939 0:d7b4484099bf 214 exp->value = atof(&buf[2]);
okini3939 0:d7b4484099bf 215 break;
okini3939 0:d7b4484099bf 216 case '^':
okini3939 0:d7b4484099bf 217 exp->expression = EXP_RISE;
okini3939 0:d7b4484099bf 218 exp->value = atof(&buf[2]);
okini3939 0:d7b4484099bf 219 break;
okini3939 0:d7b4484099bf 220
okini3939 0:d7b4484099bf 221 default:
okini3939 0:d7b4484099bf 222 exp->expression = EXP_NULL;
okini3939 0:d7b4484099bf 223 break;
okini3939 0:d7b4484099bf 224 }
okini3939 0:d7b4484099bf 225 }
okini3939 0:d7b4484099bf 226
okini3939 0:d7b4484099bf 227 void add_action (char *buf) {
okini3939 0:d7b4484099bf 228 int i, len, count;
okini3939 0:d7b4484099bf 229 char c;
okini3939 0:d7b4484099bf 230 char *tmp = NULL;
okini3939 0:d7b4484099bf 231
okini3939 0:d7b4484099bf 232 if (conf.actionscount >= CF_ACTION_NUM) return;
okini3939 0:d7b4484099bf 233
okini3939 0:d7b4484099bf 234 // conf.actions[conf.actionscount].action = atoi(&buf[0]);
okini3939 0:d7b4484099bf 235 conf.actions[conf.actionscount].action = buf[0];
okini3939 0:d7b4484099bf 236 conf.actions[conf.actionscount].sub = buf[1];
okini3939 0:d7b4484099bf 237
okini3939 0:d7b4484099bf 238 count = 0;
okini3939 0:d7b4484099bf 239 strcat(buf, "\n");
okini3939 0:d7b4484099bf 240 len = strlen(buf);
okini3939 0:d7b4484099bf 241 for (i = 1; i < len; i ++) {
okini3939 0:d7b4484099bf 242 c = buf[i];
okini3939 0:d7b4484099bf 243 if (c == ' ' || c == '\t' || c == '\n' || c == '\r') {
okini3939 0:d7b4484099bf 244 buf[i] = 0;
okini3939 0:d7b4484099bf 245 if (count) {
okini3939 0:d7b4484099bf 246 add_actionsub(&conf.actions[conf.actionscount].exps[count - 1], tmp);
okini3939 0:d7b4484099bf 247 }
okini3939 0:d7b4484099bf 248 if (count >= CF_ACTION_EXPS || c == '\n') break;
okini3939 0:d7b4484099bf 249 tmp = &buf[i + 1];
okini3939 0:d7b4484099bf 250 count ++;
okini3939 0:d7b4484099bf 251 }
okini3939 0:d7b4484099bf 252 }
okini3939 0:d7b4484099bf 253
okini3939 0:d7b4484099bf 254 conf.actions[conf.actionscount].count = count;
okini3939 0:d7b4484099bf 255 conf.actionscount ++;
okini3939 0:d7b4484099bf 256 }
okini3939 0:d7b4484099bf 257
okini3939 0:d7b4484099bf 258 int config (char *file) {
okini3939 0:d7b4484099bf 259 int i;
okini3939 0:d7b4484099bf 260 ConfigFile cfg;
okini3939 0:d7b4484099bf 261 char buf[80], key[20];
okini3939 0:d7b4484099bf 262 int ip0, ip1, ip2, ip3;
okini3939 0:d7b4484099bf 263
okini3939 0:d7b4484099bf 264 conf.ipaddr = IpAddr(0, 0, 0, 0);
okini3939 0:d7b4484099bf 265 conf.netmask = IpAddr(255, 255, 255, 0);
okini3939 0:d7b4484099bf 266 conf.gateway = IpAddr(0, 0, 0, 0);
okini3939 0:d7b4484099bf 267 conf.nameserver = IpAddr(0, 0, 0, 0);
okini3939 0:d7b4484099bf 268 conf.interval = 60;
okini3939 0:d7b4484099bf 269 conf.ntpserver[0] = 0;
okini3939 0:d7b4484099bf 270 conf.filetype = 0;
okini3939 0:d7b4484099bf 271 conf.actionscount = 0;
okini3939 0:d7b4484099bf 272 conf.pachube_apikey[0] = 0;
okini3939 0:d7b4484099bf 273 conf.pachube_feedid[0] = 0;
okini3939 0:d7b4484099bf 274 conf.twitter_user[0] = 0;
okini3939 0:d7b4484099bf 275 conf.twitter_pwd[0] = 0;
okini3939 0:d7b4484099bf 276 for (i = 0; i < CF_TWITTER_NUM; i ++) {
okini3939 0:d7b4484099bf 277 conf.twitter_mesg[i][0] = 0;
okini3939 0:d7b4484099bf 278 }
okini3939 0:d7b4484099bf 279 conf.stations_id[0] = 0;
okini3939 0:d7b4484099bf 280 conf.stations_pin[0] = 0;
okini3939 0:d7b4484099bf 281 conf.snmp_commname[0] = 0;
okini3939 0:d7b4484099bf 282 conf.leddisp_mesg[0] = 0;
okini3939 0:d7b4484099bf 283 conf.lcd_mesg[0] = 0;
okini3939 0:d7b4484099bf 284 conf.lcdtype = LCD16x2;
okini3939 0:d7b4484099bf 285 conf.lcdconf = LCDCFG_3V;
okini3939 0:d7b4484099bf 286 memset(&offset, 0, sizeof(offset));
okini3939 0:d7b4484099bf 287 memset(&sensor_old, 0, sizeof(sensor_old));
okini3939 0:d7b4484099bf 288
okini3939 0:d7b4484099bf 289 if (! cfg.read(file)) {
okini3939 0:d7b4484099bf 290 return -1;
okini3939 0:d7b4484099bf 291 }
okini3939 0:d7b4484099bf 292
okini3939 0:d7b4484099bf 293 if (cfg.getValue("INTERVAL", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 294 conf.interval = atoi(chop(buf));
okini3939 0:d7b4484099bf 295 }
okini3939 0:d7b4484099bf 296 if (cfg.getValue("FILE", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 297 chop(buf);
okini3939 0:d7b4484099bf 298 if (strcmp(buf, "SD") == 0) {
okini3939 0:d7b4484099bf 299 conf.filetype = 1;
okini3939 0:d7b4484099bf 300 } else
okini3939 0:d7b4484099bf 301 if (strcmp(buf, "USB") == 0) {
okini3939 0:d7b4484099bf 302 conf.filetype = 2;
okini3939 0:d7b4484099bf 303 }
okini3939 0:d7b4484099bf 304 }
okini3939 0:d7b4484099bf 305
okini3939 0:d7b4484099bf 306 if (cfg.getValue("IPADDRESS", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 307 chop(buf);
okini3939 0:d7b4484099bf 308 if (strcmp(buf, "DHCP") == 0) {
okini3939 0:d7b4484099bf 309 conf.ipaddr = IpAddr(255, 255, 255, 255);
okini3939 0:d7b4484099bf 310 } else {
okini3939 0:d7b4484099bf 311 sscanf(buf, "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3);
okini3939 0:d7b4484099bf 312 conf.ipaddr = IpAddr(ip0, ip1, ip2, ip3);
okini3939 0:d7b4484099bf 313 }
okini3939 0:d7b4484099bf 314 }
okini3939 0:d7b4484099bf 315 if (cfg.getValue("NETMASK", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 316 sscanf(chop(buf), "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3);
okini3939 0:d7b4484099bf 317 conf.netmask = IpAddr(ip0, ip1, ip2, ip3);
okini3939 0:d7b4484099bf 318 }
okini3939 0:d7b4484099bf 319 if (cfg.getValue("GATEWAY", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 320 sscanf(chop(buf), "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3);
okini3939 0:d7b4484099bf 321 conf.gateway = IpAddr(ip0, ip1, ip2, ip3);
okini3939 0:d7b4484099bf 322 }
okini3939 0:d7b4484099bf 323 if (cfg.getValue("NAMESERVER", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 324 sscanf(chop(buf), "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3);
okini3939 0:d7b4484099bf 325 conf.nameserver = IpAddr(ip0, ip1, ip2, ip3);
okini3939 0:d7b4484099bf 326 }
okini3939 0:d7b4484099bf 327
okini3939 0:d7b4484099bf 328 cfg.getValue("NTPSERVER", conf.ntpserver, sizeof(conf.ntpserver));
okini3939 0:d7b4484099bf 329 chop(conf.ntpserver);
okini3939 0:d7b4484099bf 330 cfg.getValue("PACHUBE_APIKEY", conf.pachube_apikey, sizeof(conf.pachube_apikey));
okini3939 0:d7b4484099bf 331 chop(conf.pachube_apikey);
okini3939 0:d7b4484099bf 332 cfg.getValue("PACHUBE_FEEDID", conf.pachube_feedid, sizeof(conf.pachube_feedid));
okini3939 0:d7b4484099bf 333 chop(conf.pachube_feedid);
okini3939 0:d7b4484099bf 334 cfg.getValue("TWITTER_USER", conf.twitter_user, sizeof(conf.twitter_user));
okini3939 0:d7b4484099bf 335 chop(conf.twitter_user);
okini3939 0:d7b4484099bf 336 cfg.getValue("TWITTER_PWD", conf.twitter_pwd, sizeof(conf.twitter_pwd));
okini3939 0:d7b4484099bf 337 chop(conf.twitter_pwd);
okini3939 0:d7b4484099bf 338 cfg.getValue("TWITTER_MESG", conf.twitter_mesg[0], sizeof(conf.twitter_mesg[0]));
okini3939 0:d7b4484099bf 339 chop(conf.twitter_mesg[0]);
okini3939 0:d7b4484099bf 340 for (i = 0; i < CF_TWITTER_NUM; i ++) {
okini3939 0:d7b4484099bf 341 sprintf(key, "TWITTER_MESG[%d]", i);
okini3939 0:d7b4484099bf 342 cfg.getValue(key, conf.twitter_mesg[i], sizeof(conf.twitter_mesg[i]));
okini3939 0:d7b4484099bf 343 chop(conf.twitter_mesg[i]);
okini3939 0:d7b4484099bf 344 }
okini3939 0:d7b4484099bf 345
okini3939 0:d7b4484099bf 346 cfg.getValue("STATIONS_ID", conf.stations_id, sizeof(conf.stations_id));
okini3939 0:d7b4484099bf 347 chop(conf.stations_id);
okini3939 0:d7b4484099bf 348 cfg.getValue("STATIONS_PIN", conf.stations_pin, sizeof(conf.stations_pin));
okini3939 0:d7b4484099bf 349 chop(conf.stations_pin);
okini3939 0:d7b4484099bf 350 cfg.getValue("SNMP_COMMNAME", conf.snmp_commname, sizeof(conf.snmp_commname));
okini3939 0:d7b4484099bf 351 chop(conf.snmp_commname);
okini3939 0:d7b4484099bf 352
okini3939 0:d7b4484099bf 353 if (cfg.getValue("LCD_TYPE", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 354 conf.lcdtype = (enum I2CLCDType)atoi(chop(buf));
okini3939 0:d7b4484099bf 355 }
okini3939 0:d7b4484099bf 356 if (cfg.getValue("LCD_CONF", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 357 conf.lcdconf = (enum I2CLCDConfig)atoi(chop(buf));
okini3939 0:d7b4484099bf 358 }
okini3939 0:d7b4484099bf 359 if (cfg.getValue("LCD_MESG", conf.lcd_mesg, sizeof(conf.lcd_mesg))) {
okini3939 0:d7b4484099bf 360 chop(conf.lcd_mesg);
okini3939 0:d7b4484099bf 361 }
okini3939 0:d7b4484099bf 362 if (cfg.getValue("LEDDISP_MESG", conf.leddisp_mesg, sizeof(conf.leddisp_mesg))) {
okini3939 0:d7b4484099bf 363 chop(conf.leddisp_mesg);
okini3939 0:d7b4484099bf 364 }
okini3939 0:d7b4484099bf 365
okini3939 0:d7b4484099bf 366 if (cfg.getValue("XBEE", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 367 xbee.baud(atoi(chop(buf)));
okini3939 0:d7b4484099bf 368 }
okini3939 0:d7b4484099bf 369
okini3939 0:d7b4484099bf 370 if (cfg.getValue("INPUT", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 371 conf.inputtype = (enum eINPUTTYPE)atoi(chop(buf));
okini3939 0:d7b4484099bf 372 }
okini3939 0:d7b4484099bf 373
okini3939 0:d7b4484099bf 374 for (i = 0; i < CF_ACTION_NUM; i ++) {
okini3939 0:d7b4484099bf 375 sprintf(key, "ACTION[%d]", i);
okini3939 0:d7b4484099bf 376 if (cfg.getValue(key, buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 377 add_action(chop(buf));
okini3939 0:d7b4484099bf 378 }
okini3939 0:d7b4484099bf 379 }
okini3939 0:d7b4484099bf 380
okini3939 0:d7b4484099bf 381 if (cfg.getValue("OFFSET[P]", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 382 offset.pres = atof(chop(buf));
okini3939 0:d7b4484099bf 383 }
okini3939 0:d7b4484099bf 384 if (cfg.getValue("OFFSET[T]", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 385 offset.temp = atof(chop(buf));
okini3939 0:d7b4484099bf 386 }
okini3939 0:d7b4484099bf 387 if (cfg.getValue("OFFSET[H]", buf, sizeof(buf))) {
okini3939 0:d7b4484099bf 388 offset.humi = atof(chop(buf));
okini3939 0:d7b4484099bf 389 }
okini3939 0:d7b4484099bf 390
okini3939 0:d7b4484099bf 391 return 0;
okini3939 0:d7b4484099bf 392 }