针对问题1,我查阅下代码,它是重新新建了服务的,具体如下所示:
没有入网前
uint32_t nrf_mesh_prov_bearer_gatt_init(nrf_mesh_prov_bearer_gatt_t * p_bearer_gatt)
{
if (p_bearer_gatt == NULL)
{
return NRF_ERROR_NULL;
}
fsm_init(&p_bearer_gatt->fsm, &m_pb_gatt_fsm_descriptor);
memset(&p_bearer_gatt->link_timeout_event, 0, sizeof(timer_event_t));
p_bearer_gatt->link_timeout_event.cb = link_timer_cb;
p_bearer_gatt->link_timeout_event.p_context = p_bearer_gatt;
bearer_event_sequential_add(&p_bearer_gatt->bearer_event_seq,
link_evt_process,
&m_evt_prov_link);
mesh_gatt_uuids_t uuids;
uuids.service = NRF_MESH_PB_GATT_SERVICE_UUID;
uuids.rx_char = NRF_MESH_PB_GATT_CHAR_IN_UUID;
uuids.tx_char = NRF_MESH_PB_GATT_CHAR_OUT_UUID;
mesh_gatt_init(&uuids, mesh_gatt_event_handler, p_bearer_gatt);
return NRF_SUCCESS;
}
该函数创建了0x1827的服务,因为入网完成之后,有个断开连接并调用
/* it requires switching GATT service before provisioning complete */
gatt_database_reset();
入网后
复位操作,这个已经因为入网的标志已置1,这个时候又新建了一个0x1828的服务
void proxy_init(void)
{
mesh_gatt_uuids_t uuids = {.service = PROXY_UUID_SERVICE,
.tx_char = PROXY_UUID_CHAR_TX,
.rx_char = PROXY_UUID_CHAR_RX};
mesh_gatt_init(&uuids, gatt_evt_handler, NULL);
m_mesh_evt_handler.evt_cb = mesh_evt_handle;
nrf_mesh_evt_handler_add(&m_mesh_evt_handler);
m_beacon_cache.array_len = MESH_GATT_PROXY_BEACON_CACHE_SIZE;
m_beacon_cache.elem_array = m_beacon_cache_entries;
m_beacon_cache.elem_size = sizeof(sizeof(beacon_cache_entry_t));
cache_init(&m_beacon_cache);
m_advertising.timer.cb = adv_timer_handler;
m_advertising.timer.interval = ADV_NETWORK_ITERATE_INTERVAL_US;
m_advertising.running = false;
for (uint32_t i = 0; i < MESH_GATT_CONNECTION_COUNT_MAX; ++i)
{
core_tx_bearer_add(&m_connections[i].bearer, &m_interface, CORE_TX_BEARER_TYPE_GATT_SERVER);
m_connections[i].connected = false;
}
/* NOTE: We're not setting the m_enabled state here. It is stored in zero-initialized memory and
* set by mesh_config_load() which _has to be called before this function_.
*
* The reason is that this function shall only be called if the device has been provisioned,
* otherwise it will add the Proxy Service to the GATT database (through mesh_gatt_init(...)).
*/
}