| 1 | /** |
|---|
| 2 | \brief PC-specific definition of the "leds" bsp module. |
|---|
| 3 | |
|---|
| 4 | \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, April 2012. |
|---|
| 5 | */ |
|---|
| 6 | |
|---|
| 7 | #include "leds.h" |
|---|
| 8 | #include "opensim_proto.h" |
|---|
| 9 | |
|---|
| 10 | //=========================== defines ========================================= |
|---|
| 11 | |
|---|
| 12 | //=========================== variables ======================================= |
|---|
| 13 | |
|---|
| 14 | //=========================== prototypes ====================================== |
|---|
| 15 | |
|---|
| 16 | //=========================== public ========================================== |
|---|
| 17 | |
|---|
| 18 | void leds_init() { |
|---|
| 19 | opensim_requ_leds_init_t requ; |
|---|
| 20 | opensim_repl_leds_init_t repl; |
|---|
| 21 | |
|---|
| 22 | // prepare request |
|---|
| 23 | requ.cmdId = OPENSIM_CMD_leds_init; |
|---|
| 24 | |
|---|
| 25 | // send request to server and get reply |
|---|
| 26 | opensim_client_send((void*)&requ, |
|---|
| 27 | sizeof(opensim_requ_leds_init_t), |
|---|
| 28 | (void*)&repl, |
|---|
| 29 | sizeof(opensim_repl_leds_init_t)); |
|---|
| 30 | |
|---|
| 31 | // make sure server did not return any errors |
|---|
| 32 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 33 | printf("ERROR rc=%d for leds_init\n",repl.rc); |
|---|
| 34 | } |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | void leds_error_on() { |
|---|
| 38 | opensim_requ_leds_error_on_t requ; |
|---|
| 39 | opensim_repl_leds_error_on_t repl; |
|---|
| 40 | |
|---|
| 41 | // prepare request |
|---|
| 42 | requ.cmdId = OPENSIM_CMD_leds_error_on; |
|---|
| 43 | |
|---|
| 44 | // send request to server and get reply |
|---|
| 45 | opensim_client_send((void*)&requ, |
|---|
| 46 | sizeof(opensim_requ_leds_error_on_t), |
|---|
| 47 | (void*)&repl, |
|---|
| 48 | sizeof(opensim_repl_leds_error_on_t)); |
|---|
| 49 | |
|---|
| 50 | // make sure server did not return any errors |
|---|
| 51 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 52 | printf("ERROR rc=%d for leds_error_on\n",repl.rc); |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | void leds_error_off() { |
|---|
| 56 | opensim_requ_leds_error_off_t requ; |
|---|
| 57 | opensim_repl_leds_error_off_t repl; |
|---|
| 58 | |
|---|
| 59 | // prepare request |
|---|
| 60 | requ.cmdId = OPENSIM_CMD_leds_error_off; |
|---|
| 61 | |
|---|
| 62 | // send request to server and get reply |
|---|
| 63 | opensim_client_send((void*)&requ, |
|---|
| 64 | sizeof(opensim_requ_leds_error_off_t), |
|---|
| 65 | (void*)&repl, |
|---|
| 66 | sizeof(opensim_repl_leds_error_off_t)); |
|---|
| 67 | |
|---|
| 68 | // make sure server did not return any errors |
|---|
| 69 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 70 | printf("ERROR rc=%d for leds_error_off\n",repl.rc); |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | void leds_error_toggle() { |
|---|
| 74 | opensim_requ_leds_error_toggle_t requ; |
|---|
| 75 | opensim_repl_leds_error_toggle_t repl; |
|---|
| 76 | |
|---|
| 77 | // prepare request |
|---|
| 78 | requ.cmdId = OPENSIM_CMD_leds_error_toggle; |
|---|
| 79 | |
|---|
| 80 | // send request to server and get reply |
|---|
| 81 | opensim_client_send((void*)&requ, |
|---|
| 82 | sizeof(opensim_requ_leds_error_toggle_t), |
|---|
| 83 | (void*)&repl, |
|---|
| 84 | sizeof(opensim_repl_leds_error_toggle_t)); |
|---|
| 85 | |
|---|
| 86 | // make sure server did not return any errors |
|---|
| 87 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 88 | printf("ERROR rc=%d for leds_error_toggle\n",repl.rc); |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | uint8_t leds_error_isOn() { |
|---|
| 92 | opensim_requ_leds_error_isOn_t requ; |
|---|
| 93 | opensim_repl_leds_error_isOn_t repl; |
|---|
| 94 | |
|---|
| 95 | // prepare request |
|---|
| 96 | requ.cmdId = OPENSIM_CMD_leds_error_isOn; |
|---|
| 97 | |
|---|
| 98 | // send request to server and get reply |
|---|
| 99 | opensim_client_send((void*)&requ, |
|---|
| 100 | sizeof(opensim_requ_leds_error_isOn_t), |
|---|
| 101 | (void*)&repl, |
|---|
| 102 | sizeof(opensim_repl_leds_error_isOn_t)); |
|---|
| 103 | |
|---|
| 104 | // make sure server did not return any errors |
|---|
| 105 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 106 | printf("ERROR rc=%d for leds_error_isOn\n",repl.rc); |
|---|
| 107 | } |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | void leds_radio_on() { |
|---|
| 111 | opensim_requ_leds_radio_on_t requ; |
|---|
| 112 | opensim_repl_leds_radio_on_t repl; |
|---|
| 113 | |
|---|
| 114 | // prepare request |
|---|
| 115 | requ.cmdId = OPENSIM_CMD_leds_radio_on; |
|---|
| 116 | |
|---|
| 117 | // send request to server and get reply |
|---|
| 118 | opensim_client_send((void*)&requ, |
|---|
| 119 | sizeof(opensim_requ_leds_radio_on_t), |
|---|
| 120 | (void*)&repl, |
|---|
| 121 | sizeof(opensim_repl_leds_radio_on_t)); |
|---|
| 122 | |
|---|
| 123 | // make sure server did not return any errors |
|---|
| 124 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 125 | printf("ERROR rc=%d for leds_radio_on\n",repl.rc); |
|---|
| 126 | } |
|---|
| 127 | } |
|---|
| 128 | void leds_radio_off() { |
|---|
| 129 | opensim_requ_leds_radio_off_t requ; |
|---|
| 130 | opensim_repl_leds_radio_off_t repl; |
|---|
| 131 | |
|---|
| 132 | // prepare request |
|---|
| 133 | requ.cmdId = OPENSIM_CMD_leds_radio_off; |
|---|
| 134 | |
|---|
| 135 | // send request to server and get reply |
|---|
| 136 | opensim_client_send((void*)&requ, |
|---|
| 137 | sizeof(opensim_requ_leds_radio_off_t), |
|---|
| 138 | (void*)&repl, |
|---|
| 139 | sizeof(opensim_repl_leds_radio_off_t)); |
|---|
| 140 | |
|---|
| 141 | // make sure server did not return any errors |
|---|
| 142 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 143 | printf("ERROR rc=%d for leds_radio_off\n",repl.rc); |
|---|
| 144 | } |
|---|
| 145 | } |
|---|
| 146 | void leds_radio_toggle() { |
|---|
| 147 | opensim_requ_leds_radio_toggle_t requ; |
|---|
| 148 | opensim_repl_leds_radio_toggle_t repl; |
|---|
| 149 | |
|---|
| 150 | // prepare request |
|---|
| 151 | requ.cmdId = OPENSIM_CMD_leds_radio_toggle; |
|---|
| 152 | |
|---|
| 153 | // send request to server and get reply |
|---|
| 154 | opensim_client_send((void*)&requ, |
|---|
| 155 | sizeof(opensim_requ_leds_radio_toggle_t), |
|---|
| 156 | (void*)&repl, |
|---|
| 157 | sizeof(opensim_repl_leds_radio_toggle_t)); |
|---|
| 158 | |
|---|
| 159 | // make sure server did not return any errors |
|---|
| 160 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 161 | printf("ERROR rc=%d for leds_radio_toggle\n",repl.rc); |
|---|
| 162 | } |
|---|
| 163 | } |
|---|
| 164 | uint8_t leds_radio_isOn() { |
|---|
| 165 | opensim_requ_leds_radio_isOn_t requ; |
|---|
| 166 | opensim_repl_leds_radio_isOn_t repl; |
|---|
| 167 | |
|---|
| 168 | // prepare request |
|---|
| 169 | requ.cmdId = OPENSIM_CMD_leds_radio_isOn; |
|---|
| 170 | |
|---|
| 171 | // send request to server and get reply |
|---|
| 172 | opensim_client_send((void*)&requ, |
|---|
| 173 | sizeof(opensim_requ_leds_radio_isOn_t), |
|---|
| 174 | (void*)&repl, |
|---|
| 175 | sizeof(opensim_repl_leds_radio_isOn_t)); |
|---|
| 176 | |
|---|
| 177 | // make sure server did not return any errors |
|---|
| 178 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 179 | printf("ERROR rc=%d for leds_radio_isOn\n",repl.rc); |
|---|
| 180 | } |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | // green |
|---|
| 184 | void leds_sync_on() { |
|---|
| 185 | opensim_requ_leds_sync_on_t requ; |
|---|
| 186 | opensim_repl_leds_sync_on_t repl; |
|---|
| 187 | |
|---|
| 188 | // prepare request |
|---|
| 189 | requ.cmdId = OPENSIM_CMD_leds_sync_on; |
|---|
| 190 | |
|---|
| 191 | // send request to server and get reply |
|---|
| 192 | opensim_client_send((void*)&requ, |
|---|
| 193 | sizeof(opensim_requ_leds_sync_on_t), |
|---|
| 194 | (void*)&repl, |
|---|
| 195 | sizeof(opensim_repl_leds_sync_on_t)); |
|---|
| 196 | |
|---|
| 197 | // make sure server did not return any errors |
|---|
| 198 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 199 | printf("ERROR rc=%d for leds_sync_on\n",repl.rc); |
|---|
| 200 | } |
|---|
| 201 | } |
|---|
| 202 | void leds_sync_off() { |
|---|
| 203 | opensim_requ_leds_sync_off_t requ; |
|---|
| 204 | opensim_repl_leds_sync_off_t repl; |
|---|
| 205 | |
|---|
| 206 | // prepare request |
|---|
| 207 | requ.cmdId = OPENSIM_CMD_leds_sync_off; |
|---|
| 208 | |
|---|
| 209 | // send request to server and get reply |
|---|
| 210 | opensim_client_send((void*)&requ, |
|---|
| 211 | sizeof(opensim_requ_leds_sync_off_t), |
|---|
| 212 | (void*)&repl, |
|---|
| 213 | sizeof(opensim_repl_leds_sync_off_t)); |
|---|
| 214 | |
|---|
| 215 | // make sure server did not return any errors |
|---|
| 216 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 217 | printf("ERROR rc=%d for leds_sync_off\n",repl.rc); |
|---|
| 218 | } |
|---|
| 219 | } |
|---|
| 220 | void leds_sync_toggle() { |
|---|
| 221 | opensim_requ_leds_sync_toggle_t requ; |
|---|
| 222 | opensim_repl_leds_sync_toggle_t repl; |
|---|
| 223 | |
|---|
| 224 | // prepare request |
|---|
| 225 | requ.cmdId = OPENSIM_CMD_leds_sync_toggle; |
|---|
| 226 | |
|---|
| 227 | // send request to server and get reply |
|---|
| 228 | opensim_client_send((void*)&requ, |
|---|
| 229 | sizeof(opensim_requ_leds_sync_toggle_t), |
|---|
| 230 | (void*)&repl, |
|---|
| 231 | sizeof(opensim_repl_leds_sync_toggle_t)); |
|---|
| 232 | |
|---|
| 233 | // make sure server did not return any errors |
|---|
| 234 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 235 | printf("ERROR rc=%d for leds_sync_toggle\n",repl.rc); |
|---|
| 236 | } |
|---|
| 237 | } |
|---|
| 238 | uint8_t leds_sync_isOn() { |
|---|
| 239 | opensim_requ_leds_sync_isOn_t requ; |
|---|
| 240 | opensim_repl_leds_sync_isOn_t repl; |
|---|
| 241 | |
|---|
| 242 | // prepare request |
|---|
| 243 | requ.cmdId = OPENSIM_CMD_leds_sync_isOn; |
|---|
| 244 | |
|---|
| 245 | // send request to server and get reply |
|---|
| 246 | opensim_client_send((void*)&requ, |
|---|
| 247 | sizeof(opensim_requ_leds_sync_isOn_t), |
|---|
| 248 | (void*)&repl, |
|---|
| 249 | sizeof(opensim_repl_leds_sync_isOn_t)); |
|---|
| 250 | |
|---|
| 251 | // make sure server did not return any errors |
|---|
| 252 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 253 | printf("ERROR rc=%d for leds_sync_isOn\n",repl.rc); |
|---|
| 254 | } |
|---|
| 255 | } |
|---|
| 256 | |
|---|
| 257 | // yellow |
|---|
| 258 | void leds_debug_on() { |
|---|
| 259 | opensim_requ_leds_debug_on_t requ; |
|---|
| 260 | opensim_repl_leds_debug_on_t repl; |
|---|
| 261 | |
|---|
| 262 | // prepare request |
|---|
| 263 | requ.cmdId = OPENSIM_CMD_leds_debug_on; |
|---|
| 264 | |
|---|
| 265 | // send request to server and get reply |
|---|
| 266 | opensim_client_send((void*)&requ, |
|---|
| 267 | sizeof(opensim_requ_leds_debug_on_t), |
|---|
| 268 | (void*)&repl, |
|---|
| 269 | sizeof(opensim_repl_leds_debug_on_t)); |
|---|
| 270 | |
|---|
| 271 | // make sure server did not return any errors |
|---|
| 272 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 273 | printf("ERROR rc=%d for leds_debug_on\n",repl.rc); |
|---|
| 274 | } |
|---|
| 275 | } |
|---|
| 276 | void leds_debug_off() { |
|---|
| 277 | opensim_requ_leds_debug_off_t requ; |
|---|
| 278 | opensim_repl_leds_debug_off_t repl; |
|---|
| 279 | |
|---|
| 280 | // prepare request |
|---|
| 281 | requ.cmdId = OPENSIM_CMD_leds_debug_off; |
|---|
| 282 | |
|---|
| 283 | // send request to server and get reply |
|---|
| 284 | opensim_client_send((void*)&requ, |
|---|
| 285 | sizeof(opensim_requ_leds_debug_off_t), |
|---|
| 286 | (void*)&repl, |
|---|
| 287 | sizeof(opensim_repl_leds_debug_off_t)); |
|---|
| 288 | |
|---|
| 289 | // make sure server did not return any errors |
|---|
| 290 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 291 | printf("ERROR rc=%d for leds_debug_off\n",repl.rc); |
|---|
| 292 | } |
|---|
| 293 | } |
|---|
| 294 | void leds_debug_toggle() { |
|---|
| 295 | opensim_requ_leds_debug_toggle_t requ; |
|---|
| 296 | opensim_repl_leds_debug_toggle_t repl; |
|---|
| 297 | |
|---|
| 298 | // prepare request |
|---|
| 299 | requ.cmdId = OPENSIM_CMD_leds_debug_toggle; |
|---|
| 300 | |
|---|
| 301 | // send request to server and get reply |
|---|
| 302 | opensim_client_send((void*)&requ, |
|---|
| 303 | sizeof(opensim_requ_leds_debug_toggle_t), |
|---|
| 304 | (void*)&repl, |
|---|
| 305 | sizeof(opensim_repl_leds_debug_toggle_t)); |
|---|
| 306 | |
|---|
| 307 | // make sure server did not return any errors |
|---|
| 308 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 309 | printf("ERROR rc=%d for leds_debug_toggle\n",repl.rc); |
|---|
| 310 | } |
|---|
| 311 | } |
|---|
| 312 | uint8_t leds_debug_isOn() { |
|---|
| 313 | opensim_requ_leds_debug_isOn_t requ; |
|---|
| 314 | opensim_repl_leds_debug_isOn_t repl; |
|---|
| 315 | |
|---|
| 316 | // prepare request |
|---|
| 317 | requ.cmdId = OPENSIM_CMD_leds_debug_isOn; |
|---|
| 318 | |
|---|
| 319 | // send request to server and get reply |
|---|
| 320 | opensim_client_send((void*)&requ, |
|---|
| 321 | sizeof(opensim_requ_leds_debug_isOn_t), |
|---|
| 322 | (void*)&repl, |
|---|
| 323 | sizeof(opensim_repl_leds_debug_isOn_t)); |
|---|
| 324 | |
|---|
| 325 | // make sure server did not return any errors |
|---|
| 326 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 327 | printf("ERROR rc=%d for leds_debug_isOn\n",repl.rc); |
|---|
| 328 | } |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | void leds_all_on() { |
|---|
| 332 | opensim_requ_leds_all_on_t requ; |
|---|
| 333 | opensim_repl_leds_all_on_t repl; |
|---|
| 334 | |
|---|
| 335 | // prepare request |
|---|
| 336 | requ.cmdId = OPENSIM_CMD_leds_all_on; |
|---|
| 337 | |
|---|
| 338 | // send request to server and get reply |
|---|
| 339 | opensim_client_send((void*)&requ, |
|---|
| 340 | sizeof(opensim_requ_leds_all_on_t), |
|---|
| 341 | (void*)&repl, |
|---|
| 342 | sizeof(opensim_repl_leds_all_on_t)); |
|---|
| 343 | |
|---|
| 344 | // make sure server did not return any errors |
|---|
| 345 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 346 | printf("ERROR rc=%d for leds_all_on\n",repl.rc); |
|---|
| 347 | } |
|---|
| 348 | } |
|---|
| 349 | void leds_all_off() { |
|---|
| 350 | opensim_requ_leds_all_off_t requ; |
|---|
| 351 | opensim_repl_leds_all_off_t repl; |
|---|
| 352 | |
|---|
| 353 | // prepare request |
|---|
| 354 | requ.cmdId = OPENSIM_CMD_leds_all_off; |
|---|
| 355 | |
|---|
| 356 | // send request to server and get reply |
|---|
| 357 | opensim_client_send((void*)&requ, |
|---|
| 358 | sizeof(opensim_requ_leds_all_off_t), |
|---|
| 359 | (void*)&repl, |
|---|
| 360 | sizeof(opensim_repl_leds_all_off_t)); |
|---|
| 361 | |
|---|
| 362 | // make sure server did not return any errors |
|---|
| 363 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 364 | printf("ERROR rc=%d for leds_all_off\n",repl.rc); |
|---|
| 365 | } |
|---|
| 366 | } |
|---|
| 367 | void leds_all_toggle() { |
|---|
| 368 | opensim_requ_leds_all_toggle_t requ; |
|---|
| 369 | opensim_repl_leds_all_toggle_t repl; |
|---|
| 370 | |
|---|
| 371 | // prepare request |
|---|
| 372 | requ.cmdId = OPENSIM_CMD_leds_all_toggle; |
|---|
| 373 | |
|---|
| 374 | // send request to server and get reply |
|---|
| 375 | opensim_client_send((void*)&requ, |
|---|
| 376 | sizeof(opensim_requ_leds_all_toggle_t), |
|---|
| 377 | (void*)&repl, |
|---|
| 378 | sizeof(opensim_repl_leds_all_toggle_t)); |
|---|
| 379 | |
|---|
| 380 | // make sure server did not return any errors |
|---|
| 381 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 382 | printf("ERROR rc=%d for leds_all_toggle\n",repl.rc); |
|---|
| 383 | } |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | void leds_circular_shift() { |
|---|
| 387 | opensim_requ_leds_circular_shift_t requ; |
|---|
| 388 | opensim_repl_leds_circular_shift_t repl; |
|---|
| 389 | |
|---|
| 390 | // prepare request |
|---|
| 391 | requ.cmdId = OPENSIM_CMD_leds_circular_shift; |
|---|
| 392 | |
|---|
| 393 | // send request to server and get reply |
|---|
| 394 | opensim_client_send((void*)&requ, |
|---|
| 395 | sizeof(opensim_requ_leds_circular_shift_t), |
|---|
| 396 | (void*)&repl, |
|---|
| 397 | sizeof(opensim_repl_leds_circular_shift_t)); |
|---|
| 398 | |
|---|
| 399 | // make sure server did not return any errors |
|---|
| 400 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 401 | printf("ERROR rc=%d for leds_circular_shift\n",repl.rc); |
|---|
| 402 | } |
|---|
| 403 | } |
|---|
| 404 | |
|---|
| 405 | void leds_increment() { |
|---|
| 406 | opensim_requ_leds_increment_t requ; |
|---|
| 407 | opensim_repl_leds_increment_t repl; |
|---|
| 408 | |
|---|
| 409 | // prepare request |
|---|
| 410 | requ.cmdId = OPENSIM_CMD_leds_increment; |
|---|
| 411 | |
|---|
| 412 | // send request to server and get reply |
|---|
| 413 | opensim_client_send((void*)&requ, |
|---|
| 414 | sizeof(opensim_requ_leds_increment_t), |
|---|
| 415 | (void*)&repl, |
|---|
| 416 | sizeof(opensim_repl_leds_increment_t)); |
|---|
| 417 | |
|---|
| 418 | // make sure server did not return any errors |
|---|
| 419 | if (repl.rc!=OPENSIM_ERR_NONE) { |
|---|
| 420 | printf("ERROR rc=%d for leds_increment\n",repl.rc); |
|---|
| 421 | } |
|---|
| 422 | } |
|---|
| 423 | |
|---|
| 424 | //=========================== private ========================================= |
|---|