mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 08:42:28 +00:00
daemon/l2cap_example: use scraped PSMs
This commit is contained in:
parent
818629960d
commit
6259b5df56
@ -51,6 +51,7 @@
|
|||||||
#include "btstack_client.h"
|
#include "btstack_client.h"
|
||||||
#include "hci_cmd.h"
|
#include "hci_cmd.h"
|
||||||
#include "classic/sdp_util.h"
|
#include "classic/sdp_util.h"
|
||||||
|
#include "bluetooth_psm.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "btstack_run_loop_windows.h"
|
#include "btstack_run_loop_windows.h"
|
||||||
@ -107,7 +108,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
if (status) {
|
if (status) {
|
||||||
l2cap_reg_fail = 1;
|
l2cap_reg_fail = 1;
|
||||||
} else {
|
} else {
|
||||||
if (psm == PSM_HID_INTERRUPT && !l2cap_reg_fail) { // The second of the two
|
if (psm == BLUETOOTH_PSM_HID_INTERRUPT && !l2cap_reg_fail) { // The second of the two
|
||||||
bt_send_cmd(&btstack_set_discoverable, 1);
|
bt_send_cmd(&btstack_set_discoverable, 1);
|
||||||
printf("Both PSMs registered.\n");
|
printf("Both PSMs registered.\n");
|
||||||
}
|
}
|
||||||
@ -164,10 +165,10 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
printf("Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
printf("Channel successfully opened: %s, handle 0x%02x, psm 0x%02x, local cid 0x%02x, remote cid 0x%02x\n",
|
||||||
bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
bd_addr_to_str(event_addr), con_handle, psm, local_cid, l2cap_event_channel_opened_get_remote_cid(packet));
|
||||||
|
|
||||||
if (psm == PSM_HID_CONTROL){
|
if (psm == BLUETOOTH_PSM_HID_CONTROL){
|
||||||
hid_control = local_cid;
|
hid_control = local_cid;
|
||||||
}
|
}
|
||||||
if (psm == PSM_HID_INTERRUPT){
|
if (psm == BLUETOOTH_PSM_HID_INTERRUPT){
|
||||||
hid_interrupt = local_cid;
|
hid_interrupt = local_cid;
|
||||||
}
|
}
|
||||||
if (hid_control && hid_interrupt){
|
if (hid_control && hid_interrupt){
|
||||||
@ -217,8 +218,8 @@ int main (int argc, const char * argv[]){
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
bt_register_packet_handler(packet_handler);
|
bt_register_packet_handler(packet_handler);
|
||||||
bt_send_cmd(&l2cap_register_service_cmd, PSM_HID_CONTROL, 250);
|
bt_send_cmd(&l2cap_register_service_cmd, BLUETOOTH_PSM_HID_CONTROL, 250);
|
||||||
bt_send_cmd(&l2cap_register_service_cmd, PSM_HID_INTERRUPT, 250);
|
bt_send_cmd(&l2cap_register_service_cmd, BLUETOOTH_PSM_HID_INTERRUPT, 250);
|
||||||
|
|
||||||
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON );
|
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON );
|
||||||
btstack_run_loop_execute();
|
btstack_run_loop_execute();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user