1 /* 2 * Copyright (C) 2015-2019 Alibaba Group Holding Limited 3 */ 4 5 #ifndef UAGENT_H 6 #define UAGENT_H 7 8 #include "uagent_type.h" 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 /** 15 * Register service routine from customer into uagent for delegate 16 * Update the cb if the same mod and func alreay registered before. 17 * 18 * @param[in] mod Module type, reference @ua_mod_t 19 * @param[in] mod_name Name of module, only user module fill this, pre-define module use NULL. 20 * @param[in] version Version of module, usually comes from aos.mk 21 * @param[in] func Service Name 22 * @param[in] func_name Name of service 23 * @param[in] cb Service Routine 24 * @param[in] arg Argument of the function. 25 * 26 * @return 0: Success, -EINVAL: invalid parameter, -EIO: Service mapping table 27 * has no enough room for new service 28 */ 29 int uagent_register(const ua_mod_t mod, const char *mod_name, char *version, 30 const ua_func_t func, const char *func_name, 31 on_customer_service cb, void *arg); 32 33 /** 34 * Un-register service routine 35 * 36 * @param[in] mod Module type, reference @ua_mod_t 37 * @param[in] func Service Name 38 * 39 * @return 0: Success, -1: Fail 40 */ 41 int uagent_unregister(const ua_mod_t mod, const ua_func_t func); 42 43 /** 44 * Request other's module's service. 45 * Remark: Customer can call any service(in case of the service exist), 46 * even this customer doesn't offer any service 47 * 48 * @param[in] src Source module type, reference @ua_mod_t 49 * @param[in] target Target module type, reference @ua_mod_t 50 * @param[in] func Function type, include pre-define func and customer's define 51 * @param[in] len Argument string's length 52 * @param[in] info_str Argument string 53 * 54 * @return 0: Success, -EINVAL: invalid parameter, -EIO: Service mapping table 55 * has no enough room for new service 56 */ 57 int uagent_request_service(const ua_mod_t src, const ua_mod_t target, 58 const ua_func_t func, const unsigned short len, 59 const void *info_str); 60 61 /** 62 * Publish customer's info. 63 * Remark: Customer can call any service(in case of the service exist), even this 64 * customer doesn't offer any service 65 * 66 * 67 * @param[in] mod Source module type, reference @ua_mod_t 68 * @param[in] type Type indicates info_str, not necessary 69 * @param[in] len Argument string's length 70 * @param[in] info_str Argument string 71 * @param[in] policy Values are constructed by a bitwise-inclusive OR of flags 72 * from the @send_policy_bit_ctrl_t 73 * 74 * @return 0: Success, -EINVAL: invalid parameter, -EIO: Service mapping table 75 * has no enough room for new service 76 */ 77 int uagent_send(const ua_mod_t mod, const ua_func_t type, 78 const unsigned short len, const void *info_str, 79 const ua_send_policy_t policy); 80 81 /** 82 * Initial uagent function 83 * 84 * @return 0: Success 85 */ 86 int uagent_init(void); 87 88 /** 89 * Start uagent ext comm service 90 * Remark: Event return 0 doesn't indicates the connection already build 91 * 92 * @param[in] pk Product Key 93 * @param[in] dn Device Name 94 * 95 * @return 0: Success, -1 fail 96 */ 97 int uagent_ext_comm_start(const char *pk, const char *dn); 98 99 #ifdef __cplusplus 100 } 101 #endif 102 103 #endif /* UAGENT_H */ 104 105