mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-31 18:33:00 +00:00
event: introduce hci_event_packet_get_type
This commit is contained in:
parent
591e55515a
commit
0e2df43f5c
@ -87,9 +87,9 @@ static btstack_packet_callback_registration_t sm_event_callback_registration;
|
|||||||
static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING) {
|
||||||
printf("ANCS Client Demo ready.\n");
|
printf("ANCS Client Demo ready.\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -107,8 +107,8 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
|||||||
|
|
||||||
static void ancs_callback(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void ancs_callback(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
const char * attribute_name;
|
const char * attribute_name;
|
||||||
if (packet[0] != HCI_EVENT_ANCS_META) return;
|
if (hci_event_packet_get_type(packet) != HCI_EVENT_ANCS_META) return;
|
||||||
switch (packet[2]){
|
switch (hci_event_ancs_meta_get_subevent_code(packet)){
|
||||||
case ANCS_SUBEVENT_CLIENT_CONNECTED:
|
case ANCS_SUBEVENT_CLIENT_CONNECTED:
|
||||||
printf("ANCS Client: Connected\n");
|
printf("ANCS Client: Connected\n");
|
||||||
break;
|
break;
|
||||||
|
@ -36,21 +36,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "btstack_config.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "btstack.h"
|
||||||
#include "hci_cmd.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 = {0x84, 0x38, 0x35, 0x65, 0xD1, 0x15};
|
static bd_addr_t remote = {0x84, 0x38, 0x35, 0x65, 0xD1, 0x15};
|
||||||
|
|
||||||
@ -59,7 +51,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
|
|||||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// bt stack activated, get started
|
// bt stack activated, get started
|
||||||
if (packet[2] == HCI_STATE_WORKING){
|
if (packet[2] == HCI_STATE_WORKING){
|
||||||
|
@ -53,17 +53,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack.h"
|
||||||
|
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
|
|
||||||
#include "btstack_debug.h"
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "hci.h"
|
|
||||||
#include "hci_dump.h"
|
|
||||||
|
|
||||||
#include "classic/sdp_util.h"
|
|
||||||
|
|
||||||
#define MAX_DEVICES 10
|
#define MAX_DEVICES 10
|
||||||
enum DEVICE_STATE { REMOTE_NAME_REQUEST, REMOTE_NAME_INQUIRED, REMOTE_NAME_FETCHED };
|
enum DEVICE_STATE { REMOTE_NAME_REQUEST, REMOTE_NAME_INQUIRED, REMOTE_NAME_FETCHED };
|
||||||
struct device {
|
struct device {
|
||||||
@ -143,10 +134,9 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
int numResponses;
|
int numResponses;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
// printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]);
|
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
|
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
|
|
||||||
switch(state){
|
switch(state){
|
||||||
/* @text In INIT, an inquiry scan is started, and the application transits to
|
/* @text In INIT, an inquiry scan is started, and the application transits to
|
||||||
|
@ -46,17 +46,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack.h"
|
||||||
|
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
|
|
||||||
#include "btstack_debug.h"
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "hci.h"
|
|
||||||
#include "hci_dump.h"
|
|
||||||
#include "gap.h"
|
|
||||||
|
|
||||||
#include "classic/sdp_util.h"
|
|
||||||
|
|
||||||
#define MAX_DEVICES 10
|
#define MAX_DEVICES 10
|
||||||
enum DEVICE_STATE { BONDING_REQUEST, BONDING_REQUESTED, BONDING_COMPLETED };
|
enum DEVICE_STATE { BONDING_REQUEST, BONDING_REQUESTED, BONDING_COMPLETED };
|
||||||
@ -131,10 +121,9 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
int i;
|
int i;
|
||||||
int numResponses;
|
int numResponses;
|
||||||
|
|
||||||
// printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]);
|
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
|
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
|
|
||||||
switch(state){
|
switch(state){
|
||||||
|
|
||||||
|
@ -50,11 +50,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "hci_cmd.h"
|
#include "btstack.h"
|
||||||
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "hci.h"
|
|
||||||
#include "ble/ad_parser.h"
|
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
|
|
||||||
@ -235,7 +231,7 @@ static void dump_advertisement_data(uint8_t * adv_data, uint8_t adv_size){
|
|||||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// BTstack activated, get started
|
// BTstack activated, get started
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
|
@ -131,7 +131,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
|
|
||||||
switch(state){
|
switch(state){
|
||||||
case TC_W4_SERVICE_RESULT:
|
case TC_W4_SERVICE_RESULT:
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
||||||
gatt_event_service_query_result_get_service(packet, &battery_service);
|
gatt_event_service_query_result_get_service(packet, &battery_service);
|
||||||
printf("Battery service found:\n");
|
printf("Battery service found:\n");
|
||||||
@ -154,7 +154,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TC_W4_CHARACTERISTIC_RESULT:
|
case TC_W4_CHARACTERISTIC_RESULT:
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_CHARACTERISTIC_QUERY_RESULT:
|
case GATT_EVENT_CHARACTERISTIC_QUERY_RESULT:
|
||||||
printf("Battery level characteristic found:\n");
|
printf("Battery level characteristic found:\n");
|
||||||
gatt_event_characteristic_query_result_get_characteristic(packet, &config_characteristic);
|
gatt_event_characteristic_query_result_get_characteristic(packet, &config_characteristic);
|
||||||
@ -170,14 +170,14 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TC_W4_BATTERY_DATA:
|
case TC_W4_BATTERY_DATA:
|
||||||
if (packet[0] == GATT_EVENT_QUERY_COMPLETE){
|
if (hci_event_packet_get_type(packet) == GATT_EVENT_QUERY_COMPLETE){
|
||||||
if (packet[4] != 0){
|
if (packet[4] != 0){
|
||||||
printf("\nNotification is not possible: ");
|
printf("\nNotification is not possible: ");
|
||||||
error_code(packet[4]);
|
error_code(packet[4]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (packet[0] != GATT_EVENT_NOTIFICATION) break;
|
if (hci_event_packet_get_type(packet) != GATT_EVENT_NOTIFICATION) break;
|
||||||
printf("\nBattery Data:\n");
|
printf("\nBattery Data:\n");
|
||||||
dump_characteristic_value(&packet[8], little_endian_read_16(packet, 6));
|
dump_characteristic_value(&packet[8], little_endian_read_16(packet, 6));
|
||||||
break;
|
break;
|
||||||
@ -205,7 +205,7 @@ static void fill_advertising_report_from_packet(advertising_report_t * report, u
|
|||||||
static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
advertising_report_t report;
|
advertising_report_t report;
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// BTstack activated, get started
|
// BTstack activated, get started
|
||||||
|
@ -172,7 +172,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
|||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
advertising_report_t report;
|
advertising_report_t report;
|
||||||
|
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// BTstack activated, get started
|
// BTstack activated, get started
|
||||||
@ -226,7 +226,7 @@ static int search_services = 1;
|
|||||||
static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
gatt_client_service_t service;
|
gatt_client_service_t service;
|
||||||
gatt_client_characteristic_t characteristic;
|
gatt_client_characteristic_t characteristic;
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_SERVICE_QUERY_RESULT:\
|
case GATT_EVENT_SERVICE_QUERY_RESULT:\
|
||||||
gatt_event_service_query_result_get_service(packet, &service);
|
gatt_event_service_query_result_get_service(packet, &service);
|
||||||
dump_service(&service);
|
dump_service(&service);
|
||||||
|
@ -50,25 +50,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "btstack_config.h"
|
|
||||||
|
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "classic/sdp_util.h"
|
|
||||||
|
|
||||||
#include "btstack_debug.h"
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "gap.h"
|
|
||||||
#include "hci.h"
|
|
||||||
#include "hci_dump.h"
|
|
||||||
|
|
||||||
#include "l2cap.h"
|
|
||||||
|
|
||||||
#include "le_counter.h"
|
#include "le_counter.h"
|
||||||
|
#include "btstack.h"
|
||||||
#include "ble/att_db.h"
|
|
||||||
#include "ble/att_server.h"
|
|
||||||
#include "ble/le_device_db.h"
|
|
||||||
#include "ble/sm.h"
|
|
||||||
|
|
||||||
#define HEARTBEAT_PERIOD_MS 1000
|
#define HEARTBEAT_PERIOD_MS 1000
|
||||||
|
|
||||||
@ -145,7 +128,7 @@ static void le_counter_setup(void){
|
|||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
printf("LE Counter Demo ready.\n");
|
printf("LE Counter Demo ready.\n");
|
||||||
|
@ -54,24 +54,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack.h"
|
||||||
|
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "classic/sdp_util.h"
|
|
||||||
|
|
||||||
#include "btstack_debug.h"
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "hci.h"
|
|
||||||
#include "hci_dump.h"
|
|
||||||
#include "l2cap.h"
|
|
||||||
|
|
||||||
#include "le_streamer.h"
|
#include "le_streamer.h"
|
||||||
|
|
||||||
#include "ble/att_db.h"
|
|
||||||
#include "ble/att_server.h"
|
|
||||||
#include "ble/le_device_db.h"
|
|
||||||
#include "ble/sm.h"
|
|
||||||
|
|
||||||
static int le_notification_enabled;
|
static int le_notification_enabled;
|
||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
static int att_write_callback(hci_con_handle_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
|
static int att_write_callback(hci_con_handle_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
|
||||||
@ -178,7 +163,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
int mtu;
|
int mtu;
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||||
le_notification_enabled = 0;
|
le_notification_enabled = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -322,7 +322,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint8_t *packet,
|
|||||||
des_iterator_t prot_it;
|
des_iterator_t prot_it;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
|
case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
|
||||||
// Handle new SDP record
|
// Handle new SDP record
|
||||||
if (sdp_event_query_attribute_byte_get_record_id(packet) != record_id) {
|
if (sdp_event_query_attribute_byte_get_record_id(packet) != record_id) {
|
||||||
@ -436,7 +436,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
/* LISTING_RESUME */
|
/* LISTING_RESUME */
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
event = packet[0];
|
event = hci_event_packet_get_type(packet);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
/* @text When BTSTACK_EVENT_STATE with state HCI_STATE_WORKING
|
/* @text When BTSTACK_EVENT_STATE with state HCI_STATE_WORKING
|
||||||
* is received and the example is started in client mode, the remote SDP BNEP query is started.
|
* is received and the example is started in client mode, the remote SDP BNEP query is started.
|
||||||
|
@ -113,7 +113,7 @@ static void sdp_client_init(void){
|
|||||||
/* LISTING_START(SDPQueryUUID): Querying the a list of service records on a remote device. */
|
/* LISTING_START(SDPQueryUUID): Querying the a list of service records on a remote device. */
|
||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
@ -166,7 +166,7 @@ static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel
|
|||||||
des_iterator_t prot_it;
|
des_iterator_t prot_it;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
|
case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
|
||||||
// handle new record
|
// handle new record
|
||||||
if (sdp_event_query_attribute_byte_get_record_id(packet) != record_id){
|
if (sdp_event_query_attribute_byte_get_record_id(packet) != record_id){
|
||||||
|
@ -107,10 +107,8 @@ static bd_addr_t remote = {0x04,0x0C,0xCE,0xE4,0x85,0xD3};
|
|||||||
|
|
||||||
/* LISTING_START(SDPQueryUUID): Querying a list of service records on a remote device. */
|
/* LISTING_START(SDPQueryUUID): Querying a list of service records on a remote device. */
|
||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler (uint8_t packet_type, uint16_t channel, 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;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
|
@ -71,10 +71,8 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
|
|||||||
|
|
||||||
|
|
||||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler(uint8_t packet_type, uint16_t channel, 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;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
|
@ -52,28 +52,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack.h"
|
||||||
|
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "classic/sdp_util.h"
|
|
||||||
|
|
||||||
#include "btstack_debug.h"
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "hci.h"
|
|
||||||
#include "hci_dump.h"
|
|
||||||
|
|
||||||
#include "l2cap.h"
|
|
||||||
|
|
||||||
#include "classic/rfcomm.h"
|
|
||||||
|
|
||||||
#include "classic/sdp_server.h"
|
|
||||||
#include "spp_and_le_counter.h"
|
#include "spp_and_le_counter.h"
|
||||||
|
|
||||||
#include "ble/att_db.h"
|
|
||||||
#include "ble/att_server.h"
|
|
||||||
#include "ble/le_device_db.h"
|
|
||||||
#include "ble/sm.h"
|
|
||||||
|
|
||||||
#define RFCOMM_SERVER_CHANNEL 1
|
#define RFCOMM_SERVER_CHANNEL 1
|
||||||
#define HEARTBEAT_PERIOD_MS 1000
|
#define HEARTBEAT_PERIOD_MS 1000
|
||||||
|
|
||||||
@ -120,7 +101,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
|
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case HCI_EVENT_PIN_CODE_REQUEST:
|
case HCI_EVENT_PIN_CODE_REQUEST:
|
||||||
// inform about pin code request
|
// inform about pin code request
|
||||||
printf("Pin code request - using '0000'\n");
|
printf("Pin code request - using '0000'\n");
|
||||||
|
@ -50,21 +50,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack.h"
|
||||||
|
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "classic/sdp_util.h"
|
|
||||||
|
|
||||||
#include "btstack_debug.h"
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "hci.h"
|
|
||||||
#include "hci_dump.h"
|
|
||||||
|
|
||||||
#include "l2cap.h"
|
|
||||||
|
|
||||||
#include "classic/rfcomm.h"
|
|
||||||
|
|
||||||
#include "classic/sdp_server.h"
|
|
||||||
|
|
||||||
#define RFCOMM_SERVER_CHANNEL 1
|
#define RFCOMM_SERVER_CHANNEL 1
|
||||||
#define HEARTBEAT_PERIOD_MS 1000
|
#define HEARTBEAT_PERIOD_MS 1000
|
||||||
@ -191,7 +177,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
|
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// BTstack activated, get started
|
// BTstack activated, get started
|
||||||
|
@ -145,7 +145,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
|
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
|
@ -117,10 +117,8 @@ static void send_packet(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler (uint8_t packet_type, uint16_t channel, 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;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
|
@ -114,7 +114,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
// printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]);
|
// printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]);
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
|
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
|
|
||||||
switch(state){
|
switch(state){
|
||||||
|
|
||||||
|
@ -69,7 +69,6 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
int i;
|
int i;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
|
|
||||||
//printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]);
|
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
|
|
||||||
case L2CAP_DATA_PACKET:
|
case L2CAP_DATA_PACKET:
|
||||||
@ -80,7 +79,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_POWERON_FAILED:
|
case BTSTACK_EVENT_POWERON_FAILED:
|
||||||
printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n");
|
printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n");
|
||||||
|
@ -94,7 +94,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_POWERON_FAILED:
|
case BTSTACK_EVENT_POWERON_FAILED:
|
||||||
printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n");
|
printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n");
|
||||||
|
@ -49,10 +49,9 @@
|
|||||||
|
|
||||||
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
|
|
||||||
// printf("- packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]);
|
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
|
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
|
|
||||||
switch (event){
|
switch (event){
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
|
@ -76,7 +76,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_POWERON_FAILED:
|
case BTSTACK_EVENT_POWERON_FAILED:
|
||||||
// handle HCI init failure
|
// handle HCI init failure
|
||||||
|
@ -76,7 +76,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_POWERON_FAILED:
|
case BTSTACK_EVENT_POWERON_FAILED:
|
||||||
// handle HCI init failure
|
// handle HCI init failure
|
||||||
|
@ -91,7 +91,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_POWERON_FAILED:
|
case BTSTACK_EVENT_POWERON_FAILED:
|
||||||
// handle HCI init failure
|
// handle HCI init failure
|
||||||
|
@ -62,7 +62,7 @@ void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint
|
|||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_POWERON_FAILED:
|
case BTSTACK_EVENT_POWERON_FAILED:
|
||||||
printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n");
|
printf("HCI Init failed - make sure you have turned off Bluetooth in the System Settings\n");
|
||||||
|
@ -1399,7 +1399,7 @@ static void deamon_status_event_handler(uint8_t *packet, uint16_t size){
|
|||||||
uint8_t update_status = 0;
|
uint8_t update_status = 0;
|
||||||
|
|
||||||
// handle state event
|
// handle state event
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
hci_state = packet[2];
|
hci_state = packet[2];
|
||||||
log_info("New state: %u\n", hci_state);
|
log_info("New state: %u\n", hci_state);
|
||||||
@ -1502,7 +1502,7 @@ static void daemon_packet_handler(void * connection, uint8_t packet_type, uint16
|
|||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
deamon_status_event_handler(packet, size);
|
deamon_status_event_handler(packet, size);
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
|
|
||||||
case HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS:
|
case HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS:
|
||||||
// ACL buffer freed...
|
// ACL buffer freed...
|
||||||
@ -1628,7 +1628,7 @@ static void rfcomm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handle_sdp_rfcomm_service_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void handle_sdp_rfcomm_service_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case SDP_EVENT_QUERY_RFCOMM_SERVICE:
|
case SDP_EVENT_QUERY_RFCOMM_SERVICE:
|
||||||
case SDP_EVENT_QUERY_COMPLETE:
|
case SDP_EVENT_QUERY_COMPLETE:
|
||||||
// already HCI Events, just forward them
|
// already HCI Events, just forward them
|
||||||
@ -1650,7 +1650,7 @@ static void sdp_client_assert_buffer(int size){
|
|||||||
static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void handle_sdp_client_query_result(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
int event_len;
|
int event_len;
|
||||||
|
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case SDP_EVENT_QUERY_ATTRIBUTE_BYTE:
|
case SDP_EVENT_QUERY_ATTRIBUTE_BYTE:
|
||||||
sdp_client_assert_buffer(sdp_event_query_attribute_byte_get_attribute_length(packet));
|
sdp_client_assert_buffer(sdp_event_query_attribute_byte_get_attribute_length(packet));
|
||||||
attribute_value[sdp_event_query_attribute_byte_get_data_offset(packet)] = sdp_event_query_attribute_byte_get_data(packet);
|
attribute_value[sdp_event_query_attribute_byte_get_data_offset(packet)] = sdp_event_query_attribute_byte_get_data(packet);
|
||||||
@ -1804,7 +1804,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
|
|
||||||
// hack: handle disconnection_complete_here instead of main hci event packet handler
|
// hack: handle disconnection_complete_here instead of main hci event packet handler
|
||||||
// we receive a HCI event packet in disguise
|
// we receive a HCI event packet in disguise
|
||||||
if (packet[0] == HCI_EVENT_DISCONNECTION_COMPLETE){
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_DISCONNECTION_COMPLETE){
|
||||||
log_info("daemon hack: handle disconnection_complete in handle_gatt_client_event instead of main hci event packet handler");
|
log_info("daemon hack: handle disconnection_complete in handle_gatt_client_event instead of main hci event packet handler");
|
||||||
hci_con_handle_t con_handle = little_endian_read_16(packet, 3);
|
hci_con_handle_t con_handle = little_endian_read_16(packet, 3);
|
||||||
daemon_remove_gatt_client_helper(con_handle);
|
daemon_remove_gatt_client_helper(con_handle);
|
||||||
@ -1812,7 +1812,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
// only handle GATT Events
|
// only handle GATT Events
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
||||||
case GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT:
|
case GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT:
|
||||||
case GATT_EVENT_NOTIFICATION:
|
case GATT_EVENT_NOTIFICATION:
|
||||||
@ -1839,7 +1839,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
connection_t *connection = NULL;
|
connection_t *connection = NULL;
|
||||||
|
|
||||||
// daemon doesn't track which connection subscribed to this particular handle, so we just notify all connections
|
// daemon doesn't track which connection subscribed to this particular handle, so we just notify all connections
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_NOTIFICATION:
|
case GATT_EVENT_NOTIFICATION:
|
||||||
case GATT_EVENT_INDICATION:{
|
case GATT_EVENT_INDICATION:{
|
||||||
hci_dump_packet(HCI_EVENT_PACKET, 0, packet, size);
|
hci_dump_packet(HCI_EVENT_PACKET, 0, packet, size);
|
||||||
@ -1862,7 +1862,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
|
|
||||||
if (!connection) return;
|
if (!connection) return;
|
||||||
|
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
|
|
||||||
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
||||||
case GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT:
|
case GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT:
|
||||||
@ -1878,7 +1878,7 @@ static void handle_gatt_client_event(uint8_t packet_type, uint16_t channel, uint
|
|||||||
case GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT:
|
case GATT_EVENT_LONG_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT:
|
||||||
offset = little_endian_read_16(packet, 6);
|
offset = little_endian_read_16(packet, 6);
|
||||||
length = little_endian_read_16(packet, 8);
|
length = little_endian_read_16(packet, 8);
|
||||||
gatt_client_helper->characteristic_buffer[0] = packet[0]; // store type (characteristic/descriptor)
|
gatt_client_helper->characteristic_buffer[0] = hci_event_packet_get_type(packet); // store type (characteristic/descriptor)
|
||||||
gatt_client_helper->characteristic_handle = little_endian_read_16(packet, 4); // store attribute handle
|
gatt_client_helper->characteristic_handle = little_endian_read_16(packet, 4); // store attribute handle
|
||||||
gatt_client_helper->characteristic_length = offset + length; // update length
|
gatt_client_helper->characteristic_length = offset + length; // update length
|
||||||
memcpy(&gatt_client_helper->characteristic_buffer[10 + offset], &packet[10], length);
|
memcpy(&gatt_client_helper->characteristic_buffer[10 + offset], &packet[10], length);
|
||||||
|
@ -229,7 +229,7 @@ static void gatt_client_callback(uint8_t packet_type, uint8_t * packet, uint16_t
|
|||||||
uint16_t value_length;
|
uint16_t value_length;
|
||||||
|
|
||||||
BLEDevice device(con_handle);
|
BLEDevice device(con_handle);
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
||||||
if (gattServiceDiscoveredCallback) {
|
if (gattServiceDiscoveredCallback) {
|
||||||
gatt_client_service_t service;
|
gatt_client_service_t service;
|
||||||
|
@ -74,8 +74,8 @@ void loop(void){
|
|||||||
/* LISTING_START(ANCSCallback): ANCS Callback */
|
/* LISTING_START(ANCSCallback): ANCS Callback */
|
||||||
void ancs_callback(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
void ancs_callback(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
const char * attribute_name;
|
const char * attribute_name;
|
||||||
if (packet[0] != HCI_EVENT_ANCS_META) return;
|
if (hci_event_packet_get_type(packet) != HCI_EVENT_ANCS_META) return;
|
||||||
switch (packet[0]){
|
switch (hci_event_ancs_meta_get_subevent_code()]){
|
||||||
case ANCS_SUBEVENT_CLIENT_CONNECTED:
|
case ANCS_SUBEVENT_CLIENT_CONNECTED:
|
||||||
Serial.println("ANCS Client: Connected");
|
Serial.println("ANCS Client: Connected");
|
||||||
break;
|
break;
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
#include "classic/btstack_link_key_db.h"
|
#include "classic/btstack_link_key_db.h"
|
||||||
#include "classic/rfcomm.h"
|
#include "classic/rfcomm.h"
|
||||||
#include "classic/sdp_server.h"
|
#include "classic/sdp_server.h"
|
||||||
@ -90,7 +91,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
|
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
|
@ -130,7 +130,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
|
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
|
@ -127,7 +127,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
|
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// bt stack activated
|
// bt stack activated
|
||||||
@ -172,7 +172,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
[dev setAddress:addr];
|
[dev setAddress:addr];
|
||||||
[dev setPageScanRepetitionMode:packet[offset]];
|
[dev setPageScanRepetitionMode:packet[offset]];
|
||||||
offset += 1;
|
offset += 1;
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case HCI_EVENT_INQUIRY_RESULT:
|
case HCI_EVENT_INQUIRY_RESULT:
|
||||||
offset += 2; // Reserved + Reserved
|
offset += 2; // Reserved + Reserved
|
||||||
[dev setClassOfDevice:little_endian_read_24(packet, 3 + numResponses*(6+1+1+1) + i*3)];
|
[dev setClassOfDevice:little_endian_read_24(packet, 3 + numResponses*(6+1+1+1) + i*3)];
|
||||||
|
@ -264,7 +264,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
case kW4SysBTDisabled:
|
case kW4SysBTDisabled:
|
||||||
|
|
||||||
// DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED
|
// DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED
|
||||||
if ( packet[0] == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED){
|
if ( hci_event_packet_get_type(packet) == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED){
|
||||||
if (packet[2]){
|
if (packet[2]){
|
||||||
// system bt on - first time try to disable it
|
// system bt on - first time try to disable it
|
||||||
if ( state == kW4SysBTState) {
|
if ( state == kW4SysBTState) {
|
||||||
@ -289,7 +289,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kW4Activated:
|
case kW4Activated:
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
state = kActivated;
|
state = kActivated;
|
||||||
@ -307,21 +307,21 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kW4Deactivated:
|
case kW4Deactivated:
|
||||||
if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_OFF){
|
if (hci_event_packet_get_type(packet) != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_OFF){
|
||||||
state = kDeactivated;
|
state = kDeactivated;
|
||||||
[self sendDeactivated];
|
[self sendDeactivated];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kActivated:
|
case kActivated:
|
||||||
if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_FALLING_ASLEEP){
|
if (hci_event_packet_get_type(packet) != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_FALLING_ASLEEP){
|
||||||
state = kSleeping;
|
state = kSleeping;
|
||||||
[self sendSleepEnter];
|
[self sendSleepEnter];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kSleeping:
|
case kSleeping:
|
||||||
if (packet[0] != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_WORKING){
|
if (hci_event_packet_get_type(packet) != BTSTACK_EVENT_STATE && packet[2] == HCI_STATE_WORKING){
|
||||||
state = kActivated;
|
state = kActivated;
|
||||||
[self sendSleepExit];
|
[self sendSleepExit];
|
||||||
}
|
}
|
||||||
@ -403,7 +403,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kW4InquiryMode:
|
case kW4InquiryMode:
|
||||||
if (packet[0] == HCI_EVENT_COMMAND_COMPLETE && COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) {
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_COMPLETE && COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) {
|
||||||
discoveryState = kInquiry;
|
discoveryState = kInquiry;
|
||||||
bt_send_cmd(&hci_inquiry, HCI_INQUIRY_LAP, INQUIRY_INTERVAL, 0);
|
bt_send_cmd(&hci_inquiry, HCI_INQUIRY_LAP, INQUIRY_INTERVAL, 0);
|
||||||
[self sendDiscoveryInquiry];
|
[self sendDiscoveryInquiry];
|
||||||
@ -412,7 +412,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
|
|
||||||
case kInquiry:
|
case kInquiry:
|
||||||
|
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case HCI_EVENT_INQUIRY_RESULT:
|
case HCI_EVENT_INQUIRY_RESULT:
|
||||||
numResponses = packet[2];
|
numResponses = packet[2];
|
||||||
for (i=0; i<numResponses ; i++){
|
for (i=0; i<numResponses ; i++){
|
||||||
@ -472,20 +472,20 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kRemoteName:
|
case kRemoteName:
|
||||||
if (packet[0] == HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE){
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE){
|
||||||
[self handleRemoteName:packet];
|
[self handleRemoteName:packet];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kW4InquiryModeBeforeStop:
|
case kW4InquiryModeBeforeStop:
|
||||||
if (packet[0] == HCI_EVENT_COMMAND_COMPLETE && COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) {
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_COMPLETE && COMMAND_COMPLETE_EVENT(packet, hci_write_inquiry_mode) ) {
|
||||||
discoveryState = kInactive;
|
discoveryState = kInactive;
|
||||||
[self sendDiscoveryStoppedEvent];
|
[self sendDiscoveryStoppedEvent];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kW4InquiryStop:
|
case kW4InquiryStop:
|
||||||
if (packet[0] == HCI_EVENT_INQUIRY_COMPLETE
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_INQUIRY_COMPLETE
|
||||||
|| COMMAND_COMPLETE_EVENT(packet, hci_inquiry_cancel)) {
|
|| COMMAND_COMPLETE_EVENT(packet, hci_inquiry_cancel)) {
|
||||||
discoveryState = kInactive;
|
discoveryState = kInactive;
|
||||||
[self sendDiscoveryStoppedEvent];
|
[self sendDiscoveryStoppedEvent];
|
||||||
@ -493,7 +493,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kW4RemoteNameBeforeStop:
|
case kW4RemoteNameBeforeStop:
|
||||||
if (packet[0] == HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE
|
||||||
|| COMMAND_COMPLETE_EVENT(packet, hci_remote_name_request_cancel)){
|
|| COMMAND_COMPLETE_EVENT(packet, hci_remote_name_request_cancel)){
|
||||||
discoveryState = kInactive;
|
discoveryState = kInactive;
|
||||||
[self sendDiscoveryStoppedEvent];
|
[self sendDiscoveryStoppedEvent];
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#import "BluetoothController.h"
|
#import "BluetoothController.h"
|
||||||
#include "btstack_run_loop.h"
|
#include "btstack_run_loop.h"
|
||||||
#include "btstack_run_loop_cocoa.h"
|
#include "btstack_run_loop_cocoa.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
|
|
||||||
#pragma mark callback handler
|
#pragma mark callback handler
|
||||||
static void btstackStoppedCallback(CFNotificationCenterRef center,
|
static void btstackStoppedCallback(CFNotificationCenterRef center,
|
||||||
@ -179,7 +180,7 @@ static BluetoothController* sharedInstance = nil;
|
|||||||
// NSLog(@"bt_packet_handler event: %u, state %u", packet[0], state);
|
// NSLog(@"bt_packet_handler event: %u, state %u", packet[0], state);
|
||||||
|
|
||||||
// update state
|
// update state
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
hci_state = packet[2];
|
hci_state = packet[2];
|
||||||
// NSLog(@"new BTSTACK_EVENT_STATE %u", hci_state);
|
// NSLog(@"new BTSTACK_EVENT_STATE %u", hci_state);
|
||||||
@ -195,7 +196,7 @@ static BluetoothController* sharedInstance = nil;
|
|||||||
switch(state){
|
switch(state){
|
||||||
|
|
||||||
case kIdle:
|
case kIdle:
|
||||||
if (packet[0] == BTSTACK_EVENT_STATE) {
|
if (hci_event_packet_get_type(packet) == BTSTACK_EVENT_STATE) {
|
||||||
if (hci_state == HCI_STATE_OFF) {
|
if (hci_state == HCI_STATE_OFF) {
|
||||||
bt_send_cmd(&btstack_get_system_bluetooth_enabled);
|
bt_send_cmd(&btstack_get_system_bluetooth_enabled);
|
||||||
} else {
|
} else {
|
||||||
@ -205,7 +206,7 @@ static BluetoothController* sharedInstance = nil;
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kW4SystemOffToEnableBTstack:
|
case kW4SystemOffToEnableBTstack:
|
||||||
if (packet[0] == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED) {
|
if (hci_event_packet_get_type(packet) == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED) {
|
||||||
if (system_bluetooth == 0){
|
if (system_bluetooth == 0){
|
||||||
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON);
|
bt_send_cmd(&btstack_set_power_mode, HCI_POWER_ON);
|
||||||
state = kIdle;
|
state = kIdle;
|
||||||
@ -214,13 +215,13 @@ static BluetoothController* sharedInstance = nil;
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kW4BTstackOffToEnableSystem:
|
case kW4BTstackOffToEnableSystem:
|
||||||
if (packet[0] == BTSTACK_EVENT_STATE) {
|
if (hci_event_packet_get_type(packet) == BTSTACK_EVENT_STATE) {
|
||||||
if (hci_state == HCI_STATE_OFF) {
|
if (hci_state == HCI_STATE_OFF) {
|
||||||
// NSLog(@"Sending set system bluetooth enable A");
|
// NSLog(@"Sending set system bluetooth enable A");
|
||||||
bt_send_cmd(&btstack_set_system_bluetooth_enabled, 1);
|
bt_send_cmd(&btstack_set_system_bluetooth_enabled, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (packet[0] == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED) {
|
if (hci_event_packet_get_type(packet) == DAEMON_EVENT_SYSTEM_BLUETOOTH_ENABLED) {
|
||||||
if (system_bluetooth == 0){
|
if (system_bluetooth == 0){
|
||||||
// NSLog(@"Sending set system bluetooth enable B");
|
// NSLog(@"Sending set system bluetooth enable B");
|
||||||
bt_send_cmd(&btstack_set_system_bluetooth_enabled, 1);
|
bt_send_cmd(&btstack_set_system_bluetooth_enabled, 1);
|
||||||
|
@ -157,7 +157,7 @@ static float addToHistory(int history[histSize], int value){
|
|||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
|
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
|
|
||||||
case HCI_EVENT_COMMAND_COMPLETE:
|
case HCI_EVENT_COMMAND_COMPLETE:
|
||||||
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_authentication_enable) ) {
|
if ( COMMAND_COMPLETE_EVENT(packet, hci_write_authentication_enable) ) {
|
||||||
|
@ -90,7 +90,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
|
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
|
@ -116,7 +116,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
|||||||
bd_addr_t addr;
|
bd_addr_t addr;
|
||||||
uint8_t adv_data[] = { 02, 01, 05, 03, 02, 0xf0, 0xff };
|
uint8_t adv_data[] = { 02, 01, 05, 03, 02, 0xf0, 0xff };
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// bt stack activated, get started - set local name
|
// bt stack activated, get started - set local name
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
|
@ -229,7 +229,7 @@ unsigned char hid_process_packet(unsigned char *hid_report, uint16_t *buffer, ui
|
|||||||
|
|
||||||
static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void l2cap_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
|
|
||||||
if (packet_type == HCI_EVENT_PACKET && packet[0] == L2CAP_EVENT_CHANNEL_OPENED){
|
if (packet_type == HCI_EVENT_PACKET && hci_event_packet_get_type(packet) == L2CAP_EVENT_CHANNEL_OPENED){
|
||||||
if (packet[2]) {
|
if (packet[2]) {
|
||||||
printf("Connection failed\n\r");
|
printf("Connection failed\n\r");
|
||||||
return;
|
return;
|
||||||
@ -277,7 +277,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
int i,j;
|
int i,j;
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// bt stack activated, get started - set local name
|
// bt stack activated, get started - set local name
|
||||||
|
@ -131,7 +131,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
|
|
||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
|
@ -91,7 +91,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
|||||||
bd_addr_t addr;
|
bd_addr_t addr;
|
||||||
uint8_t adv_data[] = { 02, 01, 05, 03, 02, 0xf0, 0xff };
|
uint8_t adv_data[] = { 02, 01, 05, 03, 02, 0xf0, 0xff };
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// bt stack activated, get started - set local name
|
// bt stack activated, get started - set local name
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
|
@ -182,7 +182,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
|||||||
int connection_encrypted;
|
int connection_encrypted;
|
||||||
|
|
||||||
// handle connect / disconncet events first
|
// handle connect / disconncet events first
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case HCI_EVENT_LE_META:
|
case HCI_EVENT_LE_META:
|
||||||
switch (packet[2]) {
|
switch (packet[2]) {
|
||||||
case HCI_SUBEVENT_LE_CONNECTION_COMPLETE:
|
case HCI_SUBEVENT_LE_CONNECTION_COMPLETE:
|
||||||
@ -226,7 +226,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
|||||||
|
|
||||||
switch(tc_state){
|
switch(tc_state){
|
||||||
case TC_W4_SERVICE_RESULT:
|
case TC_W4_SERVICE_RESULT:
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
case GATT_EVENT_SERVICE_QUERY_RESULT:
|
||||||
gatt_event_service_query_result_get_service(packet, &ancs_service);
|
gatt_event_service_query_result_get_service(packet, &ancs_service);
|
||||||
ancs_service_found = 1;
|
ancs_service_found = 1;
|
||||||
@ -247,7 +247,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TC_W4_CHARACTERISTIC_RESULT:
|
case TC_W4_CHARACTERISTIC_RESULT:
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_CHARACTERISTIC_QUERY_RESULT:
|
case GATT_EVENT_CHARACTERISTIC_QUERY_RESULT:
|
||||||
gatt_event_characteristic_query_result_get_characteristic(packet, &characteristic);
|
gatt_event_characteristic_query_result_get_characteristic(packet, &characteristic);
|
||||||
if (memcmp(characteristic.uuid128, ancs_notification_source_uuid, 16) == 0){
|
if (memcmp(characteristic.uuid128, ancs_notification_source_uuid, 16) == 0){
|
||||||
@ -280,7 +280,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TC_W4_NOTIFICATION_SOURCE_SUBSCRIBED:
|
case TC_W4_NOTIFICATION_SOURCE_SUBSCRIBED:
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_QUERY_COMPLETE:
|
case GATT_EVENT_QUERY_COMPLETE:
|
||||||
log_info("ANCS Notification Source subscribed");
|
log_info("ANCS Notification Source subscribed");
|
||||||
tc_state = TC_W4_DATA_SOURCE_SUBSCRIBED;
|
tc_state = TC_W4_DATA_SOURCE_SUBSCRIBED;
|
||||||
@ -293,7 +293,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TC_W4_DATA_SOURCE_SUBSCRIBED:
|
case TC_W4_DATA_SOURCE_SUBSCRIBED:
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case GATT_EVENT_QUERY_COMPLETE:
|
case GATT_EVENT_QUERY_COMPLETE:
|
||||||
log_info("ANCS Data Source subscribed");
|
log_info("ANCS Data Source subscribed");
|
||||||
tc_state = TC_SUBSCRIBED;
|
tc_state = TC_SUBSCRIBED;
|
||||||
@ -304,7 +304,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TC_SUBSCRIBED:
|
case TC_SUBSCRIBED:
|
||||||
if (packet[0] != GATT_EVENT_NOTIFICATION && packet[0] != GATT_EVENT_INDICATION ) break;
|
if (hci_event_packet_get_type(packet) != GATT_EVENT_NOTIFICATION && hci_event_packet_get_type(packet) != GATT_EVENT_INDICATION ) break;
|
||||||
|
|
||||||
value_handle = little_endian_read_16(packet, 4);
|
value_handle = little_endian_read_16(packet, 4);
|
||||||
value_length = little_endian_read_16(packet, 6);
|
value_length = little_endian_read_16(packet, 6);
|
||||||
|
@ -48,12 +48,12 @@
|
|||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack_config.h"
|
||||||
|
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
|
#include "btstack_run_loop.h"
|
||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
|
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
|
|
||||||
#include "ble/sm.h"
|
#include "ble/sm.h"
|
||||||
@ -137,7 +137,7 @@ static void att_event_packet_handler (uint8_t packet_type, uint16_t channel, uin
|
|||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case L2CAP_EVENT_CAN_SEND_NOW:
|
case L2CAP_EVENT_CAN_SEND_NOW:
|
||||||
att_run();
|
att_run();
|
||||||
|
@ -39,25 +39,25 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "btstack_run_loop.h"
|
|
||||||
#include "hci_cmd.h"
|
|
||||||
#include "btstack_util.h"
|
|
||||||
#include "classic/sdp_util.h"
|
|
||||||
|
|
||||||
#include "btstack_config.h"
|
#include "btstack_config.h"
|
||||||
|
|
||||||
#include "ble/gatt_client.h"
|
#include "att_dispatch.h"
|
||||||
#include "ble/ad_parser.h"
|
#include "ble/ad_parser.h"
|
||||||
|
#include "ble/att_db.h"
|
||||||
|
#include "ble/gatt_client.h"
|
||||||
|
#include "ble/le_device_db.h"
|
||||||
|
#include "ble/sm.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
|
#include "btstack_run_loop.h"
|
||||||
|
#include "btstack_util.h"
|
||||||
|
#include "classic/sdp_util.h"
|
||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
|
#include "hci_cmd.h"
|
||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
#include "ble/att_db.h"
|
|
||||||
#include "att_dispatch.h"
|
|
||||||
#include "ble/sm.h"
|
|
||||||
#include "ble/le_device_db.h"
|
|
||||||
|
|
||||||
static btstack_linked_list_t gatt_client_connections;
|
static btstack_linked_list_t gatt_client_connections;
|
||||||
static btstack_linked_list_t gatt_client_value_listeners;
|
static btstack_linked_list_t gatt_client_value_listeners;
|
||||||
@ -998,7 +998,7 @@ static void gatt_client_report_error_if_pending(gatt_client_t *peripheral, uint8
|
|||||||
static void gatt_client_hci_event_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void gatt_client_hci_event_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||||
{
|
{
|
||||||
log_info("GATT Client: HCI_EVENT_DISCONNECTION_COMPLETE");
|
log_info("GATT Client: HCI_EVENT_DISCONNECTION_COMPLETE");
|
||||||
|
14
src/ble/sm.c
14
src/ble/sm.c
@ -39,15 +39,15 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "btstack_linked_list.h"
|
|
||||||
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "btstack_debug.h"
|
|
||||||
#include "hci.h"
|
|
||||||
#include "l2cap.h"
|
|
||||||
#include "ble/le_device_db.h"
|
#include "ble/le_device_db.h"
|
||||||
#include "ble/sm.h"
|
#include "ble/sm.h"
|
||||||
|
#include "btstack_debug.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
|
#include "btstack_linked_list.h"
|
||||||
|
#include "btstack_memory.h"
|
||||||
#include "gap.h"
|
#include "gap.h"
|
||||||
|
#include "hci.h"
|
||||||
|
#include "l2cap.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// SM internal types and globals
|
// SM internal types and globals
|
||||||
@ -1834,7 +1834,7 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
|
|||||||
switch (packet_type) {
|
switch (packet_type) {
|
||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// bt stack activated, get started
|
// bt stack activated, get started
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -46,16 +46,15 @@
|
|||||||
#include <string.h> // memcpy
|
#include <string.h> // memcpy
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "hci_cmd.h"
|
#include "bnep.h"
|
||||||
|
#include "btstack_debug.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
|
#include "btstack_memory.h"
|
||||||
#include "btstack_util.h"
|
#include "btstack_util.h"
|
||||||
#include "classic/sdp_util.h"
|
#include "classic/sdp_util.h"
|
||||||
|
|
||||||
#include "btstack_memory.h"
|
|
||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
|
#include "hci_cmd.h"
|
||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "btstack_debug.h"
|
|
||||||
#include "bnep.h"
|
|
||||||
|
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
|
|
||||||
#define BNEP_CONNECTION_TIMEOUT_MS 10000
|
#define BNEP_CONNECTION_TIMEOUT_MS 10000
|
||||||
@ -1157,7 +1156,7 @@ static int bnep_hci_event_handler(uint8_t *packet, uint16_t size)
|
|||||||
bnep_channel_t *channel = NULL;
|
bnep_channel_t *channel = NULL;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
/* Accept an incoming L2CAP connection on PSM_BNEP */
|
/* Accept an incoming L2CAP connection on PSM_BNEP */
|
||||||
case L2CAP_EVENT_INCOMING_CONNECTION:
|
case L2CAP_EVENT_INCOMING_CONNECTION:
|
||||||
|
@ -45,7 +45,9 @@
|
|||||||
#define __BNEP_H
|
#define __BNEP_H
|
||||||
|
|
||||||
#include "btstack_util.h"
|
#include "btstack_util.h"
|
||||||
|
#include "btstack_run_loop.h"
|
||||||
|
#include "gap.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
|
@ -430,7 +430,7 @@ static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uin
|
|||||||
|
|
||||||
if ( connection->state != HFP_W4_SDP_EVENT_QUERY_COMPLETE) return;
|
if ( connection->state != HFP_W4_SDP_EVENT_QUERY_COMPLETE) return;
|
||||||
|
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case SDP_EVENT_QUERY_RFCOMM_SERVICE:
|
case SDP_EVENT_QUERY_RFCOMM_SERVICE:
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
log_error("handle_query_rfcomm_event alloc connection for RFCOMM port %u failed", sdp_event_query_rfcomm_service_get_rfcomm_channel(packet));
|
log_error("handle_query_rfcomm_event alloc connection for RFCOMM port %u failed", sdp_event_query_rfcomm_service_get_rfcomm_channel(packet));
|
||||||
@ -458,9 +458,9 @@ void hfp_handle_hci_event(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
|||||||
uint16_t rfcomm_cid, handle;
|
uint16_t rfcomm_cid, handle;
|
||||||
hfp_connection_t * context = NULL;
|
hfp_connection_t * context = NULL;
|
||||||
|
|
||||||
// printf("AG packet_handler type %u, packet[0] %x, size %u\n", packet_type, packet[0], size);
|
// printf("AG packet_handler type %u, event type %x, size %u\n", packet_type, hci_event_packet_get_type(packet), size);
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case RFCOMM_EVENT_INCOMING_CONNECTION:
|
case RFCOMM_EVENT_INCOMING_CONNECTION:
|
||||||
// data: event (8), len(8), address(48), channel (8), rfcomm_cid (16)
|
// data: event (8), len(8), address(48), channel (8), rfcomm_cid (16)
|
||||||
@ -477,7 +477,7 @@ void hfp_handle_hci_event(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
|||||||
|
|
||||||
case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE:
|
case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE:
|
||||||
// data: event(8), len(8), status (8), address (48), handle(16), server channel(8), rfcomm_cid(16), max frame size(16)
|
// data: event(8), len(8), status (8), address (48), handle(16), server channel(8), rfcomm_cid(16), max frame size(16)
|
||||||
printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u, packet[0] %x, size %u\n", packet_type, packet[0], size);
|
printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u, size %u\n", packet_type, size);
|
||||||
|
|
||||||
reverse_bd_addr(&packet[3], event_addr);
|
reverse_bd_addr(&packet[3], event_addr);
|
||||||
context = get_hfp_connection_context_for_bd_addr(event_addr);
|
context = get_hfp_connection_context_for_bd_addr(event_addr);
|
||||||
|
@ -443,7 +443,6 @@ static void hsp_run(void){
|
|||||||
|
|
||||||
|
|
||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
// log_info("packet_handler type %u, packet[0] %x", packet_type, packet[0]);
|
|
||||||
if (packet_type == RFCOMM_DATA_PACKET){
|
if (packet_type == RFCOMM_DATA_PACKET){
|
||||||
while (size > 0 && (packet[0] == '\n' || packet[0] == '\r')){
|
while (size > 0 && (packet[0] == '\n' || packet[0] == '\r')){
|
||||||
size--;
|
size--;
|
||||||
@ -485,7 +484,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
bd_addr_t event_addr;
|
bd_addr_t event_addr;
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
uint8_t event = packet[0];
|
uint8_t event = hci_event_packet_get_type(packet);
|
||||||
bd_addr_t event_addr;
|
bd_addr_t event_addr;
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
|
|
||||||
@ -518,7 +518,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE:
|
case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE:
|
||||||
printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
|
printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u\n", packet_type);
|
||||||
// data: event(8), len(8), status (8), address (48), handle(16), server channel(8), rfcomm_cid(16), max frame size(16)
|
// data: event(8), len(8), status (8), address (48), handle(16), server channel(8), rfcomm_cid(16), max frame size(16)
|
||||||
if (packet[2]) {
|
if (packet[2]) {
|
||||||
printf("RFCOMM channel open failed, status %u\n", packet[2]);
|
printf("RFCOMM channel open failed, status %u\n", packet[2]);
|
||||||
@ -575,7 +575,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case SDP_EVENT_QUERY_RFCOMM_SERVICE:
|
case SDP_EVENT_QUERY_RFCOMM_SERVICE:
|
||||||
channel_nr = sdp_event_query_rfcomm_service_get_rfcomm_channel(packet);
|
channel_nr = sdp_event_query_rfcomm_service_get_rfcomm_channel(packet);
|
||||||
printf("** Service name: '%s', RFCOMM port %u\n", sdp_event_query_rfcomm_service_get_name(packet), channel_nr);
|
printf("** Service name: '%s', RFCOMM port %u\n", sdp_event_query_rfcomm_service_get_name(packet), channel_nr);
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
#include "btstack_util.h"
|
#include "btstack_util.h"
|
||||||
#include "classic/rfcomm.h"
|
#include "classic/rfcomm.h"
|
||||||
@ -841,7 +842,7 @@ static int rfcomm_multiplexer_hci_event_handler(uint8_t *packet, uint16_t size){
|
|||||||
rfcomm_multiplexer_t *multiplexer = NULL;
|
rfcomm_multiplexer_t *multiplexer = NULL;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
// accept incoming PSM_RFCOMM connection if no multiplexer exists yet
|
// accept incoming PSM_RFCOMM connection if no multiplexer exists yet
|
||||||
case L2CAP_EVENT_INCOMING_CONNECTION:
|
case L2CAP_EVENT_INCOMING_CONNECTION:
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include "hci_cmd.h"
|
#include "hci_cmd.h"
|
||||||
|
|
||||||
|
#include "btstack_event.h"
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
#include "classic/sdp_server.h"
|
#include "classic/sdp_server.h"
|
||||||
#include "classic/sdp_util.h"
|
#include "classic/sdp_util.h"
|
||||||
@ -459,10 +460,7 @@ void sdp_client_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
|
|||||||
|
|
||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
|
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
case L2CAP_EVENT_TIMEOUT_CHECK:
|
|
||||||
log_info("sdp client: L2CAP_EVENT_TIMEOUT_CHECK");
|
|
||||||
break;
|
|
||||||
case L2CAP_EVENT_CHANNEL_OPENED:
|
case L2CAP_EVENT_CHANNEL_OPENED:
|
||||||
if (sdp_client_state != W4_CONNECT) break;
|
if (sdp_client_state != W4_CONNECT) break;
|
||||||
// data: event (8), len(8), status (8), address(48), handle (16), psm (16), local_cid(16), remote_cid (16), local_mtu(16), remote_mtu(16)
|
// data: event (8), len(8), status (8), address(48), handle (16), psm (16), local_cid(16), remote_cid (16), local_mtu(16), remote_mtu(16)
|
||||||
|
@ -246,7 +246,7 @@ static void handleServiceNameData(uint32_t attribute_value_length, uint32_t data
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handle_sdp_parser_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void handle_sdp_parser_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
switch (packet[0]){
|
switch (hci_event_packet_get_type(packet)){
|
||||||
case SDP_EVENT_QUERY_SERVICE_RECORD_HANDLE:
|
case SDP_EVENT_QUERY_SERVICE_RECORD_HANDLE:
|
||||||
// handle service without a name
|
// handle service without a name
|
||||||
if (sdp_rfcomm_channel_nr){
|
if (sdp_rfcomm_channel_nr){
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
|
|
||||||
@ -491,7 +492,7 @@ static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
|
|||||||
|
|
||||||
case HCI_EVENT_PACKET:
|
case HCI_EVENT_PACKET:
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case L2CAP_EVENT_INCOMING_CONNECTION:
|
case L2CAP_EVENT_INCOMING_CONNECTION:
|
||||||
if (l2cap_cid) {
|
if (l2cap_cid) {
|
||||||
|
17
src/hci.c
17
src/hci.c
@ -63,6 +63,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
#include "btstack_linked_list.h"
|
#include "btstack_linked_list.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
#include "gap.h"
|
#include "gap.h"
|
||||||
@ -1106,7 +1107,7 @@ static void hci_init_done(void){
|
|||||||
static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
||||||
uint8_t command_completed = 0;
|
uint8_t command_completed = 0;
|
||||||
|
|
||||||
if (packet[0] == HCI_EVENT_COMMAND_COMPLETE){
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_COMPLETE){
|
||||||
uint16_t opcode = little_endian_read_16(packet,3);
|
uint16_t opcode = little_endian_read_16(packet,3);
|
||||||
if (opcode == hci_stack->last_cmd_opcode){
|
if (opcode == hci_stack->last_cmd_opcode){
|
||||||
command_completed = 1;
|
command_completed = 1;
|
||||||
@ -1116,7 +1117,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packet[0] == HCI_EVENT_COMMAND_STATUS){
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_STATUS){
|
||||||
uint8_t status = packet[2];
|
uint8_t status = packet[2];
|
||||||
uint16_t opcode = little_endian_read_16(packet,4);
|
uint16_t opcode = little_endian_read_16(packet,4);
|
||||||
if (opcode == hci_stack->last_cmd_opcode){
|
if (opcode == hci_stack->last_cmd_opcode){
|
||||||
@ -1132,13 +1133,13 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Vendor == CSR
|
// Vendor == CSR
|
||||||
if (hci_stack->substate == HCI_INIT_W4_CUSTOM_INIT && packet[0] == HCI_EVENT_VENDOR_SPECIFIC){
|
if (hci_stack->substate == HCI_INIT_W4_CUSTOM_INIT && hci_event_packet_get_type(packet) == HCI_EVENT_VENDOR_SPECIFIC){
|
||||||
// TODO: track actual command
|
// TODO: track actual command
|
||||||
command_completed = 1;
|
command_completed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vendor == Toshiba
|
// Vendor == Toshiba
|
||||||
if (hci_stack->substate == HCI_INIT_W4_SEND_BAUD_CHANGE && packet[0] == HCI_EVENT_VENDOR_SPECIFIC){
|
if (hci_stack->substate == HCI_INIT_W4_SEND_BAUD_CHANGE && hci_event_packet_get_type(packet) == HCI_EVENT_VENDOR_SPECIFIC){
|
||||||
// TODO: track actual command
|
// TODO: track actual command
|
||||||
command_completed = 1;
|
command_completed = 1;
|
||||||
}
|
}
|
||||||
@ -1156,7 +1157,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
|||||||
//
|
//
|
||||||
// Fix: Command Complete for HCI Reset in HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION trigger resend
|
// Fix: Command Complete for HCI Reset in HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION trigger resend
|
||||||
if (!command_completed
|
if (!command_completed
|
||||||
&& packet[0] == HCI_EVENT_COMMAND_COMPLETE
|
&& hci_event_packet_get_type(packet) == HCI_EVENT_COMMAND_COMPLETE
|
||||||
&& hci_stack->substate == HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION){
|
&& hci_stack->substate == HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION){
|
||||||
|
|
||||||
uint16_t opcode = little_endian_read_16(packet,3);
|
uint16_t opcode = little_endian_read_16(packet,3);
|
||||||
@ -1327,9 +1328,9 @@ static void event_handler(uint8_t *packet, int size){
|
|||||||
hci_connection_t * conn;
|
hci_connection_t * conn;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// log_info("HCI:EVENT:%02x", packet[0]);
|
// log_info("HCI:EVENT:%02x", hci_event_packet_get_type(packet));
|
||||||
|
|
||||||
switch (packet[0]) {
|
switch (hci_event_packet_get_type(packet)) {
|
||||||
|
|
||||||
case HCI_EVENT_COMMAND_COMPLETE:
|
case HCI_EVENT_COMMAND_COMPLETE:
|
||||||
// get num cmd packets
|
// get num cmd packets
|
||||||
@ -1791,7 +1792,7 @@ static void event_handler(uint8_t *packet, int size){
|
|||||||
hci_emit_event(packet, size, 0); // don't dump, already happened in packet handler
|
hci_emit_event(packet, size, 0); // don't dump, already happened in packet handler
|
||||||
|
|
||||||
// moved here to give upper stack a chance to close down everything with hci_connection_t intact
|
// moved here to give upper stack a chance to close down everything with hci_connection_t intact
|
||||||
if (packet[0] == HCI_EVENT_DISCONNECTION_COMPLETE){
|
if (hci_event_packet_get_type(packet) == HCI_EVENT_DISCONNECTION_COMPLETE){
|
||||||
if (!packet[2]){
|
if (!packet[2]){
|
||||||
handle = little_endian_read_16(packet, 3);
|
handle = little_endian_read_16(packet, 3);
|
||||||
hci_connection_t * aConn = hci_connection_for_handle(handle);
|
hci_connection_t * aConn = hci_connection_for_handle(handle);
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "btstack_debug.h"
|
#include "btstack_debug.h"
|
||||||
|
#include "btstack_event.h"
|
||||||
#include "btstack_memory.h"
|
#include "btstack_memory.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -919,7 +920,7 @@ static void l2cap_hci_event_handler(uint8_t packet_type, uint16_t cid, uint8_t *
|
|||||||
btstack_linked_list_iterator_t it;
|
btstack_linked_list_iterator_t it;
|
||||||
int hci_con_used;
|
int hci_con_used;
|
||||||
|
|
||||||
switch(packet[0]){
|
switch(hci_event_packet_get_type(packet)){
|
||||||
|
|
||||||
// handle connection complete events
|
// handle connection complete events
|
||||||
case HCI_EVENT_CONNECTION_COMPLETE:
|
case HCI_EVENT_CONNECTION_COMPLETE:
|
||||||
|
@ -77,6 +77,15 @@ extern "C" {
|
|||||||
|
|
||||||
/* API_START */
|
/* API_START */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get event type
|
||||||
|
* @param event
|
||||||
|
* @return type of event
|
||||||
|
*/
|
||||||
|
static inline uint8_t hci_event_packet_get_type(const uint8_t * event){
|
||||||
|
return event[0];
|
||||||
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
hfile_header_end = """
|
hfile_header_end = """
|
||||||
@ -92,7 +101,7 @@ hfile_header_end = """
|
|||||||
|
|
||||||
c_prototoype_simple_return = '''/**
|
c_prototoype_simple_return = '''/**
|
||||||
* @brief {description}
|
* @brief {description}
|
||||||
* @param Event packet
|
* @param event packet
|
||||||
* @return {result_name}
|
* @return {result_name}
|
||||||
* @note: btstack_type {format}
|
* @note: btstack_type {format}
|
||||||
*/
|
*/
|
||||||
@ -103,7 +112,7 @@ static inline {result_type} {fn_name}(const uint8_t * event){{
|
|||||||
|
|
||||||
c_prototoype_struct_return = '''/**
|
c_prototoype_struct_return = '''/**
|
||||||
* @brief {description}
|
* @brief {description}
|
||||||
* @param Event packet
|
* @param event packet
|
||||||
* @param Pointer to storage for {result_name}
|
* @param Pointer to storage for {result_name}
|
||||||
* @note: btstack_type {format}
|
* @note: btstack_type {format}
|
||||||
*/
|
*/
|
||||||
@ -114,7 +123,7 @@ static inline void {fn_name}(const uint8_t * event, {result_type} {result_name})
|
|||||||
|
|
||||||
c_prototoype_unsupported = '''/**
|
c_prototoype_unsupported = '''/**
|
||||||
* @brief {description}
|
* @brief {description}
|
||||||
* @param Event packet
|
* @param event packet
|
||||||
* @return {result_name}
|
* @return {result_name}
|
||||||
* @note: btstack_type {format}
|
* @note: btstack_type {format}
|
||||||
*/
|
*/
|
||||||
@ -123,6 +132,16 @@ c_prototoype_unsupported = '''/**
|
|||||||
// }}
|
// }}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
meta_event_template = '''/***
|
||||||
|
* @brief Get subevent code for {meta_event} event
|
||||||
|
* @param event packet
|
||||||
|
* @return subevent_code
|
||||||
|
*/
|
||||||
|
static inline uint8_t hci_event_{meta_event}_meta_get_subevent_code(const uint8_t * event){{
|
||||||
|
return event[2];
|
||||||
|
}}
|
||||||
|
'''
|
||||||
|
|
||||||
# global variables/defines
|
# global variables/defines
|
||||||
gen_path = '../src/btstack_event.h'
|
gen_path = '../src/btstack_event.h'
|
||||||
|
|
||||||
@ -205,10 +224,16 @@ def create_events(events):
|
|||||||
global copyright
|
global copyright
|
||||||
global hfile_header_begin
|
global hfile_header_begin
|
||||||
global hfile_header_end
|
global hfile_header_end
|
||||||
|
global meta_event_template
|
||||||
|
|
||||||
with open(gen_path, 'wt') as fout:
|
with open(gen_path, 'wt') as fout:
|
||||||
fout.write(copyright)
|
fout.write(copyright)
|
||||||
fout.write(hfile_header_begin)
|
fout.write(hfile_header_begin)
|
||||||
|
|
||||||
|
meta_events = ['HSP', 'HFP', 'ANCS'];
|
||||||
|
for meta_event in meta_events:
|
||||||
|
fout.write(meta_event_template.format(meta_event=meta_event.lower()))
|
||||||
|
|
||||||
for event_type, event_name, format, args in events:
|
for event_type, event_name, format, args in events:
|
||||||
parts = event_name.split("_")
|
parts = event_name.split("_")
|
||||||
event_group = parts[0]
|
event_group = parts[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user