Hi,
I'm using nRF52832 board and I'm integrating the Bluetooth beacon sending in the Bluetooth Mesh example. I've edited the Mesh Beacon example in Mesh SDK v4.0.0 with the aim of sending iBeacon and Eddystone beacon, while the board is taking part of a mesh network. I've already changed the advertising data implemented in the Mesh Beacon example successfully and I can send iBeacon and Eddystone with no problems while the node is provisioned.
I saw the Eddystone Beacon example in the ble_peripheral folder of nRF SDK v16. I've added a new service and characteristic in the Beaconing Example. In mesh_gatt.c, within mesh_gatt_init function I wrote:
mesh_gatt_uuids_t uuids_eddystone = {.service = 0x7500,
.tx_char = 0x7502,
.rx_char = 0x7501};
memcpy(&m_gatt.uuids, &uuids_eddystone, sizeof(mesh_gatt_uuids_t));
m_gatt.evt_handler = evt_handler;
ble_uuid_t uuid_eddystone = {.type = BLE_UUID_TYPE_BLE, .uuid = uuids_eddystone.service};
NRF_MESH_ERROR_CHECK(sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &uuid_eddystone, &m_gatt.handles.service));
uuid.uuid = uuids_eddystone.rx_char;
ble_gatts_char_md_t char_md_eddystone;
memset(&char_md_eddystone, 0, sizeof(char_md_eddystone));
char_md_eddystone.char_props.write = 1; //added
char_md_eddystone.char_props.read = 1; //added
ble_gatts_attr_md_t attr_md_eddystone;
memset(&attr_md_eddystone, 0, sizeof(attr_md_eddystone));
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md_eddystone.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md_eddystone.write_perm);
attr_md_eddystone.vloc = BLE_GATTS_VLOC_STACK;
attr_md_eddystone.rd_auth = 0;
attr_md_eddystone.wr_auth = 0;
attr_md_eddystone.vlen = 1;
uint8_t value [] = {'n','o','r','d','i','c','s','e','m','i','.','c','o','m'}; //
ble_gatts_attr_t attr_char_value_eddystone;
memset(&attr_char_value_eddystone, 0, sizeof(attr_char_value_eddystone));
attr_char_value_eddystone.p_uuid = &uuid;
attr_char_value_eddystone.p_attr_md = &attr_md;
//attr_char_value.init_len = 0;
attr_char_value_eddystone.init_len = sizeof(value); //added
attr_char_value_eddystone.init_offs = 0;
attr_char_value_eddystone.max_len = MESH_GATT_PROXY_PDU_MAX_SIZE;
//attr_char_value.p_value = NULL; /* VLOC_STACK */
attr_char_value_eddystone.p_value = &value; //added
NRF_MESH_ERROR_CHECK(sd_ble_gatts_characteristic_add(m_gatt.handles.service, &char_md_eddystone, &attr_char_value_eddystone, &m_gatt.handles.rx));
in order to add a new characteristic in which I can write a new value that will be the new URL in the Eddystone beacon. I noticed that I can write a new value only if I change the following code m_gatt.connections[i].rx.pdu_type = MESH_GATT_PDU_TYPE_INVALID;
with
m_gatt.connections[i].rx.pdu_type = MESH_GATT_PDU_TYPE_PROXY_CONFIG;
and m_gatt.connections[i].conn_handle = BLE_CONN_HANDLE_INVALID;
with m_gatt.connections[i].conn_handle = BLE_CONN_HANDLE_ALL;
I saw that these last two changes don't allow me to use nRF Mesh app properly with my smartphone: the scanner sees the device but the app can't perform any further actions. But these last two changes allow me to write a new value into the characteristic.
I managed to write the part of code that changes the Eddystone URL successfully using advertiser_packet_discard, creating a new advertising data and using advertiser_packet_alloc in order to allocate the new packet.
I have two questions: how can I add a new characteristic without losing Bluetooth Mesh functionalities and how can I add a new service and characteristic with 128 bit UUID like Eddystone example in nRF SDK v16?
Thanks in advance for the answers.