btstack/example/embedded/gap_dedicated_bonding.c

54 lines
1.4 KiB
C
Raw Normal View History

2014-01-24 11:51:38 +00:00
// *****************************************************************************
2014-01-24 11:51:38 +00:00
//
// minimal setup for SDP client over USB or UART
//
// *****************************************************************************
2014-01-24 11:51:38 +00:00
#include "btstack-config.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <btstack/hci_cmds.h>
#include <btstack/run_loop.h>
#include "hci.h"
#include "gap.h"
#include "btstack_memory.h"
#include "hci_dump.h"
// static bd_addr_t remote = {0x04,0x0C,0xCE,0xE4,0x85,0xD3};
static bd_addr_t remote = {0x84, 0x38, 0x35, 0x65, 0xD1, 0x15};
static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size){
printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
if (packet_type != HCI_EVENT_PACKET) return;
switch (packet[0]) {
case BTSTACK_EVENT_STATE:
// bt stack activated, get started
if (packet[2] == HCI_STATE_WORKING){
gap_dedicated_bonding(remote, 1);
}
break;
case GAP_DEDICATED_BONDING_COMPLETED:
printf("GAP Dedicated Bonding Complete, status %u\n", packet[2]);
default:
break;
}
}
2014-11-14 20:42:29 +00:00
int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
2014-01-24 11:51:38 +00:00
hci_register_packet_handler(packet_handler);
// turn on!
2014-11-14 20:42:29 +00:00
hci_power_control(HCI_POWER_ON); run_loop_execute();
2014-01-24 11:51:38 +00:00
return 0;
}