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
conf.cpp@9:8c63e4f3edab, 2011-02-22 (annotated)
- Committer:
- okini3939
- Date:
- Tue Feb 22 14:40:11 2011 +0000
- Revision:
- 9:8c63e4f3edab
- Parent:
- 7:0d3484dc13a9
- Child:
- 10:848a2205aed1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 9:8c63e4f3edab | 1 | /** @file |
okini3939 | 9:8c63e4f3edab | 2 | * @brief mbed Weather Platform |
okini3939 | 9:8c63e4f3edab | 3 | */ |
okini3939 | 9:8c63e4f3edab | 4 | #include "mbed.h" |
okini3939 | 9:8c63e4f3edab | 5 | #include "conf.h" |
okini3939 | 9:8c63e4f3edab | 6 | #include "ConfigFile.h" |
okini3939 | 9:8c63e4f3edab | 7 | |
okini3939 | 9:8c63e4f3edab | 8 | extern struct Serial xbee; |
okini3939 | 9:8c63e4f3edab | 9 | extern struct Config conf; |
okini3939 | 9:8c63e4f3edab | 10 | extern float pres, temp, humi, light, anemo, vane, rain, uv, moist, temp2; |
okini3939 | 9:8c63e4f3edab | 11 | |
okini3939 | 9:8c63e4f3edab | 12 | char* chop (char *s) { |
okini3939 | 9:8c63e4f3edab | 13 | int i; |
okini3939 | 9:8c63e4f3edab | 14 | |
okini3939 | 9:8c63e4f3edab | 15 | for (i = strlen(s) - 1; i >= 0; i --) { |
okini3939 | 9:8c63e4f3edab | 16 | if (s[i] == ' ' || s[i] == '\n' || s[i] == '\r') { |
okini3939 | 9:8c63e4f3edab | 17 | s[i] = 0; |
okini3939 | 9:8c63e4f3edab | 18 | } else { |
okini3939 | 9:8c63e4f3edab | 19 | break; |
okini3939 | 9:8c63e4f3edab | 20 | } |
okini3939 | 9:8c63e4f3edab | 21 | } |
okini3939 | 9:8c63e4f3edab | 22 | return s; |
okini3939 | 9:8c63e4f3edab | 23 | } |
okini3939 | 9:8c63e4f3edab | 24 | |
okini3939 | 9:8c63e4f3edab | 25 | int check_action (char type) { |
okini3939 | 9:8c63e4f3edab | 26 | int i, j, count; |
okini3939 | 9:8c63e4f3edab | 27 | float value; |
okini3939 | 9:8c63e4f3edab | 28 | time_t sec = time(NULL) + (60 * 60 * 9); |
okini3939 | 9:8c63e4f3edab | 29 | struct tm *tim = localtime(&sec); |
okini3939 | 9:8c63e4f3edab | 30 | |
okini3939 | 9:8c63e4f3edab | 31 | for(i = 0; i < conf.actionscount; i ++) { |
okini3939 | 9:8c63e4f3edab | 32 | if (conf.actions[i].action != type) continue; |
okini3939 | 9:8c63e4f3edab | 33 | |
okini3939 | 9:8c63e4f3edab | 34 | count = 0; |
okini3939 | 9:8c63e4f3edab | 35 | for (j = 0; j < conf.actions[i].count; j ++) { |
okini3939 | 9:8c63e4f3edab | 36 | switch (conf.actions[i].exps[j].key) { |
okini3939 | 9:8c63e4f3edab | 37 | case 'P': |
okini3939 | 9:8c63e4f3edab | 38 | value = pres; |
okini3939 | 9:8c63e4f3edab | 39 | break; |
okini3939 | 9:8c63e4f3edab | 40 | case 'T': |
okini3939 | 9:8c63e4f3edab | 41 | value = temp; |
okini3939 | 9:8c63e4f3edab | 42 | break; |
okini3939 | 9:8c63e4f3edab | 43 | case 'H': |
okini3939 | 9:8c63e4f3edab | 44 | value = humi; |
okini3939 | 9:8c63e4f3edab | 45 | break; |
okini3939 | 9:8c63e4f3edab | 46 | case 'A': |
okini3939 | 9:8c63e4f3edab | 47 | value = anemo; |
okini3939 | 9:8c63e4f3edab | 48 | break; |
okini3939 | 9:8c63e4f3edab | 49 | case 'V': |
okini3939 | 9:8c63e4f3edab | 50 | value = vane; |
okini3939 | 9:8c63e4f3edab | 51 | break; |
okini3939 | 9:8c63e4f3edab | 52 | case 'R': |
okini3939 | 9:8c63e4f3edab | 53 | value = rain; |
okini3939 | 9:8c63e4f3edab | 54 | break; |
okini3939 | 9:8c63e4f3edab | 55 | |
okini3939 | 9:8c63e4f3edab | 56 | case 'y': |
okini3939 | 9:8c63e4f3edab | 57 | value = tim->tm_year + 1900; |
okini3939 | 9:8c63e4f3edab | 58 | break; |
okini3939 | 9:8c63e4f3edab | 59 | case 'm': |
okini3939 | 9:8c63e4f3edab | 60 | value = tim->tm_mon; |
okini3939 | 9:8c63e4f3edab | 61 | break; |
okini3939 | 9:8c63e4f3edab | 62 | case 'd': |
okini3939 | 9:8c63e4f3edab | 63 | value = tim->tm_mday; |
okini3939 | 9:8c63e4f3edab | 64 | break; |
okini3939 | 9:8c63e4f3edab | 65 | case 'h': |
okini3939 | 9:8c63e4f3edab | 66 | value = tim->tm_hour; |
okini3939 | 9:8c63e4f3edab | 67 | break; |
okini3939 | 9:8c63e4f3edab | 68 | case 'i': |
okini3939 | 9:8c63e4f3edab | 69 | value = tim->tm_min; |
okini3939 | 9:8c63e4f3edab | 70 | break; |
okini3939 | 9:8c63e4f3edab | 71 | case 's': |
okini3939 | 9:8c63e4f3edab | 72 | value = tim->tm_sec; |
okini3939 | 9:8c63e4f3edab | 73 | break; |
okini3939 | 9:8c63e4f3edab | 74 | |
okini3939 | 9:8c63e4f3edab | 75 | default: |
okini3939 | 9:8c63e4f3edab | 76 | value = 0; |
okini3939 | 9:8c63e4f3edab | 77 | break; |
okini3939 | 9:8c63e4f3edab | 78 | } |
okini3939 | 9:8c63e4f3edab | 79 | |
okini3939 | 9:8c63e4f3edab | 80 | switch (conf.actions[i].exps[j].expression) { |
okini3939 | 9:8c63e4f3edab | 81 | case EXP_EQ: |
okini3939 | 9:8c63e4f3edab | 82 | if (value == conf.actions[i].exps[j].value) { |
okini3939 | 9:8c63e4f3edab | 83 | count ++; |
okini3939 | 9:8c63e4f3edab | 84 | } |
okini3939 | 9:8c63e4f3edab | 85 | break; |
okini3939 | 9:8c63e4f3edab | 86 | case EXP_NE: |
okini3939 | 9:8c63e4f3edab | 87 | if (value != conf.actions[i].exps[j].value) { |
okini3939 | 9:8c63e4f3edab | 88 | count ++; |
okini3939 | 9:8c63e4f3edab | 89 | } |
okini3939 | 9:8c63e4f3edab | 90 | break; |
okini3939 | 9:8c63e4f3edab | 91 | case EXP_LE: |
okini3939 | 9:8c63e4f3edab | 92 | if (value <= conf.actions[i].exps[j].value) { |
okini3939 | 9:8c63e4f3edab | 93 | count ++; |
okini3939 | 9:8c63e4f3edab | 94 | } |
okini3939 | 9:8c63e4f3edab | 95 | break; |
okini3939 | 9:8c63e4f3edab | 96 | case EXP_LT: |
okini3939 | 9:8c63e4f3edab | 97 | if (value < conf.actions[i].exps[j].value) { |
okini3939 | 9:8c63e4f3edab | 98 | count ++; |
okini3939 | 9:8c63e4f3edab | 99 | } |
okini3939 | 9:8c63e4f3edab | 100 | break; |
okini3939 | 9:8c63e4f3edab | 101 | case EXP_GE: |
okini3939 | 9:8c63e4f3edab | 102 | if (value >= conf.actions[i].exps[j].value) { |
okini3939 | 9:8c63e4f3edab | 103 | count ++; |
okini3939 | 9:8c63e4f3edab | 104 | } |
okini3939 | 9:8c63e4f3edab | 105 | break; |
okini3939 | 9:8c63e4f3edab | 106 | case EXP_GT: |
okini3939 | 9:8c63e4f3edab | 107 | if (value > conf.actions[i].exps[j].value) { |
okini3939 | 9:8c63e4f3edab | 108 | count ++; |
okini3939 | 9:8c63e4f3edab | 109 | } |
okini3939 | 9:8c63e4f3edab | 110 | break; |
okini3939 | 9:8c63e4f3edab | 111 | case EXP_MOD: |
okini3939 | 9:8c63e4f3edab | 112 | if ((int)value % (int)conf.actions[i].exps[j].value) { |
okini3939 | 9:8c63e4f3edab | 113 | count ++; |
okini3939 | 9:8c63e4f3edab | 114 | } |
okini3939 | 9:8c63e4f3edab | 115 | break; |
okini3939 | 9:8c63e4f3edab | 116 | case EXP_NMOD: |
okini3939 | 9:8c63e4f3edab | 117 | if (! (int)value % (int)conf.actions[i].exps[j].value) { |
okini3939 | 9:8c63e4f3edab | 118 | count ++; |
okini3939 | 9:8c63e4f3edab | 119 | } |
okini3939 | 9:8c63e4f3edab | 120 | break; |
okini3939 | 9:8c63e4f3edab | 121 | |
okini3939 | 9:8c63e4f3edab | 122 | default: |
okini3939 | 9:8c63e4f3edab | 123 | count ++; |
okini3939 | 9:8c63e4f3edab | 124 | break; |
okini3939 | 9:8c63e4f3edab | 125 | } |
okini3939 | 9:8c63e4f3edab | 126 | } |
okini3939 | 9:8c63e4f3edab | 127 | if (count == conf.actions[i].count) { |
okini3939 | 9:8c63e4f3edab | 128 | return 1; |
okini3939 | 9:8c63e4f3edab | 129 | } |
okini3939 | 9:8c63e4f3edab | 130 | } |
okini3939 | 9:8c63e4f3edab | 131 | return 0; |
okini3939 | 9:8c63e4f3edab | 132 | } |
okini3939 | 9:8c63e4f3edab | 133 | |
okini3939 | 9:8c63e4f3edab | 134 | void add_actionsub (struct tExpression *exp, char *buf) { |
okini3939 | 9:8c63e4f3edab | 135 | |
okini3939 | 9:8c63e4f3edab | 136 | exp->key = buf[0]; |
okini3939 | 9:8c63e4f3edab | 137 | |
okini3939 | 9:8c63e4f3edab | 138 | switch (buf[1]) { |
okini3939 | 9:8c63e4f3edab | 139 | case '=': |
okini3939 | 9:8c63e4f3edab | 140 | if (buf[2] == '=') { |
okini3939 | 9:8c63e4f3edab | 141 | exp->expression = EXP_EQ; |
okini3939 | 9:8c63e4f3edab | 142 | exp->value = atof(&buf[3]); |
okini3939 | 9:8c63e4f3edab | 143 | } |
okini3939 | 9:8c63e4f3edab | 144 | break; |
okini3939 | 9:8c63e4f3edab | 145 | |
okini3939 | 9:8c63e4f3edab | 146 | case '!': |
okini3939 | 9:8c63e4f3edab | 147 | if (buf[2] == '=') { |
okini3939 | 9:8c63e4f3edab | 148 | exp->expression = EXP_NE; |
okini3939 | 9:8c63e4f3edab | 149 | exp->value = atof(&buf[3]); |
okini3939 | 9:8c63e4f3edab | 150 | } else |
okini3939 | 9:8c63e4f3edab | 151 | if (buf[2] == '%') { |
okini3939 | 9:8c63e4f3edab | 152 | exp->expression = EXP_NMOD; |
okini3939 | 9:8c63e4f3edab | 153 | exp->value = atof(&buf[3]); |
okini3939 | 9:8c63e4f3edab | 154 | } |
okini3939 | 9:8c63e4f3edab | 155 | break; |
okini3939 | 9:8c63e4f3edab | 156 | |
okini3939 | 9:8c63e4f3edab | 157 | case '<': |
okini3939 | 9:8c63e4f3edab | 158 | if (buf[2] == '=') { |
okini3939 | 9:8c63e4f3edab | 159 | exp->expression = EXP_LE; |
okini3939 | 9:8c63e4f3edab | 160 | exp->value = atof(&buf[3]); |
okini3939 | 9:8c63e4f3edab | 161 | } else { |
okini3939 | 9:8c63e4f3edab | 162 | exp->expression = EXP_LT; |
okini3939 | 9:8c63e4f3edab | 163 | exp->value = atof(&buf[2]); |
okini3939 | 9:8c63e4f3edab | 164 | } |
okini3939 | 9:8c63e4f3edab | 165 | break; |
okini3939 | 9:8c63e4f3edab | 166 | |
okini3939 | 9:8c63e4f3edab | 167 | case '>': |
okini3939 | 9:8c63e4f3edab | 168 | if (buf[2] == '=') { |
okini3939 | 9:8c63e4f3edab | 169 | exp->expression = EXP_GE; |
okini3939 | 9:8c63e4f3edab | 170 | exp->value = atof(&buf[3]); |
okini3939 | 9:8c63e4f3edab | 171 | } else { |
okini3939 | 9:8c63e4f3edab | 172 | exp->expression = EXP_GT; |
okini3939 | 9:8c63e4f3edab | 173 | exp->value = atof(&buf[2]); |
okini3939 | 9:8c63e4f3edab | 174 | } |
okini3939 | 9:8c63e4f3edab | 175 | break; |
okini3939 | 9:8c63e4f3edab | 176 | |
okini3939 | 9:8c63e4f3edab | 177 | case '%': |
okini3939 | 9:8c63e4f3edab | 178 | exp->expression = EXP_MOD; |
okini3939 | 9:8c63e4f3edab | 179 | exp->value = atof(&buf[2]); |
okini3939 | 9:8c63e4f3edab | 180 | break; |
okini3939 | 9:8c63e4f3edab | 181 | |
okini3939 | 9:8c63e4f3edab | 182 | default: |
okini3939 | 9:8c63e4f3edab | 183 | exp->expression = EXP_NULL; |
okini3939 | 9:8c63e4f3edab | 184 | break; |
okini3939 | 9:8c63e4f3edab | 185 | } |
okini3939 | 9:8c63e4f3edab | 186 | } |
okini3939 | 9:8c63e4f3edab | 187 | |
okini3939 | 9:8c63e4f3edab | 188 | void add_action (char *buf) { |
okini3939 | 9:8c63e4f3edab | 189 | int i, len, count; |
okini3939 | 9:8c63e4f3edab | 190 | char c; |
okini3939 | 9:8c63e4f3edab | 191 | char *tmp = NULL; |
okini3939 | 9:8c63e4f3edab | 192 | |
okini3939 | 9:8c63e4f3edab | 193 | if (conf.actionscount >= CF_ACTION_NUM) return; |
okini3939 | 9:8c63e4f3edab | 194 | |
okini3939 | 9:8c63e4f3edab | 195 | // conf.actions[conf.actionscount].action = atoi(&buf[0]); |
okini3939 | 9:8c63e4f3edab | 196 | conf.actions[conf.actionscount].action = buf[0]; |
okini3939 | 9:8c63e4f3edab | 197 | |
okini3939 | 9:8c63e4f3edab | 198 | count = 0; |
okini3939 | 9:8c63e4f3edab | 199 | strcat(buf, "\n"); |
okini3939 | 9:8c63e4f3edab | 200 | len = strlen(buf); |
okini3939 | 9:8c63e4f3edab | 201 | for (i = 0; i < len; i ++) { |
okini3939 | 9:8c63e4f3edab | 202 | c = buf[i]; |
okini3939 | 9:8c63e4f3edab | 203 | if (c == ' ' || c == '\t' || c == '\n' || c == '\r') { |
okini3939 | 9:8c63e4f3edab | 204 | buf[i] = 0; |
okini3939 | 9:8c63e4f3edab | 205 | if (count) { |
okini3939 | 9:8c63e4f3edab | 206 | add_actionsub(&conf.actions[conf.actionscount].exps[count - 1], tmp); |
okini3939 | 9:8c63e4f3edab | 207 | } |
okini3939 | 9:8c63e4f3edab | 208 | if (count >= CF_ACTION_EXPS || c == '\n') break; |
okini3939 | 9:8c63e4f3edab | 209 | tmp = &buf[i + 1]; |
okini3939 | 9:8c63e4f3edab | 210 | count ++; |
okini3939 | 9:8c63e4f3edab | 211 | } |
okini3939 | 9:8c63e4f3edab | 212 | } |
okini3939 | 9:8c63e4f3edab | 213 | |
okini3939 | 9:8c63e4f3edab | 214 | conf.actions[conf.actionscount].count = count; |
okini3939 | 9:8c63e4f3edab | 215 | conf.actionscount ++; |
okini3939 | 9:8c63e4f3edab | 216 | } |
okini3939 | 9:8c63e4f3edab | 217 | |
okini3939 | 9:8c63e4f3edab | 218 | int config (char *file) { |
okini3939 | 9:8c63e4f3edab | 219 | int i; |
okini3939 | 9:8c63e4f3edab | 220 | ConfigFile cfg; |
okini3939 | 9:8c63e4f3edab | 221 | char buf[80], key[20]; |
okini3939 | 9:8c63e4f3edab | 222 | int ip0, ip1, ip2, ip3; |
okini3939 | 9:8c63e4f3edab | 223 | |
okini3939 | 9:8c63e4f3edab | 224 | conf.ipaddr = IpAddr(0, 0, 0, 0); |
okini3939 | 9:8c63e4f3edab | 225 | conf.netmask = IpAddr(255, 255, 255, 0); |
okini3939 | 9:8c63e4f3edab | 226 | conf.gateway = IpAddr(0, 0, 0, 0); |
okini3939 | 9:8c63e4f3edab | 227 | conf.nameserver = IpAddr(0, 0, 0, 0); |
okini3939 | 9:8c63e4f3edab | 228 | conf.interval = 60; |
okini3939 | 9:8c63e4f3edab | 229 | conf.ntpserver[0] = 0; |
okini3939 | 9:8c63e4f3edab | 230 | conf.filetype = 0; |
okini3939 | 9:8c63e4f3edab | 231 | conf.actionscount = 0; |
okini3939 | 9:8c63e4f3edab | 232 | conf.pachube_apikey[0] = 0; |
okini3939 | 9:8c63e4f3edab | 233 | conf.pachube_feedid[0] = 0; |
okini3939 | 9:8c63e4f3edab | 234 | conf.twitter_user[0] = 0; |
okini3939 | 9:8c63e4f3edab | 235 | conf.twitter_pwd[0] = 0; |
okini3939 | 9:8c63e4f3edab | 236 | conf.twitter_mesg[0] = 0; |
okini3939 | 9:8c63e4f3edab | 237 | conf.stations_id[0] = 0; |
okini3939 | 9:8c63e4f3edab | 238 | conf.stations_pin[0] = 0; |
okini3939 | 9:8c63e4f3edab | 239 | conf.snmp_commname[0] = 0; |
okini3939 | 9:8c63e4f3edab | 240 | |
okini3939 | 9:8c63e4f3edab | 241 | if (! cfg.read(file)) { |
okini3939 | 9:8c63e4f3edab | 242 | return -1; |
okini3939 | 9:8c63e4f3edab | 243 | } |
okini3939 | 9:8c63e4f3edab | 244 | |
okini3939 | 9:8c63e4f3edab | 245 | if (cfg.getValue("INTERVAL", buf, sizeof(buf))) { |
okini3939 | 9:8c63e4f3edab | 246 | conf.interval = atoi(chop(buf)); |
okini3939 | 9:8c63e4f3edab | 247 | } |
okini3939 | 9:8c63e4f3edab | 248 | if (cfg.getValue("FILE", buf, sizeof(buf))) { |
okini3939 | 9:8c63e4f3edab | 249 | chop(buf); |
okini3939 | 9:8c63e4f3edab | 250 | if (strcmp(buf, "SD") == 0) { |
okini3939 | 9:8c63e4f3edab | 251 | conf.filetype = 1; |
okini3939 | 9:8c63e4f3edab | 252 | } else |
okini3939 | 9:8c63e4f3edab | 253 | if (strcmp(buf, "USB") == 0) { |
okini3939 | 9:8c63e4f3edab | 254 | conf.filetype = 2; |
okini3939 | 9:8c63e4f3edab | 255 | } |
okini3939 | 9:8c63e4f3edab | 256 | } |
okini3939 | 9:8c63e4f3edab | 257 | |
okini3939 | 9:8c63e4f3edab | 258 | if (cfg.getValue("IPADDRESS", buf, sizeof(buf))) { |
okini3939 | 9:8c63e4f3edab | 259 | chop(buf); |
okini3939 | 9:8c63e4f3edab | 260 | if (strcmp(buf, "DHCP") == 0) { |
okini3939 | 9:8c63e4f3edab | 261 | conf.ipaddr = IpAddr(255, 255, 255, 255); |
okini3939 | 9:8c63e4f3edab | 262 | } else { |
okini3939 | 9:8c63e4f3edab | 263 | sscanf(buf, "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3); |
okini3939 | 9:8c63e4f3edab | 264 | conf.ipaddr = IpAddr(ip0, ip1, ip2, ip3); |
okini3939 | 9:8c63e4f3edab | 265 | } |
okini3939 | 9:8c63e4f3edab | 266 | } |
okini3939 | 9:8c63e4f3edab | 267 | if (cfg.getValue("NETMASK", buf, sizeof(buf))) { |
okini3939 | 9:8c63e4f3edab | 268 | sscanf(chop(buf), "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3); |
okini3939 | 9:8c63e4f3edab | 269 | conf.netmask = IpAddr(ip0, ip1, ip2, ip3); |
okini3939 | 9:8c63e4f3edab | 270 | } |
okini3939 | 9:8c63e4f3edab | 271 | if (cfg.getValue("GATEWAY", buf, sizeof(buf))) { |
okini3939 | 9:8c63e4f3edab | 272 | sscanf(chop(buf), "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3); |
okini3939 | 9:8c63e4f3edab | 273 | conf.gateway = IpAddr(ip0, ip1, ip2, ip3); |
okini3939 | 9:8c63e4f3edab | 274 | } |
okini3939 | 9:8c63e4f3edab | 275 | if (cfg.getValue("NAMESERVER", buf, sizeof(buf))) { |
okini3939 | 9:8c63e4f3edab | 276 | sscanf(chop(buf), "%d.%d.%d.%d", &ip0, &ip1, &ip2, &ip3); |
okini3939 | 9:8c63e4f3edab | 277 | conf.nameserver = IpAddr(ip0, ip1, ip2, ip3); |
okini3939 | 9:8c63e4f3edab | 278 | } |
okini3939 | 9:8c63e4f3edab | 279 | |
okini3939 | 9:8c63e4f3edab | 280 | cfg.getValue("NTPSERVER", conf.ntpserver, sizeof(conf.ntpserver)); |
okini3939 | 9:8c63e4f3edab | 281 | chop(conf.ntpserver); |
okini3939 | 9:8c63e4f3edab | 282 | cfg.getValue("PACHUBE_APIKEY", conf.pachube_apikey, sizeof(conf.pachube_apikey)); |
okini3939 | 9:8c63e4f3edab | 283 | chop(conf.pachube_apikey); |
okini3939 | 9:8c63e4f3edab | 284 | cfg.getValue("PACHUBE_FEEDID", conf.pachube_feedid, sizeof(conf.pachube_feedid)); |
okini3939 | 9:8c63e4f3edab | 285 | chop(conf.pachube_feedid); |
okini3939 | 9:8c63e4f3edab | 286 | cfg.getValue("TWITTER_USER", conf.twitter_user, sizeof(conf.twitter_user)); |
okini3939 | 9:8c63e4f3edab | 287 | chop(conf.twitter_user); |
okini3939 | 9:8c63e4f3edab | 288 | cfg.getValue("TWITTER_PWD", conf.twitter_pwd, sizeof(conf.twitter_pwd)); |
okini3939 | 9:8c63e4f3edab | 289 | chop(conf.twitter_pwd); |
okini3939 | 9:8c63e4f3edab | 290 | cfg.getValue("TWITTER_MESG", conf.twitter_mesg, sizeof(conf.twitter_mesg)); |
okini3939 | 9:8c63e4f3edab | 291 | chop(conf.twitter_mesg); |
okini3939 | 9:8c63e4f3edab | 292 | cfg.getValue("STATIONS_ID", conf.stations_id, sizeof(conf.stations_id)); |
okini3939 | 9:8c63e4f3edab | 293 | chop(conf.stations_id); |
okini3939 | 9:8c63e4f3edab | 294 | cfg.getValue("STATIONS_PIN", conf.stations_pin, sizeof(conf.stations_pin)); |
okini3939 | 9:8c63e4f3edab | 295 | chop(conf.stations_pin); |
okini3939 | 9:8c63e4f3edab | 296 | cfg.getValue("SNMP_COMMNAME", conf.snmp_commname, sizeof(conf.snmp_commname)); |
okini3939 | 9:8c63e4f3edab | 297 | chop(conf.snmp_commname); |
okini3939 | 9:8c63e4f3edab | 298 | |
okini3939 | 9:8c63e4f3edab | 299 | if (cfg.getValue("XBEE", buf, sizeof(buf))) { |
okini3939 | 9:8c63e4f3edab | 300 | xbee.baud(atoi(chop(buf))); |
okini3939 | 9:8c63e4f3edab | 301 | } |
okini3939 | 9:8c63e4f3edab | 302 | |
okini3939 | 9:8c63e4f3edab | 303 | for (i = 0; i < CF_ACTION_NUM; i ++) { |
okini3939 | 9:8c63e4f3edab | 304 | sprintf(key, "ACTION[%d]", i); |
okini3939 | 9:8c63e4f3edab | 305 | if (cfg.getValue(key, buf, sizeof(buf))) { |
okini3939 | 9:8c63e4f3edab | 306 | add_action(chop(buf)); |
okini3939 | 9:8c63e4f3edab | 307 | } |
okini3939 | 9:8c63e4f3edab | 308 | } |
okini3939 | 9:8c63e4f3edab | 309 | |
okini3939 | 9:8c63e4f3edab | 310 | return 0; |
okini3939 | 9:8c63e4f3edab | 311 | } |