add le_dis_c
1. discovery device info service 2. dis client handling events from the database discovery module 3. reading different characteristics from DIS, and show with segger rtt
This commit is contained in:
@@ -200,6 +200,11 @@ extern "C"
|
||||
#define BLE_DB_DISCOVERY_ENABLED 1
|
||||
// Priority with which BLE events are dispatched to the Database Discovery module.
|
||||
#define BLE_DB_DISC_BLE_OBSERVER_PRIO 1
|
||||
// Enable Device Information Client module
|
||||
#define BLE_DIS_C_ENABLED 1
|
||||
// Priority with which BLE events are dispatched to the Device Information Client.
|
||||
#define BLE_DIS_C_BLE_OBSERVER_PRIO 1
|
||||
|
||||
|
||||
#define COUNTOF(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
|
||||
@@ -376,6 +376,7 @@
|
||||
<ClCompile Include="..\bmd380_sdk\components\ble\nrf_ble_scan\nrf_ble_scan.c" />
|
||||
<ClCompile Include="..\bmd380_sdk\components\libraries\queue\nrf_queue.c" />
|
||||
<ClCompile Include="le_db_discovery.c" />
|
||||
<ClCompile Include="le_dis_c.c" />
|
||||
<ClCompile Include="le_gap.c" />
|
||||
<ClCompile Include="le_gatt.c" />
|
||||
<ClCompile Include="le_gap_queue.c" />
|
||||
|
||||
@@ -1664,6 +1664,9 @@
|
||||
<ClCompile Include="le_gap_queue.c">
|
||||
<Filter>Source files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="le_dis_c.c">
|
||||
<Filter>Source files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\bmd380_sdk\components\ble\ble_services\ble_dis_c\ble_dis_c.h">
|
||||
|
||||
@@ -24,6 +24,8 @@ static void db_disc_handler(ble_db_discovery_evt_t *p_evt)
|
||||
{
|
||||
case BLE_DB_DISCOVERY_COMPLETE:
|
||||
NRF_LOG_INFO("BLE_DB_DISCOVERY_COMPLETE");
|
||||
extern void le_dis_c_on_db_disc_evt(ble_db_discovery_evt_t *p_evt);
|
||||
le_dis_c_on_db_disc_evt(p_evt);
|
||||
break;
|
||||
case BLE_DB_DISCOVERY_ERROR:
|
||||
NRF_LOG_INFO("BLE_DB_DISCOVERY_ERROR");
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#include "ble_dis_c.h"
|
||||
|
||||
#include "ble_gattc.h"
|
||||
#include "nrf_ble_gq.h"
|
||||
|
||||
#include "nrf_log.h"
|
||||
#include "nrf_log_ctrl.h"
|
||||
#include "nrf_log_default_backends.h"
|
||||
|
||||
ble_dis_c_char_type_t dis_c_char_types[10];
|
||||
BLE_DIS_C_DEF(m_ble_dis_c);
|
||||
|
||||
void dis_c_evt_handler(ble_dis_c_t *p_ble_dis_c, ble_dis_c_evt_t const *p_evt)
|
||||
{
|
||||
switch (p_evt->evt_type)
|
||||
{
|
||||
case BLE_DIS_C_EVT_DISCOVERY_COMPLETE:
|
||||
ble_dis_c_handles_assign(p_ble_dis_c, p_evt->conn_handle, p_evt->params.disc_complete.handles);
|
||||
ble_dis_c_read(&m_ble_dis_c, BLE_DIS_C_MANUF_NAME);
|
||||
ble_dis_c_read(&m_ble_dis_c, BLE_DIS_C_MODEL_NUM);
|
||||
ble_dis_c_read(&m_ble_dis_c, BLE_DIS_C_SERIAL_NUM);
|
||||
ble_dis_c_read(&m_ble_dis_c, BLE_DIS_C_FW_REV);
|
||||
ble_dis_c_read(&m_ble_dis_c, BLE_DIS_C_HW_REV);
|
||||
break;
|
||||
case BLE_DIS_C_EVT_DIS_C_READ_RSP: {
|
||||
char str[32];
|
||||
memset(str, 0x00, sizeof(str));
|
||||
memcpy(str, p_evt->params.read_rsp.content.string.p_data, p_evt->params.read_rsp.content.string.len);
|
||||
switch (p_evt->params.read_rsp.char_type)
|
||||
{
|
||||
case BLE_DIS_C_MANUF_NAME:
|
||||
NRF_LOG_INFO("Manufacture: %s", str);
|
||||
break;
|
||||
case BLE_DIS_C_MODEL_NUM:
|
||||
NRF_LOG_INFO("Model: %s", str);
|
||||
break;
|
||||
case BLE_DIS_C_SERIAL_NUM:
|
||||
NRF_LOG_INFO("Serial Num: %s", str);
|
||||
break;
|
||||
case BLE_DIS_C_FW_REV:
|
||||
NRF_LOG_INFO("FW Ver: %s", str);
|
||||
break;
|
||||
case BLE_DIS_C_HW_REV:
|
||||
NRF_LOG_INFO("HW Ver: %s", str);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void le_dis_c_init(void)
|
||||
{
|
||||
ble_dis_c_init_t dis_init;
|
||||
memset(&dis_init, 0x00, sizeof(dis_init));
|
||||
|
||||
extern nrf_ble_gq_t *le_gap_queue(void);
|
||||
dis_init.evt_handler = dis_c_evt_handler;
|
||||
dis_init.p_gatt_queue = le_gap_queue();
|
||||
dis_init.error_handler = NULL;
|
||||
|
||||
ble_dis_c_init(&m_ble_dis_c, &dis_init);
|
||||
}
|
||||
|
||||
void le_dis_c_on_db_disc_evt(ble_db_discovery_evt_t *p_evt)
|
||||
{
|
||||
ble_dis_c_on_db_disc_evt(&m_ble_dis_c, p_evt);
|
||||
}
|
||||
Reference in New Issue
Block a user