Skip to content

Commit 6e33825

Browse files
committed
Init header without init whole buffer
1 parent b1e0d2f commit 6e33825

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,19 @@ void assert_nrf_callback (uint16_t line_num, uint8_t const * p_file_name)
411411
// Process BLE event from SD
412412
uint32_t proc_ble(void)
413413
{
414-
__ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ] = {0};
414+
__ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ];
415415
uint16_t ev_len = BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX);
416416

417+
// Init header
418+
ble_evt_t* evt = (ble_evt_t*) ev_buf;
419+
evt->header.evt_id = 0;
420+
417421
// Get BLE Event
418422
uint32_t err = sd_ble_evt_get(ev_buf, &ev_len);
419423

420424
// Handle valid event, ignore error
421425
if( NRF_SUCCESS == err)
422426
{
423-
ble_evt_t* evt = (ble_evt_t*) ev_buf;
424-
425427
switch (evt->header.evt_id)
426428
{
427429
case BLE_GAP_EVT_CONNECTED:

0 commit comments

Comments
 (0)