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/iot-baidu-ca-scheduler/baidu_ca_handler.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 | // Copyright 2017 Baidu Inc. All Rights Reserved. |
| TMBOY | 47:9e361da97763 | 2 | // Author: Su Hao (suhao@baidu.com) |
| TMBOY | 47:9e361da97763 | 3 | // |
| TMBOY | 47:9e361da97763 | 4 | // Description: Handler |
| TMBOY | 47:9e361da97763 | 5 | |
| TMBOY | 47:9e361da97763 | 6 | #ifndef BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SCHEDULER_BAIDU_CA_HANDLER_H |
| TMBOY | 47:9e361da97763 | 7 | #define BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SCHEDULER_BAIDU_CA_HANDLER_H |
| TMBOY | 47:9e361da97763 | 8 | |
| TMBOY | 47:9e361da97763 | 9 | #include "rtos.h" |
| TMBOY | 47:9e361da97763 | 10 | #include "baidu_ca_message.h" |
| TMBOY | 47:9e361da97763 | 11 | |
| TMBOY | 47:9e361da97763 | 12 | namespace duer { |
| TMBOY | 47:9e361da97763 | 13 | |
| TMBOY | 47:9e361da97763 | 14 | class Handler { |
| TMBOY | 47:9e361da97763 | 15 | public: |
| TMBOY | 47:9e361da97763 | 16 | class OnMessageListener { |
| TMBOY | 47:9e361da97763 | 17 | public: |
| TMBOY | 47:9e361da97763 | 18 | |
| TMBOY | 47:9e361da97763 | 19 | virtual bool on_message(Message& message) = 0; |
| TMBOY | 47:9e361da97763 | 20 | |
| TMBOY | 47:9e361da97763 | 21 | virtual ~OnMessageListener() {} |
| TMBOY | 47:9e361da97763 | 22 | |
| TMBOY | 47:9e361da97763 | 23 | }; |
| TMBOY | 47:9e361da97763 | 24 | |
| TMBOY | 47:9e361da97763 | 25 | Handler(); |
| TMBOY | 47:9e361da97763 | 26 | |
| TMBOY | 47:9e361da97763 | 27 | virtual ~Handler(); |
| TMBOY | 47:9e361da97763 | 28 | |
| TMBOY | 47:9e361da97763 | 29 | void send_message(int what, void* object); |
| TMBOY | 47:9e361da97763 | 30 | |
| TMBOY | 47:9e361da97763 | 31 | void send_message(const Message& message); |
| TMBOY | 47:9e361da97763 | 32 | |
| TMBOY | 47:9e361da97763 | 33 | void set_on_message_listener(OnMessageListener* listener); |
| TMBOY | 47:9e361da97763 | 34 | |
| TMBOY | 47:9e361da97763 | 35 | protected: |
| TMBOY | 47:9e361da97763 | 36 | |
| TMBOY | 47:9e361da97763 | 37 | virtual void handle_message(Message& message); |
| TMBOY | 47:9e361da97763 | 38 | |
| TMBOY | 47:9e361da97763 | 39 | private: |
| TMBOY | 47:9e361da97763 | 40 | |
| TMBOY | 47:9e361da97763 | 41 | void loop(); |
| TMBOY | 47:9e361da97763 | 42 | |
| TMBOY | 47:9e361da97763 | 43 | rtos::Thread _thread; |
| TMBOY | 47:9e361da97763 | 44 | rtos::Queue<Message, 20> _queue; |
| TMBOY | 47:9e361da97763 | 45 | OnMessageListener* _listener; |
| TMBOY | 47:9e361da97763 | 46 | }; |
| TMBOY | 47:9e361da97763 | 47 | |
| TMBOY | 47:9e361da97763 | 48 | } // namespace duer |
| TMBOY | 47:9e361da97763 | 49 | |
| TMBOY | 47:9e361da97763 | 50 | #endif // BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SCHEDULER_BAIDU_CA_HANDLER_H |
