mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-27 06:35:20 +00:00
init rls_line_status, respond to unknown multiplexer commands with nsc rsp
This commit is contained in:
parent
c0164e1c7c
commit
e88584bc6b
36
src/rfcomm.c
36
src/rfcomm.c
@ -261,6 +261,7 @@ static void rfcomm_multiplexer_initialize(rfcomm_multiplexer_t *multiplexer){
|
||||
multiplexer->send_dm_for_dlci = 0;
|
||||
multiplexer->max_frame_size = rfcomm_max_frame_size_for_l2cap_mtu(l2cap_max_mtu());
|
||||
multiplexer->test_data_len = 0;
|
||||
multiplexer->nsc_command = 0;
|
||||
}
|
||||
|
||||
static rfcomm_multiplexer_t * rfcomm_multiplexer_create_for_addr(bd_addr_t *addr){
|
||||
@ -351,6 +352,8 @@ static void rfcomm_channel_initialize(rfcomm_channel_t *channel, rfcomm_multiple
|
||||
channel->new_credits_incoming = 0x30;
|
||||
channel->incoming_flow_control = 0;
|
||||
|
||||
channel->rls_line_status = RFCOMM_RLS_STATUS_INVALID;
|
||||
|
||||
if (service) {
|
||||
// incoming connection
|
||||
channel->outgoing = 0;
|
||||
@ -566,6 +569,16 @@ static int rfcomm_send_uih_msc_rsp(rfcomm_multiplexer_t *multiplexer, uint8_t dl
|
||||
return rfcomm_send_packet_for_multiplexer(multiplexer, address, BT_RFCOMM_UIH, 0, (uint8_t *) payload, pos);
|
||||
}
|
||||
|
||||
static int rfcomm_send_uih_nsc_rsp(rfcomm_multiplexer_t *multiplexer, uint8_t command) {
|
||||
uint8_t address = (1 << 0) | (multiplexer->outgoing<< 1);
|
||||
uint8_t payload[3];
|
||||
uint8_t pos = 0;
|
||||
payload[pos++] = BT_RFCOMM_NSC_RSP;
|
||||
payload[pos++] = 1 << 1 | 1; // len
|
||||
payload[pos++] = command;
|
||||
return rfcomm_send_packet_for_multiplexer(multiplexer, address, BT_RFCOMM_UIH, 0, (uint8_t *) payload, pos);
|
||||
}
|
||||
|
||||
static int rfcomm_send_uih_pn_command(rfcomm_multiplexer_t *multiplexer, uint8_t dlci, uint16_t max_frame_size){
|
||||
uint8_t payload[10];
|
||||
uint8_t address = (1 << 0) | (multiplexer->outgoing << 1);
|
||||
@ -969,11 +982,19 @@ static void rfcomm_multiplexer_state_machine(rfcomm_multiplexer_t * multiplexer,
|
||||
|
||||
// process stored DM responses
|
||||
if (multiplexer->send_dm_for_dlci){
|
||||
rfcomm_send_dm_pf(multiplexer, multiplexer->send_dm_for_dlci);
|
||||
multiplexer->send_dm_for_dlci = 0;
|
||||
rfcomm_send_dm_pf(multiplexer, multiplexer->send_dm_for_dlci);
|
||||
return;
|
||||
}
|
||||
|
||||
if (multiplexer->nsc_command){
|
||||
uint8_t command = multiplexer->nsc_command;
|
||||
multiplexer->nsc_command = 0;
|
||||
rfcomm_send_uih_nsc_rsp(multiplexer, command);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (multiplexer->state) {
|
||||
case RFCOMM_MULTIPLEXER_SEND_SABM_0:
|
||||
switch (event) {
|
||||
@ -1344,10 +1365,17 @@ void rfcomm_channel_packet_handler(rfcomm_multiplexer_t * multiplexer, uint8_t
|
||||
rfcomm_channel_state_machine_2(multiplexer, message_dlci, (rfcomm_channel_event_t*) &event_rls);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
log_error("Received unknown UIH packet - 0x%02x\n", packet[payload_offset]);
|
||||
|
||||
// Following commands are handled by rfcomm_multiplexer_l2cap_packet_handler
|
||||
// case BT_RFCOMM_TEST_CMD:
|
||||
// case BT_RFCOMM_FCOFF_CMD:
|
||||
// case BT_RFCOMM_FCON_CMD:
|
||||
// everything else is an not supported command
|
||||
default: {
|
||||
log_error("Received unknown UIH command packet - 0x%02x\n", packet[payload_offset]);
|
||||
multiplexer->nsc_command = packet[payload_offset];
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -121,6 +121,7 @@ typedef enum {
|
||||
CH_EVT_RCVD_DM,
|
||||
CH_EVT_RCVD_MSC_CMD,
|
||||
CH_EVT_RCVD_MSC_RSP,
|
||||
CH_EVT_RCVD_NSC_RSP,
|
||||
CH_EVT_RCVD_RLS_CMD,
|
||||
CH_EVT_RCVD_RLS_RSP,
|
||||
CH_EVT_RCVD_RPN_CMD,
|
||||
@ -213,6 +214,9 @@ typedef struct {
|
||||
// send DM for DLCI != 0
|
||||
uint8_t send_dm_for_dlci;
|
||||
|
||||
// non supportec command, 0 if not set
|
||||
uint8_t nsc_command;
|
||||
|
||||
// test data - limited to RFCOMM_TEST_DATA_MAX_LEN
|
||||
uint8_t test_data_len;
|
||||
uint8_t test_data[RFCOMM_TEST_DATA_MAX_LEN];
|
||||
|
Loading…
x
Reference in New Issue
Block a user