实现多个配置器和子网的BLE Mesh网络,需要在代码中进行以下步骤:
1.定义多个子网并初始化:
mesh_subnet_t subnet1 ={ .net_key_index = 0, .net_key = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, .iv_index = 0, };
mesh_subnet_t subnet2 ={ .net_key_index = 1, .net_key = {0x1f, 0x23, 0x4d, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}, .iv_index = 0, };
2.定义多个配置器并初始化:
mesh_cfg_srv_t cfg_srv1; mesh_cfg_srv_t cfg_srv2;
3.注册每个配置器到各自的子网:
mesh_cfg_srv_init(&cfg_srv1, &subnet1, nrf_mesh_evt_handler); mesh_cfg_srv_init(&cfg_srv2, &subnet2, nrf_mesh_evt_handler);
4.定义多个配网节点并配置到各自的配置器:
mesh_provisionee_config_t provisionee_config1 = { .p_device_uri = DEVICE_URI, .p_in_app_data = DB_FILE_NAME, .netkey_index = 0, }; mesh_provisionee_config_t provisionee_config2 = { .p_device_uri = DEVICE_URI, .p_in_app_data = DB_FILE_NAME, .netkey_index = 1, };
mesh_provisionee_add(MESH_PROVISIONEE_OOB_METHOD_STATIC, &provisionee_config1, cfg_client_evt_handler1); mesh_provisionee_add(MESH_PROVISIONEE_OOB_METHOD_STATIC, &provision