1
1
/**
2
2
* Copyright (c) 2016 - 2017, Nordic Semiconductor ASA
3
- *
3
+ *
4
4
* All rights reserved.
5
- *
5
+ *
6
6
* Redistribution and use in source and binary forms, with or without modification,
7
7
* are permitted provided that the following conditions are met:
8
- *
8
+ *
9
9
* 1. Redistributions of source code must retain the above copyright notice, this
10
10
* list of conditions and the following disclaimer.
11
- *
11
+ *
12
12
* 2. Redistributions in binary form, except as embedded into a Nordic
13
13
* Semiconductor ASA integrated circuit in a product or a software update for
14
14
* such product, must reproduce the above copyright notice, this list of
15
15
* conditions and the following disclaimer in the documentation and/or other
16
16
* materials provided with the distribution.
17
- *
17
+ *
18
18
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
19
19
* contributors may be used to endorse or promote products derived from this
20
20
* software without specific prior written permission.
21
- *
21
+ *
22
22
* 4. This software, with or without modification, must only be used with a
23
23
* Nordic Semiconductor ASA integrated circuit.
24
- *
24
+ *
25
25
* 5. Any software provided in binary form under this license must not be reverse
26
26
* engineered, decompiled, modified and/or disassembled.
27
- *
27
+ *
28
28
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
29
29
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30
30
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
35
35
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36
36
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37
37
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
- *
38
+ *
39
39
*/
40
40
41
41
#include "nrf_ble_dfu.h"
@@ -143,7 +143,7 @@ static uint32_t conn_params_init(void)
143
143
/**@brief Function for the Advertising functionality initialization.
144
144
*
145
145
* @details Encodes the required advertising data and passes it to the stack.
146
- * The advertising data encoded here is specific for DFU.
146
+ * The advertising data encoded here is specific for DFU.
147
147
* Setting advertising data can by done by calling @ref ble_advdata_set.
148
148
*/
149
149
static uint32_t advertising_init (uint8_t adv_flags )
@@ -154,12 +154,12 @@ static uint32_t advertising_init(uint8_t adv_flags)
154
154
uint16_t actual_device_name_length = max_device_name_length ;
155
155
156
156
uint8_t p_encoded_advdata [MAX_ADV_DATA_LENGTH ];
157
-
157
+
158
158
// Encode flags.
159
159
p_encoded_advdata [0 ] = 0x2 ;
160
160
p_encoded_advdata [1 ] = BLE_GAP_AD_TYPE_FLAGS ;
161
161
p_encoded_advdata [2 ] = adv_flags ;
162
-
162
+
163
163
// Encode 'more available' uuid list.
164
164
p_encoded_advdata [3 ] = 0x3 ;
165
165
p_encoded_advdata [4 ] = BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE ;
@@ -172,7 +172,7 @@ static uint32_t advertising_init(uint8_t adv_flags)
172
172
{
173
173
return err_code ;
174
174
}
175
-
175
+
176
176
// Set GAP device in advertising data.
177
177
if (actual_device_name_length <= max_device_name_length )
178
178
{
@@ -524,7 +524,7 @@ static bool on_rw_authorize_req(ble_dfu_t * p_dfu, ble_evt_t * p_ble_evt)
524
524
ble_gatts_rw_authorize_reply_params_t auth_reply = {0 };
525
525
ble_gatts_evt_rw_authorize_request_t * p_authorize_request ;
526
526
ble_gatts_evt_write_t * p_ble_write_evt ;
527
-
527
+
528
528
p_authorize_request = & (p_ble_evt -> evt .gatts_evt .params .authorize_request );
529
529
p_ble_write_evt = & (p_ble_evt -> evt .gatts_evt .params .authorize_request .request .write );
530
530
@@ -544,7 +544,7 @@ static bool on_rw_authorize_req(ble_dfu_t * p_dfu, ble_evt_t * p_ble_evt)
544
544
{
545
545
// Send an error response to the peer indicating that the CCCD is improperly configured.
546
546
auth_reply .params .write .gatt_status = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR ;
547
-
547
+
548
548
// Ignore response of auth reply
549
549
(void )sd_ble_gatts_rw_authorize_reply (m_conn_handle , & auth_reply );
550
550
return false;
@@ -660,9 +660,9 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
660
660
{
661
661
if (on_rw_authorize_req (& m_dfu , p_ble_evt ))
662
662
{
663
- err_code = on_ctrl_pt_write (& m_dfu ,
663
+ err_code = on_ctrl_pt_write (& m_dfu ,
664
664
& (p_ble_evt -> evt .gatts_evt .params .authorize_request .request .write ));
665
- #ifdef NRF_DFU_DEBUG_VERSION
665
+ #ifdef NRF_DFU_DEBUG_VERSION
666
666
if (err_code != NRF_SUCCESS )
667
667
{
668
668
NRF_LOG_ERROR ("Could not handle on_ctrl_pt_write. err_code: 0x%04x\r\n" , err_code );
@@ -684,19 +684,19 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
684
684
err_code = sd_ble_gatts_sys_attr_set (p_ble_evt -> evt .gap_evt .conn_handle , NULL , 0 , 0 );
685
685
APP_ERROR_CHECK (err_code );
686
686
break ;
687
-
687
+
688
688
case BLE_GATTS_EVT_WRITE :
689
689
on_write (& m_dfu , p_ble_evt );
690
690
break ;
691
691
692
692
#if (NRF_SD_BLE_API_VERSION == 3 )
693
693
case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST :
694
- err_code = sd_ble_gatts_exchange_mtu_reply (p_ble_evt -> evt .gatts_evt .conn_handle ,
694
+ err_code = sd_ble_gatts_exchange_mtu_reply (p_ble_evt -> evt .gatts_evt .conn_handle ,
695
695
NRF_BLE_MAX_MTU_SIZE );
696
696
APP_ERROR_CHECK (err_code );
697
697
break ; // BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST
698
698
#endif
699
-
699
+
700
700
default :
701
701
// No implementation needed.
702
702
break ;
@@ -771,8 +771,8 @@ static uint32_t gap_params_init(void)
771
771
strlen (DEVICE_NAME ));
772
772
VERIFY_SUCCESS (err_code );
773
773
774
- gap_conn_params .min_conn_interval = MIN_CONN_INTERVAL ;
775
- gap_conn_params .max_conn_interval = MAX_CONN_INTERVAL ;
774
+ gap_conn_params .min_conn_interval = NRF_DFU_BLE_MIN_CONN_INTERVAL ;
775
+ gap_conn_params .max_conn_interval = NRF_DFU_BLE_MAX_CONN_INTERVAL ;
776
776
gap_conn_params .slave_latency = SLAVE_LATENCY ;
777
777
gap_conn_params .conn_sup_timeout = CONN_SUP_TIMEOUT ;
778
778
@@ -809,8 +809,8 @@ static uint32_t ble_stack_init(bool init_softdevice)
809
809
810
810
#if (NRF_SD_BLE_API_VERSION == 3 )
811
811
ble_enable_params .gatt_enable_params .att_mtu = NRF_BLE_MAX_MTU_SIZE ;
812
- #endif
813
-
812
+ #endif
813
+
814
814
// Enable BLE stack.
815
815
err_code = softdevice_enable (& ble_enable_params );
816
816
return err_code ;
0 commit comments