Link Kit C-SDK  4.1.0
函数 | 变量
aiot_subdev_api.c 文件参考

subdev模块的API接口实现, 提供.......的能力 更多...

#include "subdev_private.h"
#include "core_global.h"
#include "core_string.h"
#include "core_log.h"
#include "core_sha256.h"
#include "core_mqtt.h"
#include "cJSON.h"
aiot_subdev_api.c 的引用(Include)关系图:

函数

static void _subdev_topo_generic_reply_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata, aiot_subdev_recv_type_t type, uint8_t pk_pos)
 
static void _subdev_topo_generic_notify_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata, aiot_subdev_recv_type_t type, uint8_t pk_pos)
 
static void _subdev_topo_add_reply_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
 
static void _subdev_topo_delete_reply_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
 
static void _subdev_topo_get_reply_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
 
static void _subdev_batch_login_reply_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
 
static void _subdev_batch_logout_reply_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
 
static void _subdev_sub_register_reply_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
 
static void _subdev_product_register_reply_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
 
static void _subdev_topo_change_recv_handler (void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
 
static int32_t _subdev_operate_topic_map (subdev_handle_t *subdev_handle, aiot_mqtt_option_t option)
 
static int32_t _subdev_send_message (subdev_handle_t *subdev_handle, char *topic_fmt, cJSON *root)
 
static int32_t _subdev_calculate_sign (subdev_handle_t *subdev_handle, aiot_subdev_dev_t *dev, char *clientid, char *timestamp, char sign_str[65])
 
static int32_t _subdev_calculate_product_register_sign (subdev_handle_t *subdev_handle, aiot_subdev_dev_t *dev, char *random, char sign_str[65])
 
static int32_t _subdev_topo_add_append_params (subdev_handle_t *subdev_handle, cJSON *params, aiot_subdev_dev_t *dev, char *timestamp)
 
static int32_t _subdev_append_pk_dn_to_params (subdev_handle_t *subdev_handle, cJSON *params, aiot_subdev_dev_t *dev)
 
static int32_t _subdev_topo_delete_append_params (subdev_handle_t *subdev_handle, cJSON *params, aiot_subdev_dev_t *dev)
 
static int32_t _subdev_batch_login_append_device_list (subdev_handle_t *subdev_handle, cJSON *device_list, aiot_subdev_dev_t *dev, char *timestamp)
 
static int32_t _subdev_batch_logout_append_params (subdev_handle_t *subdev_handle, cJSON *params, aiot_subdev_dev_t *dev)
 
static int32_t _subdev_sub_register_append_params (subdev_handle_t *subdev_handle, cJSON *params, aiot_subdev_dev_t *dev)
 
static int32_t _subdev_product_register_append_params (subdev_handle_t *subdev_handle, cJSON *proxieds, aiot_subdev_dev_t *dev)
 
void * aiot_subdev_init (void)
 创建subdev会话实例, 并以默认值配置会话参数 更多...
 
int32_t aiot_subdev_setopt (void *handle, aiot_subdev_option_t option, void *data)
 配置subdev会话 更多...
 
int32_t aiot_subdev_deinit (void **handle)
 结束subdev会话, 销毁实例并回收资源 更多...
 
int32_t aiot_subdev_send_topo_add (void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
 向物联网平台发送添加子设备与网关topo关系的请求 更多...
 
int32_t aiot_subdev_send_topo_delete (void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
 向物联网平台发送删除子设备与网关topo关系的请求 更多...
 
int32_t aiot_subdev_send_topo_get (void *handle)
 向物联网平台发送查询子设备与网关topo关系的请求 更多...
 
int32_t aiot_subdev_send_batch_login (void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
 向物联网平台发送子设备上线请求 更多...
 
int32_t aiot_subdev_send_batch_logout (void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
 向物联网平台发送子设备下线请求 更多...
 
int32_t aiot_subdev_send_sub_register (void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
 向物联网平台发送子设备动态注册请求 更多...
 
int32_t aiot_subdev_send_product_register (void *handle, aiot_subdev_dev_t dev[], uint32_t dev_num)
 向物联网平台发送子设备动态注册请求(可从其他网关抢绑子设备) 更多...
 

变量

static subdev_topic_map_t g_subdev_topic_map []
 

详细描述

subdev模块的API接口实现, 提供.......的能力

函数说明

static void _subdev_topo_generic_reply_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata,
aiot_subdev_recv_type_t  type,
uint8_t  pk_pos 
)
static
static void _subdev_topo_generic_notify_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata,
aiot_subdev_recv_type_t  type,
uint8_t  pk_pos 
)
static
static void _subdev_topo_add_reply_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata 
)
static

函数调用图:

static void _subdev_topo_delete_reply_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata 
)
static

函数调用图:

static void _subdev_topo_get_reply_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata 
)
static

函数调用图:

static void _subdev_batch_login_reply_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata 
)
static

