mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-22 06:41:17 +00:00
use only combined opcode from ocf/ogf
This commit is contained in:
parent
554588a5c7
commit
0a974e0c44
10
src/hci.c
10
src/hci.c
@ -11,13 +11,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
|
|
||||||
|
// calculate combined ogf/ocf value
|
||||||
|
#define OPCODE(ogf, ocf) (ocf | ogf << 10)
|
||||||
|
|
||||||
hci_cmd_t hci_inquiry = {
|
hci_cmd_t hci_inquiry = {
|
||||||
0x01, 0x01, "311" // LAP, Inquiry length, Num_responses
|
OPCODE(0x01, 0x01), "311" // LAP, Inquiry length, Num_responses
|
||||||
};
|
};
|
||||||
|
|
||||||
hci_cmd_t hci_reset = {
|
hci_cmd_t hci_reset = {
|
||||||
0x03, 0x03, ""
|
OPCODE(0x03, 0x03), ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -73,8 +75,8 @@ void hci_run(){
|
|||||||
|
|
||||||
|
|
||||||
void hci_create_cmd_packet(uint8_t *buffer, uint8_t *cmd_len, hci_cmd_t *cmd, ...){
|
void hci_create_cmd_packet(uint8_t *buffer, uint8_t *cmd_len, hci_cmd_t *cmd, ...){
|
||||||
buffer[0] = cmd->ocf;
|
buffer[0] = cmd->opcode & 0xff;
|
||||||
buffer[1] = cmd->ocf >> 8 | cmd->ogf << 2;
|
buffer[1] = cmd->opcode >> 8;
|
||||||
int pos = 3;
|
int pos = 3;
|
||||||
|
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
@ -17,8 +17,7 @@ typedef enum {
|
|||||||
} HCI_POWER_MODE;
|
} HCI_POWER_MODE;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t ogf;
|
uint16_t opcode;
|
||||||
uint16_t ocf;
|
|
||||||
const char *format;
|
const char *format;
|
||||||
} hci_cmd_t;
|
} hci_cmd_t;
|
||||||
|
|
||||||
|
@ -19,9 +19,11 @@ static hci_transport_t * transport;
|
|||||||
static hci_uart_config_t config;
|
static hci_uart_config_t config;
|
||||||
static uint8_t buffer [200];
|
static uint8_t buffer [200];
|
||||||
|
|
||||||
|
#define COMMAND_COMPLETE_EVENT(event,cmd) ( event[0] == 0x0e && (event[3] | (event[4] << 8)) == cmd.opcode)
|
||||||
|
|
||||||
void event_handler(uint8_t *packet, int size){
|
void event_handler(uint8_t *packet, int size){
|
||||||
//
|
// printf("Event type: %x, opcode: %x, other %x\n", packet[0], packet[3] | packet[4] << 8);
|
||||||
if (packet[3] == 3 && packet[4] == 12){
|
if ( COMMAND_COMPLETE_EVENT(packet, hci_reset) ) {
|
||||||
// reset done, send inq
|
// reset done, send inq
|
||||||
uint8_t len;
|
uint8_t len;
|
||||||
hci_create_cmd_packet( buffer, &len, &hci_inquiry, HCI_INQUIRY_LAP, 30, 0);
|
hci_create_cmd_packet( buffer, &len, &hci_inquiry, HCI_INQUIRY_LAP, 30, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user