use only combined opcode from ocf/ogf

This commit is contained in:
matthias.ringwald 2009-05-10 14:16:03 +00:00
parent 554588a5c7
commit 0a974e0c44
3 changed files with 11 additions and 8 deletions

View File

@ -11,13 +11,15 @@
#include <stdio.h>
#include "hci.h"
// calculate combined ogf/ocf value
#define OPCODE(ogf, ocf) (ocf | ogf << 10)
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 = {
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, ...){
buffer[0] = cmd->ocf;
buffer[1] = cmd->ocf >> 8 | cmd->ogf << 2;
buffer[0] = cmd->opcode & 0xff;
buffer[1] = cmd->opcode >> 8;
int pos = 3;
va_list argptr;

View File

@ -17,8 +17,7 @@ typedef enum {
} HCI_POWER_MODE;
typedef struct {
uint8_t ogf;
uint16_t ocf;
uint16_t opcode;
const char *format;
} hci_cmd_t;

View File

@ -19,9 +19,11 @@ static hci_transport_t * transport;
static hci_uart_config_t config;
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){
//
if (packet[3] == 3 && packet[4] == 12){
// printf("Event type: %x, opcode: %x, other %x\n", packet[0], packet[3] | packet[4] << 8);
if ( COMMAND_COMPLETE_EVENT(packet, hci_reset) ) {
// reset done, send inq
uint8_t len;
hci_create_cmd_packet( buffer, &len, &hci_inquiry, HCI_INQUIRY_LAP, 30, 0);