简介
config模型,专门用来给节点做“配置”用的,例如,订阅、发布、绑定appkey等配置。
应用流程(端对端直接控制方式)
SDK代码参考
以下代码是一些代码片段,需要了解完整内容的话,可以在工程里面进行全局搜索!
客户端:
初始化
注册config client模型
/* Register Configuration model client */
retval = UI_register_config_model_client(element_handle);
设置config client发布地址和devicekey
/* Set the Publish address for Config Client */
UI_set_publish_address(UI_prov_data.uaddr, UI_config_client_model_handle,MS_TRUE);
发送获取Composition数据命令
/* Get the Composition data */
UI_config_client_get_composition_data(0x00);
服务端:
初始化
注册config server模型
/* Register foundation model servers */
retval = UI_register_foundation_model_servers(element_handle);
APP_config_server_CB_init(UI_app_config_server_callback);
获取devicekey?
UI_sample_get_device_key();
不处理Composition命令,返回Composition状态
null
客户端:
发送添加appkey命令
/* Add Appkey */
UI_config_client_appkey_add(0, 0, UI_appkey);
服务端:
绑定appkey到各个模型
case MS_ACCESS_CONFIG_APPKEY_ADD_OPCODE:
#ifdef EASY_BOUNDING
blebrr_scan_pl(FALSE);
ms_provisioner_addr = saddr;
vm_subscriptiong_binding_cb();//重要
// ms_provisioner_addr = saddr;
#if (CFG_HEARTBEAT_MODE)
UI_trn_set_heartbeat_subscription(saddr);
#endif
#else
// CONSOLE_OUT("Stop timer\n");
ms_provisioner_addr = saddr;
// EM_stop_timer(&procfg_timer_handle);
blebrr_prov_started = MS_FALSE;
#endif
break;
客户端:
处理appkey添加完成响应回调
case MS_ACCESS_CONFIG_APPKEY_STATUS_OPCODE:
{
CONSOLE_OUT(
"MS_ACCESS_CONFIG_APPKEY_STATUS_OPCODE\n");
#ifdef EASY_BOUNDING
UI_SET_RAW_DATA_DST_ADDR(UI_prov_data.uaddr);
MS_access_cm_set_transmit_state(MS_NETWORK_TX_STATE, (0<<3)|0);
/* Set provision started */
blebrr_prov_started = MS_FALSE;
EM_stop_timer(&procfg_timer_handle);
CONSOLE_OUT(
"PROVISION AND CONFIG DONE!!!\n");
// UI_config_proxy_set(0);
/* Send a Generic ON */
#else
/* Bind the model to Appkey */
UI_config_client_model_app_bind(UI_prov_data.uaddr, 0, MS_ACCESS_MODEL_TYPE_SIG, MS_MODEL_ID_GENERIC_ONOFF_SERVER);
#endif
}