This commit is contained in:
Matthias Ringwald 2015-07-02 20:18:25 +02:00
commit e94343db7e
2 changed files with 7 additions and 12 deletions

View File

@ -40,7 +40,6 @@ void CHECK_EQUAL_ARRAY(const uint8_t * expected, uint8_t * actual, int size){
// -----------------------------------------------------
static void handle_hci_event(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
printf(" handle_hci_event \n");
if (packet_type != HCI_EVENT_PACKET) return;
bd_addr_t address;
@ -48,9 +47,7 @@ static void handle_hci_event(void * connection, uint8_t packet_type, uint16_t ch
switch (event) {
case BTSTACK_EVENT_STATE:
if (packet[2] != HCI_STATE_WORKING) break;
printf("BTstack activated, set scan params!\n");
le_central_set_scan_parameters(0,0x0030, 0x0030);
printf("Start scanning\n");
le_central_start_scan();
break;
@ -65,11 +62,9 @@ static void handle_hci_event(void * connection, uint8_t packet_type, uint16_t ch
case HCI_EVENT_LE_META:
// wait for connection complete
if (packet[2] != HCI_SUBEVENT_LE_CONNECTION_COMPLETE) break;
printf("connected\n");
connected = 1;
break;
case HCI_EVENT_DISCONNECTION_COMPLETE:
printf("disconnected\n");
exit(0);
break;
default:

View File

@ -12,7 +12,7 @@
#include "sm.h"
static btstack_packet_handler_t att_packet_handler;
static void (*hci_packet_handler) (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) = NULL;
static void (*registered_l2cap_packet_handler) (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) = NULL;
static linked_list_t connections;
static const uint16_t max_mtu = 23;
@ -25,22 +25,22 @@ uint16_t get_gatt_client_handle(void){
void mock_simulate_command_complete(const hci_cmd_t *cmd){
uint8_t packet[] = {HCI_EVENT_COMMAND_COMPLETE, 4, 1, cmd->opcode & 0xff, cmd->opcode >> 8, 0};
hci_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
registered_l2cap_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
}
void mock_simulate_hci_state_working(void){
uint8_t packet[3] = {BTSTACK_EVENT_STATE, 0, HCI_STATE_WORKING};
hci_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, 3);
registered_l2cap_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, 3);
}
void mock_simulate_connected(void){
uint8_t packet[] = {0x3E, 0x13, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x9B, 0x77, 0xD1, 0xF7, 0xB1, 0x34, 0x50, 0x00, 0x00, 0x00, 0xD0, 0x07, 0x05};
hci_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
registered_l2cap_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
}
void mock_simulate_scan_response(void){
uint8_t packet[] = {0xE2, 0x00, 0xE2, 0x01, 0x34, 0xB1, 0xF7, 0xD1, 0x77, 0x9B, 0xCC, 0x09, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
hci_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
uint8_t packet[] = {0xE2, 0x13, 0xE2, 0x01, 0x34, 0xB1, 0xF7, 0xD1, 0x77, 0x9B, 0xCC, 0x09, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
registered_l2cap_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
}
le_command_status_t le_central_start_scan(void){
@ -89,7 +89,7 @@ void l2cap_register_fixed_channel(btstack_packet_handler_t packet_handler, uint1
}
void l2cap_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){
hci_packet_handler = handler;
registered_l2cap_packet_handler = handler;
}