函数调用图:

static void _subdev_batch_logout_reply_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata 
)
static

函数调用图:

static void _subdev_sub_register_reply_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata 
)
static

函数调用图:

static void _subdev_product_register_reply_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata 
)
static

函数调用图:

static void _subdev_topo_change_recv_handler ( void *  handle,
const aiot_mqtt_recv_t packet,
void *  userdata 
)
static

函数调用图:

static int32_t _subdev_operate_topic_map ( subdev_handle_t *  subdev_handle,
aiot_mqtt_option_t  option 
)
static

函数调用图:

static int32_t _subdev_send_message ( subdev_handle_t *  subdev_handle,
char *  topic_fmt,
cJSON *  root 
)
static

函数调用图:

static int32_t _subdev_calculate_sign ( subdev_handle_t *  subdev_handle,
aiot_subdev_dev_t dev,
char *  clientid,
char *  timestamp,
char  sign_str[65] 
)
static
static int32_t _subdev_calculate_product_register_sign ( subdev_handle_t *  subdev_handle,
aiot_subdev_dev_t dev,
char *  random,
char  sign_str[65] 
)
static
static int32_t _subdev_topo_add_append_params ( subdev_handle_t *  subdev_handle,
cJSON *  params,
aiot_subdev_dev_t dev,
char *  timestamp 
)
static

函数调用图:

static int32_t _subdev_append_pk_dn_to_params ( subdev_handle_t *  subdev_handle,
cJSON *  params,
aiot_subdev_dev_t dev 
)
static
static int32_t _subdev_topo_delete_append_params ( subdev_handle_t *  subdev_handle,
cJSON *  params,
aiot_subdev_dev_t dev 
)
static

函数调用图:

static int32_t _subdev_batch_login_append_device_list ( subdev_handle_t *  subdev_handle,
cJSON *  device_list,
aiot_subdev_dev_t dev,
char *  timestamp 
)
static

函数调用图:

static int32_t _subdev_batch_logout_append_params ( subdev_handle_t *  subdev_handle,
cJSON *  params,
aiot_subdev_dev_t dev 
)
static

函数调用图:

static int32_t _subdev_sub_register_append_params ( subdev_handle_t *  subdev_handle,
cJSON *  params,
aiot_subdev_dev_t dev 
)
static

函数调用图:

static int32_t _subdev_product_register_append_params ( subdev_handle_t *  subdev_handle,
cJSON *  proxieds,
aiot_subdev_dev_t dev 
)
static

函数调用图:

void* aiot_subdev_init ( void  )

创建subdev会话实例, 并以默认值配置会话参数

返回
void *
返回值
非NULLsubdev实例的句柄
NULL初始化失败, 一般是内存分配失败导致

函数调用图:

int32_t aiot_subdev_setopt ( void *  handle,
aiot_subdev_option_t  option,
void *  data 
)

配置subdev会话

参数
[in]handlesubdev会话句柄
[in]option配置选项, 更多信息请参考aiot_subdev_option_t
[in]data配置选项数据, 更多信息请参考aiot_subdev_option_t
返回
int32_t
返回值
<STATE_SUCCESS参数配置失败
>=STATE_SUCCESS参数配置成功

函数调用图:

int32_t aiot_subdev_deinit ( void **  handle)

结束subdev会话, 销毁实例并回收资源

参数
[in]handle指向subdev会话句柄的指针
返回
int32_t
返回值
<STATE_SUCCESS执行失败
>=STATE_SUCCESS执行成功
int32_t aiot_subdev_send_topo_add ( void *  handle,
aiot_subdev_dev_t  dev[],
uint32_t  dev_num 
)

向物联网平台发送添加子设备与网关topo关系的请求

参数
handlesubdev会话句柄
dev需要添加topo关系的子设备数组
dev_num子设备数组中的子设备数量
返回
int32_t
返回值
<STATE_SUCCESS请求发送失败
>=STATE_SUCCESS请求发送成功
注解

aiot_subdev_dev_t 中需要填写product key, device name 和 device secret

函数调用图:

int32_t aiot_subdev_send_topo_delete ( void *  handle,
aiot_subdev_dev_t  dev[],
uint32_t  dev_num 
)

向物联网平台发送删除子设备与网关topo关系的请求

