l2cap: fix build

This commit is contained in:
Matthias Ringwald 2021-10-28 09:56:05 +02:00
parent c0c8a8293c
commit c61d23ae45
2 changed files with 6 additions and 2 deletions

View File

@ -81,10 +81,11 @@ uint16_t l2cap_create_signaling_packet(uint8_t * acl_buffer, hci_con_handle_t ha
"M", // invalid format for unit testing
#endif
};
static const unsigned int num_l2cap_commands = sizeof(l2cap_signaling_commands_format) / sizeof(const char *);
btstack_assert(0 < cmd);
static const unsigned int num_l2cap_commands = sizeof(l2cap_signaling_commands_format) / sizeof(const char *);
btstack_assert(cmd <= num_l2cap_commands);
UNUSED(num_l2cap_commands);
const char *format = l2cap_signaling_commands_format[cmd-1u];
btstack_assert(format != NULL);

View File

@ -14,11 +14,13 @@ static uint16_t l2cap_send_le_signaling_packet(hci_con_handle_t handle, L2CAP_SI
static uint8_t acl_buffer[100];
va_list argptr;
va_start(argptr, identifier);
uint16_t len = l2cap_create_signaling_le(acl_buffer, handle, cmd, identifier, argptr);
uint16_t len = l2cap_create_signaling_packet(acl_buffer, handle, 0x00, L2CAP_CID_SIGNALING_LE, cmd, identifier, argptr);
va_end(argptr);
return len;
}
#if 0
// invalid cmds trigger assert
TEST(L2CAP_LE_Signaling, l2cap_create_signaling_le_invalid_cmd){
uint16_t size = l2cap_send_le_signaling_packet((hci_con_handle_t) 0x01, (L2CAP_SIGNALING_COMMANDS)(CONNECTION_PARAMETER_UPDATE_REQUEST-1), 1);
CHECK_EQUAL(0, size);
@ -33,6 +35,7 @@ TEST(L2CAP_LE_Signaling, l2cap_create_signaling_le_invalid_cmd_FF){
uint16_t size = l2cap_send_le_signaling_packet((hci_con_handle_t) 0x01, (L2CAP_SIGNALING_COMMANDS)0xFF, 1);
CHECK_EQUAL(0, size);
}
#endif
TEST(L2CAP_LE_Signaling, l2cap_create_signaling_le_invalid_cmd_M_format){
uint16_t size = l2cap_send_le_signaling_packet((hci_con_handle_t) 0x01, COMMAND_WITH_INVALID_FORMAT, 1);