Commit 160d09e6 authored by chen.weican's avatar chen.weican

【修改内容】增加子设备心跳检测机制

【提交人】陈伟灿
parent a04fc3d1
...@@ -121,6 +121,22 @@ int iotx_dm_dev_online(_IN_ int devid) ...@@ -121,6 +121,22 @@ int iotx_dm_dev_online(_IN_ int devid)
return res; return res;
} }
int iotx_dm_dev_offline(_IN_ int devid)
{
int res = 0;
if (devid < 0) {
return INVALID_PARAMETER;
}
_dm_api_lock();
res = dm_mgr_upstream_status_offline(devid);
_dm_api_unlock();
return res;
}
int iotx_dm_subdev_login(_IN_ int devid) int iotx_dm_subdev_login(_IN_ int devid)
{ {
int res = 0; int res = 0;
......
...@@ -19,29 +19,6 @@ typedef struct { ...@@ -19,29 +19,6 @@ typedef struct {
char deviceCode[DEVICE_CODE_MAXLEN]; char deviceCode[DEVICE_CODE_MAXLEN];
struct list_head linked_list; struct list_head linked_list;
} kk_dev_heartbeat_node_t; } kk_dev_heartbeat_node_t;
#endif
static kk_heartbeat_ctx_t s_kk_heartbeat_ctx = {0};
static kk_heartbeat_ctx_t *_kk_heartbeat_get_ctx(void)
{
return &s_kk_heartbeat_ctx;
}
static void _kk_heartbeat_lock(void)
{
kk_heartbeat_ctx_t *ctx = _kk_heartbeat_get_ctx();
if (ctx->mutex) {
HAL_MutexLock(ctx->mutex);
}
}
static void _kk_heartbeat_unlock(void)
{
kk_heartbeat_ctx_t *ctx = _kk_heartbeat_get_ctx();
if (ctx->mutex) {
HAL_MutexUnlock(ctx->mutex);
}
}
#if 0
static int _kk_add_heartbeat_node(const char* deviceCode,unsigned int timestamp) static int _kk_add_heartbeat_node(const char* deviceCode,unsigned int timestamp)
{ {
kk_heartbeat_ctx_t *ctx = _kk_heartbeat_get_ctx(); kk_heartbeat_ctx_t *ctx = _kk_heartbeat_get_ctx();
...@@ -51,12 +28,14 @@ static int _kk_add_heartbeat_node(const char* deviceCode,unsigned int timestamp) ...@@ -51,12 +28,14 @@ static int _kk_add_heartbeat_node(const char* deviceCode,unsigned int timestamp)
if (node == NULL) { if (node == NULL) {
return MEMORY_NOT_ENOUGH; return MEMORY_NOT_ENOUGH;
} }
_kk_heartbeat_lock();
memset(node,0x0,sizeof(kk_dev_heartbeat_node_t)); memset(node,0x0,sizeof(kk_dev_heartbeat_node_t));
memcpy(node->deviceCode,deviceCode,strlen(deviceCode)); memcpy(node->deviceCode,deviceCode,strlen(deviceCode));
node->timerstamp = timestamp; node->timerstamp = timestamp;
INIT_LIST_HEAD(&node->linked_list); INIT_LIST_HEAD(&node->linked_list);
list_add_tail(&node->linked_list, &ctx->dev_list); list_add_tail(&node->linked_list, &ctx->dev_list);
return SUCCESS_RETURN _kk_heartbeat_unlock();
return SUCCESS_RETURN;
...@@ -80,8 +59,30 @@ int kk_heartbeat_update_time(const char deviceCode[DEVICE_CODE_MAXLEN],unsigned ...@@ -80,8 +59,30 @@ int kk_heartbeat_update_time(const char deviceCode[DEVICE_CODE_MAXLEN],unsigned
return FAIL_RETURN; return FAIL_RETURN;
} }
#endif #endif
static kk_heartbeat_ctx_t s_kk_heartbeat_ctx = {0};
static kk_heartbeat_ctx_t *_kk_heartbeat_get_ctx(void)
{
return &s_kk_heartbeat_ctx;
}
static void _kk_heartbeat_lock(void)
{
kk_heartbeat_ctx_t *ctx = _kk_heartbeat_get_ctx();
if (ctx->mutex) {
HAL_MutexLock(ctx->mutex);
}
}
static void _kk_heartbeat_unlock(void)
{
kk_heartbeat_ctx_t *ctx = _kk_heartbeat_get_ctx();
if (ctx->mutex) {
HAL_MutexUnlock(ctx->mutex);
}
}
void *kk_heartbeat_yield(void *args) void *kk_heartbeat_yield(void *args)
{ {
kk_heartbeat_ctx_t *ctx = _kk_heartbeat_get_ctx(); kk_heartbeat_ctx_t *ctx = _kk_heartbeat_get_ctx();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment