bowen liu
/
mbed-os-example-blinky
ex
Fork of mbed-os-example-mbed5-blinky by
Embed:
(wiki syntax)
Show/hide line numbers
baidu_status_reporter.h
00001 #ifndef BAIDU_OS_UTILITY_BAIDU_STATUS_REPORTER_H 00002 #define BAIDU_OS_UTILITY_BAIDU_STATUS_REPORTER_H 00003 00004 #include "rtos.h" 00005 #include "baidu_ca_object.h" 00006 00007 namespace duer { 00008 00009 #define REPORT_FUNCTION_MAX 8 00010 00011 typedef void (*ReportFunc)(Object&); 00012 00013 class StatusReporter { 00014 public: 00015 00016 static StatusReporter& obtain(); 00017 00018 // register the data report function 00019 // Note: only register one time 00020 // how to handle register multi-time 00021 // how to provide unregister function 00022 // return: 00023 // 0 success, -1 fail array is full -2 param report_function is null 00024 int register_report_function(ReportFunc report_function); 00025 00026 void start(); 00027 00028 void stop(); 00029 00030 // report the basic info after connect the network success 00031 void device_info_report(); 00032 00033 // report the status info every 5min 00034 void device_status_report(); 00035 00036 private: 00037 00038 StatusReporter(); 00039 00040 StatusReporter(const StatusReporter&); 00041 00042 StatusReporter& operator=(const StatusReporter&); 00043 00044 // timer for report statistic info about the device periodically 00045 rtos::RtosTimer _periodic_report_timer; 00046 00047 rtos::Mutex _report_functions_mutex; 00048 00049 ReportFunc _report_functions[REPORT_FUNCTION_MAX]; 00050 00051 volatile int _current_report_function_index; 00052 }; 00053 00054 } // namespace duer 00055 00056 #endif // BAIDU_OS_UTILITY_BAIDU_STATUS_REPORTER_H
Generated on Tue Jul 12 2022 16:28:53 by 1.7.2