参数
handlesubdev会话句柄
dev需要删除topo关系的子设备数组
dev_num子设备数组中的子设备数量
返回
int32_t
返回值
<STATE_SUCCESS请求发送失败
>=STATE_SUCCESS请求发送成功
注解

aiot_subdev_dev_t 中需要填写product key, device name

函数调用图:

int32_t aiot_subdev_send_topo_get ( void *  handle)

向物联网平台发送查询子设备与网关topo关系的请求

参数
handlesubdev会话句柄
返回
int32_t
返回值
<STATE_SUCCESS请求发送失败
>=STATE_SUCCESS请求发送成功
注解

aiot_subdev_dev_t 中需要填写product key, device name

函数调用图:

int32_t aiot_subdev_send_batch_login ( void *  handle,
aiot_subdev_dev_t  dev[],
uint32_t  dev_num 
)

向物联网平台发送子设备上线请求

参数
handlesubdev会话句柄
dev需要上线的子设备数组
dev_num子设备数组中的子设备数量
返回
int32_t
返回值
<STATE_SUCCESS请求发送失败
>=STATE_SUCCESS请求发送成功
注解

aiot_subdev_dev_t 中需要填写product key, device name, device secret

函数调用图:

int32_t aiot_subdev_send_batch_logout ( void *  handle,
aiot_subdev_dev_t  dev[],
uint32_t  dev_num 
)

向物联网平台发送子设备下线请求

参数
handlesubdev会话句柄
dev需要下线的子设备数组
dev_num子设备数组中的子设备数量
返回
int32_t
返回值
<STATE_SUCCESS请求发送失败
>=STATE_SUCCESS请求发送成功
注解

aiot_subdev_dev_t 中需要填写product key, device name

函数调用图:

int32_t aiot_subdev_send_sub_register ( void *  handle,
aiot_subdev_dev_t  dev[],
uint32_t  dev_num 
)

向物联网平台发送子设备动态注册请求

参数
handlesubdev会话句柄
dev需要动态注册的子设备数组
dev_num子设备数组中的子设备数量
返回
int32_t
返回值
<STATE_SUCCESS请求发送失败
>=STATE_SUCCESS请求发送成功
注解

aiot_subdev_dev_t 中需要填写product key, device name

函数调用图:

int32_t aiot_subdev_send_product_register ( void *  handle,
aiot_subdev_dev_t  dev[],
uint32_t  dev_num 
)

向物联网平台发送子设备动态注册请求(可从其他网关抢绑子设备)

参数
handlesubdev会话句柄
dev需要动态注册的子设备数组
dev_num子设备数组中的子设备数量
返回
int32_t
返回值
<STATE_SUCCESS请求发送失败
>=STATE_SUCCESS请求发送成功
注解

aiot_subdev_dev_t 中需要填写product key, device name, product secret

函数调用图:

变量说明

subdev_topic_map_t g_subdev_topic_map[]
static
初始值:
= {
{SUBDEV_TOPIC_TOPO_ADD_REPLY, _subdev_topo_add_reply_recv_handler },
{SUBDEV_TOPIC_TOPO_DELETE_REPLY, _subdev_topo_delete_reply_recv_handler },
{SUBDEV_TOPIC_TOPO_GET_REPLY, _subdev_topo_get_reply_recv_handler },
{SUBDEV_TOPIC_BATCH_LOGIN_REPLY, _subdev_batch_login_reply_recv_handler },
{SUBDEV_TOPIC_BATCH_LOGOUT_REPLY, _subdev_batch_logout_reply_recv_handler },
{SUBDEV_TOPIC_SUB_REGISTER_REPLY, _subdev_sub_register_reply_recv_handler },
{SUBDEV_TOPIC_PRODUCT_REGISTER_REPLY, _subdev_product_register_reply_recv_handler },
{SUBDEV_TOPIC_TOPO_CHANGE_NOTIFY, _subdev_topo_change_recv_handler }
}
static void _subdev_sub_register_reply_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
Definition: aiot_subdev_api.c:206
static void _subdev_topo_add_reply_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
Definition: aiot_subdev_api.c:181
static void _subdev_topo_delete_reply_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
Definition: aiot_subdev_api.c:186
static void _subdev_topo_get_reply_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
Definition: aiot_subdev_api.c:191
static void _subdev_topo_change_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
Definition: aiot_subdev_api.c:216
static void _subdev_batch_logout_reply_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
Definition: aiot_subdev_api.c:201
static void _subdev_product_register_reply_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
Definition: aiot_subdev_api.c:211
static void _subdev_batch_login_reply_recv_handler(void *handle, const aiot_mqtt_recv_t *packet, void *userdata)
Definition: aiot_subdev_api.c:196