Skip to content

Commit c0f61a5

Browse files
committed
minor bug fixes
1 parent b12e64d commit c0f61a5

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

src/ble/helpers/ble_helpers.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ ret_code_t ble_helper_characteristic_add(ble_helper_characteristic_init_t *init)
9191

9292
APP_ERROR_CHECK(err_code);
9393

94-
*(init->value_handle) = p_handles.value_handle;
95-
*(init->cccd_handle) = p_handles.cccd_handle;
94+
if(init->value_handle != 0x00) {
95+
*(init->value_handle) = p_handles.value_handle;
96+
}
97+
if(init->cccd_handle != 0x00) {
98+
*(init->cccd_handle) = p_handles.cccd_handle;
99+
}
96100

97101
if (init->number_of_digitals > 0) {
98102
uint16_t number_of_digitals_handle;

src/ble/services/hid/ble_hid.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ uint16_t ble_hid_characteristic_information_handle;
1818

1919
uint16_t ble_hid_characteristic_report_value_handle;
2020
uint16_t ble_hid_characteristic_report_cccd_handle;
21+
uint16_t ble_hid_characteristic_control_point_value_handle;
2122

2223
bool ble_hid_report_notification_enabled = false;
2324

@@ -181,19 +182,19 @@ void ble_hid_handle_input_change(uint32_t index, gpio_config_input_digital_t *co
181182
APP_ERROR_CHECK(err_code);
182183
}
183184

184-
void ble_hid_on_connect(ble_evt_t *p_ble_evt)
185+
void ble_hid_on_connect(const ble_evt_t *p_ble_evt)
185186
{
186187
ble_hid_connection_handle = p_ble_evt->evt.gap_evt.conn_handle;
187188
}
188189

189-
void ble_hid_on_disconnect(ble_evt_t *p_ble_evt)
190+
void ble_hid_on_disconnect(const ble_evt_t *p_ble_evt)
190191
{
191192
UNUSED_PARAMETER(p_ble_evt);
192193
ble_hid_connection_handle = BLE_CONN_HANDLE_INVALID;
193194
ble_hid_report_notification_enabled = false;
194195
}
195196

196-
void handle_hid_report_cccd_write(ble_gatts_evt_write_t *write_evt)
197+
void handle_hid_report_cccd_write(const ble_gatts_evt_write_t *write_evt)
197198
{
198199
if (write_evt->len == 2)
199200
{
@@ -202,9 +203,9 @@ void handle_hid_report_cccd_write(ble_gatts_evt_write_t *write_evt)
202203
}
203204
}
204205

205-
void ble_hid_on_write(ble_evt_t *p_ble_evt)
206+
void ble_hid_on_write(const ble_evt_t *p_ble_evt)
206207
{
207-
ble_gatts_evt_write_t *write_evt = &p_ble_evt
208+
const ble_gatts_evt_write_t *write_evt = &p_ble_evt
208209
->evt
209210
.gatts_evt
210211
.params
@@ -214,12 +215,21 @@ void ble_hid_on_write(ble_evt_t *p_ble_evt)
214215

215216
if (handle == ble_hid_characteristic_report_cccd_handle)
216217
{
218+
NRF_LOG_DEBUG("writing cccd");
217219
handle_hid_report_cccd_write(write_evt);
218220
return;
219221
}
222+
223+
if (handle == ble_hid_characteristic_control_point_value_handle)
224+
{
225+
NRF_LOG_DEBUG("writing control point");
226+
return;
227+
}
228+
229+
NRF_LOG_DEBUG("writing unknown thingathing %d %d %d %d %d", handle, ble_hid_characteristic_information_handle, ble_hid_characteristic_report_cccd_handle, ble_hid_characteristic_report_value_handle, ble_hid_characteristic_control_point_value_handle);
220230
}
221231

222-
void ble_hid_on_ble_evt(ble_evt_t *p_ble_evt)
232+
void ble_hid_on_ble_evt(const ble_evt_t *p_ble_evt)
223233
{
224234
switch (p_ble_evt->header.evt_id)
225235
{
@@ -264,7 +274,8 @@ ret_code_t ble_hid_characteristic_report_map_add()
264274
.is_readable = true,
265275
.max_length = sizeof(descriptor_value),
266276
.initial_value_length = sizeof(descriptor_value),
267-
.initial_value = descriptor_value
277+
.initial_value = descriptor_value,
278+
.value_handle = &ble_hid_characteristic_information_handle
268279
};
269280

270281
return ble_helper_characteristic_add(&init);
@@ -276,6 +287,7 @@ ret_code_t ble_hid_characteristic_control_point_add()
276287
.service_handle = ble_hid_service_handle,
277288
.uuid = BLE_UUID_HID_CHARACTERISTIC_CONTROL_POINT,
278289
.is_writable = true,
290+
.value_handle = &ble_hid_characteristic_control_point_value_handle,
279291
.max_length = 1
280292
};
281293

src/ble/services/hid/ble_hid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
ret_code_t ble_hid_init();
1414
void ble_hid_handle_input_change(uint32_t index, gpio_config_input_digital_t *config);
15-
void ble_hid_on_ble_evt(ble_evt_t *p_ble_evt);
15+
void ble_hid_on_ble_evt(const ble_evt_t *p_ble_evt);

src/error_handler/error_handler.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include "app_error.h"
55
#include "watchdog.h"
66

7+
#ifdef NRF52
8+
#include "nrf_strerror.h"
9+
#endif
10+
711
#define DEAD_BEEF 0xDEADBEEF /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */
812

913
void HardFault_Handler(){

0 commit comments

Comments
 (0)