framework_compat.h 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #ifndef _INFRA_COMPAT_H_
  2. #define _INFRA_COMPAT_H_
  3. enum iot_event_t {
  4. IOT_REGISTER_SUCCESS = 0,
  5. IOT_LOGIN_SUCCESS,
  6. IOT_CONNECT_CLOUD_SUCCESS,
  7. IOT_REGISTER_FAILT,
  8. IOT_LOGIN_FAILT,
  9. IOT_CONNECT_CLOUD_FAILT,
  10. };
  11. int iotx_event_post(int event);
  12. // 注册事件回调
  13. int iotx_event_regist_cb(void (*monitor_cb)(int event));
  14. #define IOT_RegisterCallback(evt, cb) iotx_register_for_##evt(cb);
  15. #define DECLARE_EVENT_CALLBACK(evt, cb) int iotx_register_for_##evt(cb);
  16. #define DEFINE_EVENT_CALLBACK(evt, cb) int iotx_register_for_##evt(cb) { \
  17. if (evt < 0 || evt >= sizeof(g_impl_event_map)/sizeof(impl_event_map_t)) {return -1;} \
  18. g_impl_event_map[evt].callback = (void *)callback;return 0;}
  19. DECLARE_EVENT_CALLBACK(IOT_REGISTER_SUCCESS, void(*cb)(void))
  20. DECLARE_EVENT_CALLBACK(IOT_LOGIN_SUCCESS, void(*cb)(void))
  21. DECLARE_EVENT_CALLBACK(IOT_CONNECT_CLOUD_SUCCESS, void(*cb)(void))
  22. DECLARE_EVENT_CALLBACK(IOT_REGISTER_FAILT, void(*cb)(void))
  23. DECLARE_EVENT_CALLBACK(IOT_LOGIN_FAILT, void(*cb)(void))
  24. DECLARE_EVENT_CALLBACK(IOT_REGISTER_FAILT, void(*cb)(void))
  25. #endif