Skip to content

Commit

Permalink
nimble/ll: Add debug printf vs hci event
Browse files Browse the repository at this point in the history
This adds helper to send vs hci event with payload formatted in
printf-like manner. It should be only used for debugging.
  • Loading branch information
andrzej-kaczmarek committed Jun 5, 2023
1 parent 8d6cc49 commit 27dc910
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions nimble/controller/include/controller/ble_ll_ctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ void ble_ll_calc_session_key(struct ble_ll_conn_sm *connsm);
void ble_ll_ctrl_phy_update_proc_complete(struct ble_ll_conn_sm *connsm);
void ble_ll_ctrl_initiate_dle(struct ble_ll_conn_sm *connsm, bool initial);
void ble_ll_hci_ev_send_vs_assert(const char *file, uint32_t line);
void ble_ll_hci_ev_send_vs_printf(uint8_t id, const char *fmt, ...);
void ble_ll_hci_ev_send_vs_llcp_trace(uint8_t type, uint16_t handle, uint16_t count,
void *pdu, size_t length);

Expand Down
30 changes: 29 additions & 1 deletion nimble/controller/src/ble_ll_hci_ev.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
#include <stdint.h>

#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "syscfg/syscfg.h"
#include "nimble/ble.h"
Expand Down Expand Up @@ -609,6 +611,32 @@ ble_ll_hci_ev_send_vs_assert(const char *file, uint32_t line)
}
}

void
ble_ll_hci_ev_send_vs_printf(uint8_t id, const char *fmt, ...)
{
struct ble_hci_ev_vs *ev;
struct ble_hci_ev *hci_ev;
va_list ap;

hci_ev = ble_transport_alloc_evt(1);
if (!hci_ev) {
return;
}

hci_ev->opcode = BLE_HCI_EVCODE_VS;
hci_ev->length = sizeof(*ev);

ev = (void *) hci_ev->data;
ev->id = id;

va_start(ap, fmt);
hci_ev->length += vsnprintf((void *)ev->data,
BLE_HCI_MAX_DATA_LEN - sizeof(*ev), fmt, ap);
va_end(ap);

ble_ll_hci_event_send(hci_ev);
}

#if MYNEWT_VAL(BLE_LL_HCI_LLCP_TRACE)
void
ble_ll_hci_ev_send_vs_llcp_trace(uint8_t type, uint16_t handle, uint16_t count,
Expand Down

0 comments on commit 27dc910

Please sign in to comment.