1. 解决频繁频繁掉线的问题:原因是因为ble
sdk需要一开始就初始化,配网的时候只是去控制其广播是否开启。不然会导致一直掉线
This commit is contained in:
@ -42,7 +42,7 @@
|
||||
//static bool g_switch = 0;
|
||||
int sid_switch;
|
||||
static bool g_autoUpdate = 0;
|
||||
static int ble_adv_time = BLE_ADV_TIME;
|
||||
static int ble_adv_time = 0;
|
||||
static HILINK_BT_DevInfo g_btDevInfo = {0};
|
||||
extern int set_get_ble_mac(void);
|
||||
extern int HILINK_Printf(const char *format, ...);
|
||||
@ -258,6 +258,7 @@ static void ReporFwvCheckSum(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ble_sdk_running = 0;
|
||||
static void HILINK_BT_StateChangeHandler(HILINK_BT_SdkStatus event, const void *param)
|
||||
{
|
||||
(void)param;
|
||||
@ -276,6 +277,7 @@ static void HILINK_BT_StateChangeHandler(HILINK_BT_SdkStatus event, const void *
|
||||
|
||||
/* BLE配网广播控制:参数代表广播时间,0:停止;0xFFFFFFFF:一直广播,其他:广播指定时间后停止,单位秒 */
|
||||
(void)BLE_CfgNetAdvCtrl(ble_adv_time);
|
||||
ble_sdk_running = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,13 +432,21 @@ unsigned int GetWifiRecoveryType(void)
|
||||
{
|
||||
return (0x01 | 0x02);
|
||||
}
|
||||
|
||||
int start_hilink_ble_net_config(int32_t net_cfg_time_s)
|
||||
{
|
||||
int ret = 0;
|
||||
int hilink_entry_mode=hfget_hilink_mode();
|
||||
ble_adv_time = net_cfg_time_s;
|
||||
printf("hilink_entry_mode:%d, ble_adv_time:%d\r\n",hilink_entry_mode, ble_adv_time);
|
||||
if (ble_sdk_running) {
|
||||
BLE_CfgNetAdvCtrl(ble_adv_time);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int hilink_ble_main(void)
|
||||
{
|
||||
int ret = 0;
|
||||
hfdbg_set_level(1);
|
||||
hfset_hilink_mode(SMTLK_BLE_FAST_CONNECT);
|
||||
int hilink_entry_mode=hfget_hilink_mode();
|
||||
printf("hilink_entry_mode:%d\r\n",hilink_entry_mode);
|
||||
if(hilink_entry_mode != SMTLK_SOFTAP)
|
||||
{
|
||||
if(hfget_hilink_mode() == SMTLK_BLE_NARMAL)
|
||||
@ -490,7 +500,19 @@ int start_hilink_ble_net_config(int32_t net_cfg_time_s)
|
||||
HILINK_SetProtType(1);
|
||||
ret = HILINK_SetNetConfigMode(HILINK_NETCONFIG_WIFI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 修改任务属性 */
|
||||
HILINK_SdkAttr *sdkAttr = HILINK_GetSdkAttr();
|
||||
if (sdkAttr == NULL) {
|
||||
HILINK_SAL_NOTICE("sdkAttr is null");
|
||||
return -1;
|
||||
}
|
||||
sdkAttr->monitorTaskStackSize = 0x600; /* 示例代码 推荐栈大小为0x400 */
|
||||
sdkAttr->rebootHardware = HardReboot;
|
||||
sdkAttr->rebootSoftware = HardReboot;
|
||||
HILINK_SetSdkAttr(*sdkAttr);
|
||||
|
||||
/* 注册极简配网WIFI相关函数 */
|
||||
WiFiRecoveryApi wifiCb;
|
||||
wifiCb.getWifiRecoveryType = GetWifiRecoveryType;
|
||||
@ -505,23 +527,6 @@ int start_hilink_ble_net_config(int32_t net_cfg_time_s)
|
||||
}
|
||||
HILINK_SAL_NOTICE("RegWiFiRecoveryCallback finish!\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
int hilink_ble_main(void)
|
||||
{
|
||||
hfdbg_set_level(1);
|
||||
hfset_hilink_mode(SMTLK_BLE_FAST_CONNECT);
|
||||
/* 修改任务属性 */
|
||||
HILINK_SdkAttr *sdkAttr = HILINK_GetSdkAttr();
|
||||
if (sdkAttr == NULL) {
|
||||
HILINK_SAL_NOTICE("sdkAttr is null");
|
||||
return -1;
|
||||
}
|
||||
sdkAttr->monitorTaskStackSize = 0x600; /* 示例代码 推荐栈大小为0x400 */
|
||||
sdkAttr->rebootHardware = HardReboot;
|
||||
sdkAttr->rebootSoftware = HardReboot;
|
||||
HILINK_SetSdkAttr(*sdkAttr);
|
||||
|
||||
#ifdef CONFIG_SUPPORT_HILINK_INDIE_UPGRADE
|
||||
if (HILINK_RegisterErrnoCallback(get_os_errno) != 0) {
|
||||
HILINK_SAL_NOTICE("reg errno cb err\r\n");
|
||||
|
@ -12,19 +12,16 @@
|
||||
#include "hal_reboot.h"
|
||||
#include "hilink_device.h"
|
||||
#include "hilink_network_adapter.h"
|
||||
#include "hsf.h"
|
||||
|
||||
#ifdef SUPPORT_QUICK_NETCFG
|
||||
#include "hilink_quick_netcfg_demo.h"
|
||||
#include "hilink_quick_netcfg_api.h"
|
||||
#endif
|
||||
extern unsigned char *HILINK_GetAutoAc(void);
|
||||
|
||||
static int GetAcV2Func(unsigned char *acKey, unsigned int acLen)
|
||||
{
|
||||
/* key文件在开发者平台获取 */
|
||||
e_printf("GetAcV2Func\r\n");
|
||||
memcpy(acKey, HILINK_GetAutoAc(), acLen);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static unsigned int GetWifiRecType(void)
|
||||
@ -87,7 +84,7 @@ int hilink_wifi_main(void)
|
||||
HILINK_SAL_NOTICE("HILINK_Main start error");
|
||||
return -1;
|
||||
}
|
||||
e_printf("HILINK_Main start success\r\n");
|
||||
|
||||
#ifdef SUPPORT_QUICK_NETCFG
|
||||
StartQuickNetCfg();
|
||||
#endif
|
||||
|
@ -16,54 +16,18 @@ extern "C" {
|
||||
* 与hilink sdk相同定义,双模组模式只需一份,已提供给第三方厂家,暂不按编程规范整改
|
||||
*/
|
||||
|
||||
#define SORONTEK_PRODUCT 1
|
||||
#define HIFLYING_PRODUCT 0
|
||||
#if SORONTEK_PRODUCT // EKKO add for device info, Reference from product json
|
||||
|
||||
#define ProductId "2Q4H"
|
||||
#define deviceTypeId "21D"
|
||||
#define manufacturerID "gub"
|
||||
#define deviceModel "SR-TH-020-10W"
|
||||
#define configName "SR_"
|
||||
#define configType "light"
|
||||
#define enterpriseEnglishName "SORONTEK" // EKKO: TODO: need check
|
||||
#define configName "SR_L"
|
||||
#define configType "ight"
|
||||
#define enterpriseEnglishName "SORONTEK"
|
||||
#define brandEn "SORONTEK"
|
||||
#define deviceName "LED嵌入式天花射灯"
|
||||
#define deviceName "SORONTEK智能双色温灯"
|
||||
#define productSeries ""
|
||||
#define MANUAFACTURER_ACKEY {\
|
||||
0x66, 0x22, 0x33, 0x5F, 0x75, 0x31, 0x29, 0x6A, 0x27, 0x34, 0x57, 0x44, 0x32, 0x42, 0x27, 0x59, \
|
||||
0xE1, 0xDE, 0x9C, 0xA6, 0xA6, 0x77, 0x54, 0x8C, 0xA9, 0xB0, 0x0D, 0xC7, 0xCB, 0x1B, 0x32, 0x2B, \
|
||||
0xB9, 0x4E, 0xEE, 0x97, 0xDC, 0x43, 0xFB, 0xF1, 0x86, 0xCC, 0xFD, 0x6E, 0x78, 0xA8, 0x36, 0x22}
|
||||
#elif HIFLYING_PRODUCT
|
||||
#define ProductId "2PAD"
|
||||
#define deviceTypeId "01D"
|
||||
#define manufacturerID "01C"
|
||||
#define deviceModel "hf-262-jjpw"
|
||||
#define configName "262"
|
||||
#define configType "HF"
|
||||
#define enterpriseEnglishName "HighFlying"
|
||||
#define brandEn "hiflying"
|
||||
#define deviceName "专用262认证测试设备"
|
||||
#define productSeries "262"
|
||||
#define MANUAFACTURER_ACKEY { \
|
||||
0x73,0x4A,0x68,0x4E,0x3B,0x77,0x2A,0x42,0x33,0x74,0x6D,0x50,0x3C,0x6F,0x2E,0x60,0x40,0xCA, \
|
||||
0x74,0x27,0x25,0xB7,0x1A,0x72,0x41,0xCD,0xAB,0xD4,0x04,0x55,0x7D,0xC4,0x2B,0x32,0x7E,0xB2, \
|
||||
0x39,0xB1,0xDC,0x28,0x46,0xBB,0x6A,0x77,0x86,0x3D,0xD8,0xE3 }
|
||||
#else
|
||||
#define ProductId "2PQP"
|
||||
#define deviceTypeId "112"
|
||||
#define manufacturerID "i0s"
|
||||
#define deviceModel "SamSLE001"
|
||||
#define configName "HuaweiSm"
|
||||
#define configType "art Home"
|
||||
#define enterpriseEnglishName "yuanxun"
|
||||
#define brandEn "YX"
|
||||
#define deviceName "SamSLETest"
|
||||
#define productSeries ""
|
||||
#define MANUAFACTURER_ACKEY { \
|
||||
0x66, 0x3F, 0x64, 0x78, 0x4B, 0x78, 0x3B, 0x26, 0x76, 0x78, 0x24, 0x56, 0x25, 0x2C, 0x57, 0x47, 0x6F, \
|
||||
0xC8, 0xE7, 0xD6, 0xC6, 0xF2, 0x7F, 0x03, 0x3A, 0x1C, 0x78, 0x05, 0x66, 0x24, 0x5F, 0x09, 0xCD, 0xAD, \
|
||||
0x30, 0x55, 0x2C, 0x19, 0x28, 0x34, 0x1A, 0xC3, 0x31, 0x49, 0x16, 0xC7, 0x45, 0x1B};
|
||||
#endif
|
||||
|
||||
#define DEVICE_HIVERSION "1.0.0"
|
||||
/* 设备固件版本号 */
|
||||
#define FIRMWARE_VER "1.0.0"
|
||||
|
@ -15,7 +15,24 @@
|
||||
#include "hsf.h"
|
||||
#include "hilink_entry.h"
|
||||
|
||||
// #undef CONFIG_SUPPORT_HILINK_INDIE_UPGRADE
|
||||
extern void handle_device_online(void);
|
||||
extern void handle_device_unbind(void);
|
||||
extern void handle_device_offline(void);
|
||||
|
||||
extern int myhandle_put_brightness(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_put_cct(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_put_lightMode(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_put_switch(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_put_progressSwitch(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_get_brightness(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_cct(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_lightMode(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_switch(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern int myhandle_get_progressSwitch(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
// 声明外部函数
|
||||
extern int myhandle_put_cmd(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int myhandle_get_cmd(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
|
||||
/*
|
||||
*
|
||||
* 服务信息定义
|
||||
@ -23,11 +40,16 @@
|
||||
* (2)与devicepartner平台物模型定义必须保持一致
|
||||
*/
|
||||
static const HILINK_SvcInfo SVC_INFO[] = {
|
||||
{ "brightness", "brightness" },
|
||||
{ "cct", "cct" },
|
||||
{ "mode", "lightMode" },
|
||||
{ "progressSwitch", "progressSwitch" },
|
||||
{ "switch", "switch" },
|
||||
#ifdef CONFIG_SUPPORT_HILINK_INDIE_UPGRADE
|
||||
{ "checkSum", "checkSum" },
|
||||
// { "checkSum", "checkSum" },
|
||||
#endif
|
||||
};
|
||||
|
||||
int HILINK_GetDevInfo(HILINK_DevInfo *devinfo)
|
||||
{
|
||||
if (devinfo == NULL) {
|
||||
@ -125,22 +147,27 @@ int HILINK_GetSvcInfo(HILINK_SvcInfo *svcInfo[], unsigned int size)
|
||||
}
|
||||
return svcNum;
|
||||
}
|
||||
|
||||
/* AC参数 */
|
||||
unsigned char A_C[48] = MANUAFACTURER_ACKEY;
|
||||
unsigned char A_C[48] = {
|
||||
0x66, 0x22, 0x33, 0x5F, 0x75, 0x31, 0x29, 0x6A, 0x27, 0x34, 0x57, 0x44, 0x32, 0x42, 0x27, 0x59, 0xE1, \
|
||||
0xDE, 0x9C, 0xA6, 0xA6, 0x77, 0x54, 0x8C, 0xA9, 0xB0, 0x0D, 0xC7, 0xCB, 0x1B, 0x32, 0x2B, 0xB9, 0x4E, \
|
||||
0xEE, 0x97, 0xDC, 0x43, 0xFB, 0xF1, 0x86, 0xCC, 0xFD, 0x6E, 0x78, 0xA8, 0x36, 0x22};
|
||||
|
||||
/* 获取加密 AC 参数 */
|
||||
unsigned char *HILINK_GetAutoAc(void)
|
||||
{
|
||||
// e_printf("HILINK_GetAutoAc\r\n");
|
||||
return A_C;
|
||||
}
|
||||
|
||||
|
||||
extern int HILINK_HILINK_Printf(const char *format, ...);
|
||||
|
||||
#if 0 //EKKO REMOVE
|
||||
// 设备状态定义
|
||||
typedef struct{
|
||||
int brightness_brightness;
|
||||
int cct_colorTemperature;
|
||||
int lightMode_mode;
|
||||
int progressSwitch_fadeTime;
|
||||
int switch_on;
|
||||
}t_device_info;
|
||||
// 分配一个对象记录设备状态
|
||||
@ -192,10 +219,119 @@ int handle_get_switch(const char* svc_id, const char* in, unsigned int in_len,ch
|
||||
return 0;
|
||||
}
|
||||
// 服务处理信息注册
|
||||
|
||||
int handle_put_brightness(const char* svc_id, const char* payload, unsigned int len)
|
||||
{
|
||||
cJSON* pJson = cJSON_Parse(payload);
|
||||
if (!pJson)
|
||||
return -1;
|
||||
cJSON* brightness_item = cJSON_GetObjectItem(pJson, "brightness");
|
||||
if (brightness_item)
|
||||
g_device_info.brightness_brightness = brightness_item->valueint;
|
||||
HILINK_Printf("%s:%d svcId:%s, payload:%s\r\n", __FUNCTION__, __LINE__, svc_id, payload);
|
||||
cJSON_Delete(pJson);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_get_brightness(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len)
|
||||
{
|
||||
*out_len = 64;
|
||||
*out = (char*)malloc(*out_len);
|
||||
if (*out == NULL)
|
||||
return -1;
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"brightness\":%d}", g_device_info.brightness_brightness);
|
||||
HILINK_Printf("%s:%d svcId:%s, *out:%s\r\n", __FUNCTION__, __LINE__, svc_id, *out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_put_cct(const char* svc_id, const char* payload, unsigned int len)
|
||||
{
|
||||
cJSON* pJson = cJSON_Parse(payload);
|
||||
if (!pJson)
|
||||
return -1;
|
||||
cJSON* colorTemperature_item = cJSON_GetObjectItem(pJson, "colorTemperature");
|
||||
if (colorTemperature_item)
|
||||
g_device_info.cct_colorTemperature = colorTemperature_item->valueint;
|
||||
HILINK_Printf("%s:%d svcId:%s, payload:%s\r\n", __FUNCTION__, __LINE__, svc_id, payload);
|
||||
cJSON_Delete(pJson);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_get_cct(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len)
|
||||
{
|
||||
*out_len = 64;
|
||||
*out = (char*)malloc(*out_len);
|
||||
if (*out == NULL)
|
||||
return -1;
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"colorTemperature\":%d}", g_device_info.cct_colorTemperature);
|
||||
HILINK_Printf("%s:%d svcId:%s, *out:%s\r\n", __FUNCTION__, __LINE__, svc_id, *out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_put_lightMode(const char* svc_id, const char* payload, unsigned int len)
|
||||
{
|
||||
cJSON* pJson = cJSON_Parse(payload);
|
||||
if (!pJson)
|
||||
return -1;
|
||||
cJSON* mode_item = cJSON_GetObjectItem(pJson, "mode");
|
||||
if (mode_item)
|
||||
g_device_info.lightMode_mode = mode_item->valueint;
|
||||
HILINK_Printf("%s:%d svcId:%s, payload:%s\r\n", __FUNCTION__, __LINE__, svc_id, payload);
|
||||
cJSON_Delete(pJson);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_get_lightMode(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len)
|
||||
{
|
||||
*out_len = 64;
|
||||
*out = (char*)malloc(*out_len);
|
||||
if (*out == NULL)
|
||||
return -1;
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"mode\":%d}", g_device_info.lightMode_mode);
|
||||
HILINK_Printf("%s:%d svcId:%s, *out:%s\r\n", __FUNCTION__, __LINE__, svc_id, *out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_put_progressSwitch(const char* svc_id, const char* payload, unsigned int len)
|
||||
{
|
||||
cJSON* pJson = cJSON_Parse(payload);
|
||||
if (!pJson)
|
||||
return -1;
|
||||
cJSON* fadeTime_item = cJSON_GetObjectItem(pJson, "fadeTime");
|
||||
if (fadeTime_item)
|
||||
g_device_info.progressSwitch_fadeTime = fadeTime_item->valueint;
|
||||
HILINK_Printf("%s:%d svcId:%s, payload:%s\r\n", __FUNCTION__, __LINE__, svc_id, payload);
|
||||
cJSON_Delete(pJson);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handle_get_progressSwitch(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len)
|
||||
{
|
||||
*out_len = 64;
|
||||
*out = (char*)malloc(*out_len);
|
||||
if (*out == NULL)
|
||||
return -1;
|
||||
*out_len = sprintf_s(*out, *out_len, "{\"fadeTime\":%d}", g_device_info.progressSwitch_fadeTime);
|
||||
HILINK_Printf("%s:%d svcId:%s, *out:%s\r\n", __FUNCTION__, __LINE__, svc_id, *out);
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_USE_CUSTOMER_SVC_INFO
|
||||
HANDLE_SVC_INFO g_device_profile[] = {
|
||||
{"switch", handle_put_switch, handle_get_switch},
|
||||
// 故障不支持 HILINK_PutCharState,配置 not_support_put
|
||||
{"brightness", myhandle_put_brightness, myhandle_get_brightness},
|
||||
{"cct", myhandle_put_cct, myhandle_get_cct},
|
||||
{"lightMode", myhandle_put_lightMode, myhandle_get_lightMode},
|
||||
{"progressSwitch", myhandle_put_progressSwitch, myhandle_get_progressSwitch},
|
||||
{"switch", myhandle_put_switch, myhandle_get_switch},
|
||||
};
|
||||
#else
|
||||
HANDLE_SVC_INFO g_device_profile[] = {
|
||||
{"brightness", handle_put_brightness, handle_get_brightness},
|
||||
{"cct", handle_put_cct, handle_get_cct},
|
||||
{"lightMode", handle_put_lightMode, handle_get_lightMode},
|
||||
{"progressSwitch", handle_put_progressSwitch, handle_get_progressSwitch},
|
||||
{"switch", handle_put_switch, handle_get_switch},
|
||||
};
|
||||
#endif // end of CONFIG_USE_CUSTOMER_SVC_INFO
|
||||
// 服务总数量
|
||||
int g_device_profile_count = sizeof(g_device_profile) / sizeof(HANDLE_SVC_INFO);
|
||||
|
||||
@ -241,34 +377,21 @@ int handle_get_cmd(const char* svc_id, const char* in, unsigned int in_len, char
|
||||
}
|
||||
return function(svc_id, in, in_len, out,out_len);
|
||||
}
|
||||
#endif
|
||||
// 声明外部函数
|
||||
extern int device_module_control(const char* svc_id, const char* payload, unsigned int len);
|
||||
extern int device_module_get_state(const char* svc_id, const char* in, unsigned int in_len, char** out, unsigned int* out_len);
|
||||
extern void handle_device_online(void);
|
||||
extern void handle_device_unbind(void);
|
||||
extern void handle_device_offline(void);
|
||||
//替换实现
|
||||
#define handle_get_cmd device_module_get_state
|
||||
#define handle_put_cmd device_module_control
|
||||
|
||||
// 快速上报函数,用于上报服务状态信息
|
||||
int fast_report(const char* svc_id)
|
||||
{
|
||||
// e_printf("[fast_report] 开始上报服务状态: %s\r\n", svc_id);
|
||||
|
||||
char* payload = NULL;
|
||||
int len;
|
||||
int err = handle_get_cmd(svc_id, NULL, 0, &payload, (unsigned int *)&len);
|
||||
if(err != 0) {
|
||||
e_printf("[fast_report] 获取服务状态失败: %d\r\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
err = HILINK_ReportCharState(svc_id, payload, len);
|
||||
e_printf("[fast_report] 服务[%s] 状态上报结果: %d, payload: %s\r\n", svc_id, err, payload);
|
||||
return err;
|
||||
}
|
||||
|
||||
char* payload = NULL;
|
||||
int len;
|
||||
int err = handle_get_cmd(svc_id, NULL, 0, &payload, (unsigned int *)&len);
|
||||
if(err != 0) {
|
||||
HILINK_Printf("get msg from %s failed \r\n", svc_id);
|
||||
return err;
|
||||
}
|
||||
err = HILINK_ReportCharState(svc_id, payload, len);
|
||||
HILINK_Printf("report %s result is %d, payload:%s \r\n", svc_id, err, payload);
|
||||
return err;
|
||||
}
|
||||
/*
|
||||
* 修改服务当前字段值
|
||||
* svcId为服务的ID,payload为接收到需要修改的Json格式的字段与其值,len为payload的长度
|
||||
@ -288,7 +411,7 @@ int HILINK_PutCharState(const char *svcId, const char *payload, unsigned int len
|
||||
cJSON *json = cJSON_Parse(payload);
|
||||
if (json == NULL) {
|
||||
e_printf("[HILINK_PutCharState] JSON解析失败\r\n");
|
||||
return -101;
|
||||
return -1;
|
||||
}
|
||||
cJSON_Delete(json);
|
||||
|
||||
@ -397,6 +520,7 @@ void HILINK_NotifyDevStatus(int status)
|
||||
handle_device_offline();
|
||||
break;
|
||||
case HILINK_M2M_CLOUD_ONLINE:
|
||||
/* 设备连接云端成功,请在此处添加实现 */
|
||||
#if defined(SUPPORT_MINIMALIST_NETCFG) || defined(SUPPORT_BLE_ANCILLAY_NETCFG)
|
||||
BLE_CfgNetAdvUpdate(NULL);
|
||||
BLE_CfgNetAdvCtrl(0);
|
||||
@ -439,12 +563,12 @@ void HILINK_NotifyDevStatus(int status)
|
||||
/* 设备被注册,请在此处添加实现 */
|
||||
break;
|
||||
case HILINK_DEVICE_UNREGISTER:
|
||||
e_printf("[HILINK_NotifyDevStatus] 设备被解绑\r\n");
|
||||
handle_device_unbind();
|
||||
/* 设备被解绑,请在此处添加实现 */
|
||||
handle_device_unbind();
|
||||
break;
|
||||
case HILINK_REVOKE_FLAG_SET:
|
||||
/* 设备被复位标记置位,请在此处添加实现 */
|
||||
handle_device_unbind(); // 处理设备解绑
|
||||
handle_device_unbind();
|
||||
break;
|
||||
case HILINK_NEGO_REG_INFO_FAIL:
|
||||
/* 设备协商配网信息失败 */
|
||||
@ -489,8 +613,8 @@ int HILINK_ProcessBeforeRestart(int flag)
|
||||
/* APP删除设备触发模组重启 */
|
||||
if (flag == 1) {
|
||||
/* 实现模组重启前的操作(如:保存系统状态等) */
|
||||
handle_device_unbind(); // 处理设备解绑
|
||||
return 0;
|
||||
handle_device_unbind(); // 处理设备解绑
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 设备长时间离线触发模组重启,尝试恢复网络 */
|
||||
|
Reference in New Issue
Block a user