mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-03 23:47:08 +00:00
mtk: fix hci transport, daemon: fix compile
This commit is contained in:
parent
fea5a680db
commit
8b26961ae5
@ -93,7 +93,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
||||
}
|
||||
break;
|
||||
|
||||
case DAEMON_EVENT_RFCOMM_SERVICE_REGISTERED:
|
||||
case RFCOMM_EVENT_PERSISTENT_CHANNEL:
|
||||
rfcomm_channel_nr = packet[3];
|
||||
printf("RFCOMM channel %u was assigned by BTdaemon\n", rfcomm_channel_nr);
|
||||
bt_send_cmd(&rfcomm_register_service_cmd, rfcomm_channel_nr, 0xffff); // reserved channel, mtu limited by l2cap
|
||||
|
@ -108,7 +108,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
||||
}
|
||||
break;
|
||||
|
||||
case DAEMON_EVENT_RFCOMM_SERVICE_REGISTERED:
|
||||
case RFCOMM_EVENT_PERSISTENT_CHANNEL:
|
||||
rfcomm_channel_nr = packet[3];
|
||||
printf("RFCOMM channel %u was assigned by BTdaemon\n", rfcomm_channel_nr);
|
||||
bt_send_cmd(&rfcomm_register_service_cmd, rfcomm_channel_nr, 0xffff); // reserved channel, mtu limited by l2cap
|
||||
|
@ -1076,9 +1076,9 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
// enforce \0
|
||||
packet[3+248] = 0;
|
||||
rfcomm_channel = rfcomm_service_db_channel_for_service((char*)&packet[3]);
|
||||
log_info("DAEMON_EVENT_RFCOMM_SERVICE_REGISTERED %u", rfcomm_channel);
|
||||
log_info("RFCOMM_EVENT_PERSISTENT_CHANNEL %u", rfcomm_channel);
|
||||
uint8_t event[4];
|
||||
event[0] = DAEMON_EVENT_RFCOMM_SERVICE_REGISTERED;
|
||||
event[0] = RFCOMM_EVENT_PERSISTENT_CHANNEL;
|
||||
event[1] = sizeof(event) - 2;
|
||||
event[2] = 0;
|
||||
event[3] = rfcomm_channel;
|
||||
|
@ -50,7 +50,7 @@ uint8_t rfcomm_service_db_channel_for_service(const char *serviceName){
|
||||
// quick hack: use sum over service name, map 0 to 1
|
||||
int sum = 0;
|
||||
while (*serviceName){
|
||||
sum += serviceName;
|
||||
sum += *serviceName;
|
||||
}
|
||||
int channel = sum & 0x0f;
|
||||
if (channel == 0) return 1;
|
||||
|
@ -124,12 +124,12 @@ static void h4_register_packet_handler(void (*handler)(uint8_t packet_type, ui
|
||||
}
|
||||
|
||||
static void h4_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type) {
|
||||
if (hci_transport_h4->ds->fd == 0) return -1;
|
||||
if (hci_transport_h4->ds->fd == 0) return;
|
||||
|
||||
// read up to bytes_to_read data in
|
||||
ssize_t bytes_read = mtk_bt_read(hci_transport_h4->ds->fd, &hci_packet_in[0], sizeof(hci_packet_in));
|
||||
|
||||
if (bytes_read == 0) return 0;
|
||||
if (bytes_read == 0) return;
|
||||
|
||||
// iterate over packets
|
||||
uint16_t pos = 0;
|
||||
@ -150,8 +150,6 @@ static void h4_process(btstack_data_source_t *ds, btstack_data_source_callback_t
|
||||
packet_handler(hci_packet_in[pos], &hci_packet_in[pos+1], packet_len-1);
|
||||
pos += packet_len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||
|
Loading…
Reference in New Issue
Block a user