mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
removed unneccesary code in example
This commit is contained in:
parent
87ea0ea477
commit
5698302b40
4
TODO.txt
4
TODO.txt
@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
UNTIL 13. August 2009 : Google Open Source Jam
|
UNTIL 13. August 2009 : Google Open Source Jam
|
||||||
- implement L2CAP state machine
|
- implement L2CAP state machine
|
||||||
|
- outgoing for now only
|
||||||
- decide on naming conventions for various layers
|
- decide on naming conventions for various layers
|
||||||
|
- decide where L2CAP state machine belongs
|
||||||
|
- decide on l2CAP event/data interface
|
||||||
|
- client does not need to send raw ACL packets
|
||||||
- provide demos:
|
- provide demos:
|
||||||
- BT Scanner: module info, inquiry, remote name
|
- BT Scanner: module info, inquiry, remote name
|
||||||
- Terminal app with L2CAP support - Python or Java PC demo
|
- Terminal app with L2CAP support - Python or Java PC demo
|
||||||
|
@ -12,48 +12,38 @@
|
|||||||
#include "../src/btstack.h"
|
#include "../src/btstack.h"
|
||||||
#include "../src/run_loop.h"
|
#include "../src/run_loop.h"
|
||||||
#include "../src/hci.h"
|
#include "../src/hci.h"
|
||||||
#include "../src/l2cap.h"
|
|
||||||
|
|
||||||
hci_con_handle_t con_handle_out = 0;
|
bd_addr_t addr = {0x00, 0x03, 0xc9, 0x3d, 0x77, 0x43 }; // Think Outside Keyboard
|
||||||
uint16_t dest_cid;
|
|
||||||
uint16_t local_cid;
|
|
||||||
|
|
||||||
void acl_handler(uint8_t *packet, uint16_t size){
|
void acl_handler(uint8_t *packet, uint16_t size){
|
||||||
// just dump data
|
// just dump data for now
|
||||||
hexdump( packet, size );
|
hexdump( packet, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_handler(uint8_t *packet, uint16_t size){
|
void event_handler(uint8_t *packet, uint16_t size){
|
||||||
// printf("Event type: %x, opcode: %x, other %x\n", packet[0], packet[3] | packet[4] << 8);
|
// bt stack activated, get started - set local name
|
||||||
|
|
||||||
bd_addr_t addr = {0x00, 0x03, 0xc9, 0x3d, 0x77, 0x43 }; // Think Outside Keyboard
|
|
||||||
|
|
||||||
// bt stack activated, get started
|
|
||||||
if (packet[0] == HCI_EVENT_BTSTACK_WORKING ||
|
if (packet[0] == HCI_EVENT_BTSTACK_WORKING ||
|
||||||
(packet[0] == HCI_EVENT_BTSTACK_STATE && packet[2] == HCI_STATE_WORKING)) {
|
(packet[0] == HCI_EVENT_BTSTACK_STATE && packet[2] == HCI_STATE_WORKING)) {
|
||||||
bt_send_cmd(&hci_write_local_name, "BTstack-Test");
|
bt_send_cmd(&hci_write_local_name, "BTstack-Test");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set local name
|
// use pairing
|
||||||
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_local_name) ) {
|
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_local_name) ) {
|
||||||
bt_send_cmd(&hci_write_authentication_enable, 1);
|
bt_send_cmd(&hci_write_authentication_enable, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use pairing
|
// connect to HID device (PSM 0x13) at addr
|
||||||
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_authentication_enable) ) {
|
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_authentication_enable) ) {
|
||||||
bt_send_cmd(&hci_write_inquiry_mode, 2);
|
l2cap_create_channel(addr, 0x13, event_handler, acl_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// inform about pin code request
|
// inform about pin code request
|
||||||
if (packet[0] == HCI_EVENT_PIN_CODE_REQUEST){
|
if (packet[0] == HCI_EVENT_PIN_CODE_REQUEST){
|
||||||
printf("Please enter PIN 1234 on remote device\n");
|
printf("Please enter PIN 1234 on remote device\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect to device at addr
|
|
||||||
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) {
|
|
||||||
l2cap_create_channel(addr, 0x13, event_handler, acl_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// inform about new l2cap connection
|
||||||
if (packet[0] == HCI_EVENT_L2CAP_CHANNEL_OPENED){
|
if (packet[0] == HCI_EVENT_L2CAP_CHANNEL_OPENED){
|
||||||
printf("Channel successfully opened, handle 0x%02x, local cid 0x%02x\n", READ_BT_16(packet, 2), READ_BT_16(packet, 4));;
|
printf("Channel successfully opened, handle 0x%02x, local cid 0x%02x\n", READ_BT_16(packet, 2), READ_BT_16(packet, 4));;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user