1 /* 2 * Copyright (C) 2015-2019 Alibaba Group Holding Limited 3 */ 4 #ifndef UAGENT_API_H 5 #define UAGENT_API_H 6 #include <stdbool.h> 7 #include <stdio.h> 8 #include "uagent_config.h" 9 #include "uagent_type.h" 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 typedef struct { 15 char initd; 16 char service_started; 17 ua_send_policy_t to_console; 18 char cloud_connect; 19 char pk[PK_STR_SIZE]; 20 char dn[DN_STR_SIZE]; 21 } uagent_service_attr_t; 22 extern uagent_service_attr_t uagent_service_attr; 23 24 #define UAGENT_INITED_FINISH (UAGENT_INITED == uagent_service_attr.initd) 25 26 void uagent_init_mutex(void); 27 28 bool uagent_get_mutex(void); 29 30 void uagent_release_mutex(void); 31 32 int add_list(mod_func_t *mod_func_tree, const ua_func_t func, char *func_name); 33 int del_list(mod_func_t *mod_func_tree, const ua_func_t func); 34 35 36 typedef int (*on_recv_handler) (const unsigned short len, const char* str); 37 38 int uagent_ext_comm_init(const char pk[12], const char dn[36], on_recv_handler handler); 39 40 int uagent_ext_comm_publish(const unsigned short len, void* data, const bool conn_orient); 41 42 int uagent_ack(const service_agent_rlt_t rlt, 43 const unsigned long id, 44 const ua_mod_t mod, 45 const ua_func_t type, 46 const void* info_str); 47 48 /* REMARK: return 1 indicates connecting */ 49 char check_connect(); 50 51 void start_monitor_delay_out(); 52 void stop_monitor_delay_out(); 53 54 55 #define UAGENT_DEBUG(fmt, ...) //printf("<D>UA %s[%d]: "fmt"\r\n", __func__, __LINE__, ##__VA_ARGS__) 56 57 58 #define UAGENT_INFO(fmt, ...) printf("<I>UA %s[%d]: "fmt"\r\n", __func__, __LINE__, ##__VA_ARGS__) 59 60 #define UAGENT_ERR(fmt, ...) printf("<E>UA %s[%d]: "fmt"\r\n", __func__, __LINE__, ##__VA_ARGS__) 61 62 #ifdef __cplusplus 63 } 64 #endif 65 66 #endif /* !UAGENT_API_H */ 67