| Algorithm 1 Wireless sensor application main activities | |
| 1: | Initialize components |
| 2: | Set sensors parameters |
| 3: | whileTruedo ▹ Main app. loop |
| 4: | Process BLE events |
| 5: | if (1 min. passed) then |
| 6: | if (batt. level or light data from RAM > thresholds) then ▹ From prev. active period |
| 7: | Power up sensors |
| 8: | Wake up all components ▹ Can be executed even if device was not in low power mode |
| 9: | Measure T and RH, save data to RAM |
| 10: | Get light intensity, save data to RAM |
| 11: | Perform gas measurement, save data to RAM |
| 12: | Put all components in sleep mode |
| 13: | Power down sensors |
| 14: | end if |
| 15: | Get batt. level, save data to RAM |
| 16: | end if |
| 17: | Update advertising payload with data from RAM |
| 18: | Enter low power mode |
| 19: | end while |