Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Donald Chen
pc-ble-driver-sd_api_v6
Commits
c066acf0
Commit
c066acf0
authored
Feb 08, 2019
by
Donald Chen
Browse files
remove workarounds
parent
3f9cb4de
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/heart_rate_monitor/main.c
View file @
c066acf0
...
@@ -617,11 +617,9 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
...
@@ -617,11 +617,9 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
switch
(
p_ble_evt
->
header
.
evt_id
)
switch
(
p_ble_evt
->
header
.
evt_id
)
{
{
case
BLE_GAP_EVT_CONNECTED
:
case
BLE_GAP_EVT_CONNECTED
:
printf
(
"Connected, connection handle 0x%04X
\n
"
,
p_ble_evt
->
evt
.
gap_evt
.
conn_handle
);
fflush
(
stdout
);
//DSC: for some reason this evt does not always get fired, so I set in the cccd write as well
m_connection_handle
=
p_ble_evt
->
evt
.
gap_evt
.
conn_handle
;
m_connection_handle
=
p_ble_evt
->
evt
.
gap_evt
.
conn_handle
;
printf
(
"Connected, connection handle 0x%04X
\n
"
,
m_connection_handle
);
fflush
(
stdout
);
break
;
break
;
case
BLE_GAP_EVT_DISCONNECTED
:
case
BLE_GAP_EVT_DISCONNECTED
:
...
@@ -639,7 +637,7 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
...
@@ -639,7 +637,7 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
break
;
break
;
case
BLE_GATTS_EVT_SYS_ATTR_MISSING
:
case
BLE_GATTS_EVT_SYS_ATTR_MISSING
:
err_code
=
sd_ble_gatts_sys_attr_set
(
adapter
,
p_ble_evt
->
evt
.
gap_evt
.
con
n_handle
,
NULL
,
0
,
0
);
err_code
=
sd_ble_gatts_sys_attr_set
(
adapter
,
m_connectio
n_handle
,
NULL
,
0
,
0
);
if
(
err_code
!=
NRF_SUCCESS
)
if
(
err_code
!=
NRF_SUCCESS
)
{
{
...
@@ -653,32 +651,13 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
...
@@ -653,32 +651,13 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
m_heart_rate_measurement_handle
.
cccd_handle
)
m_heart_rate_measurement_handle
.
cccd_handle
)
{
{
uint8_t
write_data
=
p_ble_evt
->
evt
.
gatts_evt
.
params
.
write
.
data
[
0
];
uint8_t
write_data
=
p_ble_evt
->
evt
.
gatts_evt
.
params
.
write
.
data
[
0
];
//DSC: set conn handle here since the connected event isn't always recieved
m_connection_handle
=
p_ble_evt
->
evt
.
gatts_evt
.
conn_handle
;
m_send_notifications
=
write_data
==
BLE_GATT_HVX_NOTIFICATION
;
m_send_notifications
=
write_data
==
BLE_GATT_HVX_NOTIFICATION
;
printf
(
"HRM CCCD write: conn_hndl %d, enabled %d
\n
"
,
m_connection_handle
,
m_send_notifications
);
fflush
(
stdout
);
}
break
;
case
BLE_GAP_EVT_CONN_PARAM_UPDATE
:
{
ble_gap_conn_params_t
*
p_cp
=
&
p_ble_evt
->
evt
.
gap_evt
.
params
.
conn_param_update
.
conn_params
;
printf
(
"Connection params updated: i_min %d, i_max %d, supp_to %d, s_lat %d
\n
"
,
p_cp
->
min_conn_interval
,
p_cp
->
max_conn_interval
,
p_cp
->
conn_sup_timeout
,
p_cp
->
slave_latency
);
fflush
(
stdout
);
}
}
break
;
break
;
#if NRF_SD_BLE_API >= 3
#if NRF_SD_BLE_API >= 3
case
BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST
:
case
BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST
:
err_code
=
sd_ble_gatts_exchange_mtu_reply
(
adapter
,
p_ble_evt
->
evt
.
gap_evt
.
con
n_handle
,
err_code
=
sd_ble_gatts_exchange_mtu_reply
(
adapter
,
m_connectio
n_handle
,
GATT_MTU_SIZE_DEFAULT
);
GATT_MTU_SIZE_DEFAULT
);
if
(
err_code
!=
NRF_SUCCESS
)
if
(
err_code
!=
NRF_SUCCESS
)
...
@@ -689,45 +668,15 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
...
@@ -689,45 +668,15 @@ static void ble_evt_dispatch(adapter_t * adapter, ble_evt_t * p_ble_evt)
break
;
break
;
#endif
#endif
#if NRF_SD_BLE_API >= 4
case
BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST
:
{
ble_gap_data_length_params_t
*
p_params
=
NULL
;
// &p_ble_evt->evt.gap_evt.params.data_length_update_request.peer_params;
err_code
=
sd_ble_gap_data_length_update
(
adapter
,
p_ble_evt
->
evt
.
gap_evt
.
conn_handle
,
p_params
,
NULL
);
printf
(
"Data length update request. Error code: 0x%02X
\n
"
,
err_code
);
fflush
(
stdout
);
}
break
;
case
BLE_GAP_EVT_DATA_LENGTH_UPDATE
:
printf
(
"Data length updated.
\n
"
);
fflush
(
stdout
);
break
;
case
BLE_GAP_EVT_PHY_UPDATE_REQUEST
:
{
ble_gap_phys_t
phys
=
{
BLE_GAP_PHY_1MBPS
,
BLE_GAP_PHY_1MBPS
};
err_code
=
sd_ble_gap_phy_update
(
adapter
,
p_ble_evt
->
evt
.
gap_evt
.
conn_handle
,
&
phys
);
printf
(
"PHY update request. Error code: 0x%02X
\n
"
,
err_code
);
fflush
(
stdout
);
}
break
;
case
BLE_GAP_EVT_PHY_UPDATE
:
printf
(
"PHY updated.
\n
"
);
fflush
(
stdout
);
break
;
#endif
#if NRF_SD_BLE_API <= 3
#if NRF_SD_BLE_API <= 3
case
BLE_EVT_TX_COMPLETE
:
case
BLE_EVT_TX_COMPLETE
:
#else
#else
case
BLE_GATTS_EVT_HVN_TX_COMPLETE
:
case
BLE_GATTS_EVT_HVN_TX_COMPLETE
:
#endif
#endif
printf
(
"Successfully transmitted a heart rate reading.
\n
"
);
#ifdef DEBUG
printf
(
"Successfully transmitted a heart rate reading."
);
fflush
(
stdout
);
fflush
(
stdout
);
#endif
break
;
break
;
default:
default:
...
@@ -830,6 +779,7 @@ int main(int argc, char * argv[])
...
@@ -830,6 +779,7 @@ int main(int argc, char * argv[])
{
{
heart_rate_measurement_send
();
heart_rate_measurement_send
();
}
}
Sleep
(
1000
);
Sleep
(
1000
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment