Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/src/utility/baidu_status_reporter.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | #ifndef BAIDU_OS_UTILITY_BAIDU_STATUS_REPORTER_H |
| TMBOY | 47:9e361da97763 | 2 | #define BAIDU_OS_UTILITY_BAIDU_STATUS_REPORTER_H |
| TMBOY | 47:9e361da97763 | 3 | |
| TMBOY | 47:9e361da97763 | 4 | #include "rtos.h" |
| TMBOY | 47:9e361da97763 | 5 | #include "baidu_ca_object.h" |
| TMBOY | 47:9e361da97763 | 6 | |
| TMBOY | 47:9e361da97763 | 7 | namespace duer { |
| TMBOY | 47:9e361da97763 | 8 | |
| TMBOY | 47:9e361da97763 | 9 | #define REPORT_FUNCTION_MAX 8 |
| TMBOY | 47:9e361da97763 | 10 | |
| TMBOY | 47:9e361da97763 | 11 | typedef void (*ReportFunc)(Object&); |
| TMBOY | 47:9e361da97763 | 12 | |
| TMBOY | 47:9e361da97763 | 13 | class StatusReporter { |
| TMBOY | 47:9e361da97763 | 14 | public: |
| TMBOY | 47:9e361da97763 | 15 | |
| TMBOY | 47:9e361da97763 | 16 | static StatusReporter& obtain(); |
| TMBOY | 47:9e361da97763 | 17 | |
| TMBOY | 47:9e361da97763 | 18 | // register the data report function |
| TMBOY | 47:9e361da97763 | 19 | // Note: only register one time |
| TMBOY | 47:9e361da97763 | 20 | // how to handle register multi-time |
| TMBOY | 47:9e361da97763 | 21 | // how to provide unregister function |
| TMBOY | 47:9e361da97763 | 22 | // return: |
| TMBOY | 47:9e361da97763 | 23 | // 0 success, -1 fail array is full -2 param report_function is null |
| TMBOY | 47:9e361da97763 | 24 | int register_report_function(ReportFunc report_function); |
| TMBOY | 47:9e361da97763 | 25 | |
| TMBOY | 47:9e361da97763 | 26 | void start(); |
| TMBOY | 47:9e361da97763 | 27 | |
| TMBOY | 47:9e361da97763 | 28 | void stop(); |
| TMBOY | 47:9e361da97763 | 29 | |
| TMBOY | 47:9e361da97763 | 30 | // report the basic info after connect the network success |
| TMBOY | 47:9e361da97763 | 31 | void device_info_report(); |
| TMBOY | 47:9e361da97763 | 32 | |
| TMBOY | 47:9e361da97763 | 33 | // report the status info every 5min |
| TMBOY | 47:9e361da97763 | 34 | void device_status_report(); |
| TMBOY | 47:9e361da97763 | 35 | |
| TMBOY | 47:9e361da97763 | 36 | private: |
| TMBOY | 47:9e361da97763 | 37 | |
| TMBOY | 47:9e361da97763 | 38 | StatusReporter(); |
| TMBOY | 47:9e361da97763 | 39 | |
| TMBOY | 47:9e361da97763 | 40 | StatusReporter(const StatusReporter&); |
| TMBOY | 47:9e361da97763 | 41 | |
| TMBOY | 47:9e361da97763 | 42 | StatusReporter& operator=(const StatusReporter&); |
| TMBOY | 47:9e361da97763 | 43 | |
| TMBOY | 47:9e361da97763 | 44 | // timer for report statistic info about the device periodically |
| TMBOY | 47:9e361da97763 | 45 | rtos::RtosTimer _periodic_report_timer; |
| TMBOY | 47:9e361da97763 | 46 | |
| TMBOY | 47:9e361da97763 | 47 | rtos::Mutex _report_functions_mutex; |
| TMBOY | 47:9e361da97763 | 48 | |
| TMBOY | 47:9e361da97763 | 49 | ReportFunc _report_functions[REPORT_FUNCTION_MAX]; |
| TMBOY | 47:9e361da97763 | 50 | |
| TMBOY | 47:9e361da97763 | 51 | volatile int _current_report_function_index; |
| TMBOY | 47:9e361da97763 | 52 | }; |
| TMBOY | 47:9e361da97763 | 53 | |
| TMBOY | 47:9e361da97763 | 54 | } // namespace duer |
| TMBOY | 47:9e361da97763 | 55 | |
| TMBOY | 47:9e361da97763 | 56 | #endif // BAIDU_OS_UTILITY_BAIDU_STATUS_REPORTER_H |
