Hello,
I am in the process trying to send multiple packets over ble but cannot seems to figure out this UART example.
I have read many posts that use `ble_nus_string_send` to send string data, however, I can't seem to find this function located anywhere.
I currently can only send one byte at a time.
I started on the ble_blinky example as I needed some buttons so I don't know exactly what I would be missing.
This is a little test hello world on button click for button 0 in main.c:
static void button_event_handler(uint8_t pin_no, uint8_t button_action) { ret_code_t err_code; uint8_t data_value[] = {"HelloWorld!"}; uint16_t len = sizeof(data_value); SEGGER_RTT_printf(0, "Length = %d\n", len); switch (pin_no) { case BUTTON0_BUTTON: SEGGER_RTT_WriteString(0, "Send button state change.\n"); err_code = ble_btn_on_button0_change(m_conn_handle, &m_btn, data_value, len); if (err_code != NRF_SUCCESS && err_code != BLE_ERROR_INVALID_CONN_HANDLE && err_code != NRF_ERROR_INVALID_STATE && err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) { APP_ERROR_CHECK(err_code); } break; case BUTTON1_BUTTON: SEGGER_RTT_WriteString(0, "Send button state change.\n"); err_code = ble_btn_on_button1_change(m_conn_handle, &m_btn, button_action); if (err_code != NRF_SUCCESS && err_code != BLE_ERROR_INVALID_CONN_HANDLE && err_code != NRF_ERROR_INVALID_STATE && err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) { APP_ERROR_CHECK(err_code); } break; default: APP_ERROR_HANDLER(pin_no); break; } }
button_service.c:
uint32_t ble_btn_on_button0_change(uint16_t conn_handle, ble_btn_t * p_btn, uint8_t * button_state, uint16_t len) { ble_gatts_hvx_params_t params; memset(¶ms, 0, sizeof(params)); params.type = BLE_GATT_HVX_NOTIFICATION; params.handle = p_btn->button0_char_handles.value_handle; params.p_data = button_state; params.p_len = len; return sd_ble_gatts_hvx(conn_handle, ¶ms); }
I don't know if there is some external setting that I need to change to send more than one byte. I know this to be the case in some areas as it took me longer than I would like to admit to figure out that `app_button_enable` is required to enable buttons.
If I am totally off base please point me in the right direction.