towards a basic test app

This commit is contained in:
matthias.ringwald 2009-05-03 21:28:40 +00:00
parent 3363fde1ec
commit 475c8125ef
4 changed files with 89 additions and 10 deletions

View File

@ -5,7 +5,40 @@
*
*/
#include <unistd.h>
#include "hci.h"
void hci_run(hci_transport_t *transport, void *config){
static hci_transport_t *hci_transport;
void hci_init(hci_transport_t *transport, void *config){
// reference to use transport layer implementation
hci_transport = transport;
// open unix socket
// wait for connections
// enter loop
// handle events
}
int hci_power_control(HCI_POWER_MODE power_mode){
return 0;
}
int hci_send_cmd(char *buffer, int size){
return hci_transport->send_cmd_packet(buffer, size);
}
void hci_run(){
while (1) {
// construct file descriptor set to wait for
// select
// for each ready file in FD - call handle_data
sleep(1);
}
}

View File

@ -9,6 +9,17 @@
#include "hci_transport.h"
// run the hci daemon loop
void hci_run(hci_transport_t *transport, void *config);
typedef enum {
HCI_POWER_OFF = 0,
HCI_POWER_ON
} HCI_POWER_MODE;
// set up HCI
void hci_init(hci_transport_t *transport, void *config);
// power control
int hci_power_control(HCI_POWER_MODE mode);
// run the hci daemon loop
void hci_run();

View File

@ -5,7 +5,7 @@
*
*/
#include "hci_h4_transport.h"
#include "hci_transport_h4.h"
// prototypes
static int open(void *transport_config){
@ -26,6 +26,7 @@ static int send_acl_packet(void *packet, int size){
static void register_event_packet_handler(void (*handler)(void *packet, int size)){
}
static void register_acl_packet_handler (void (*handler)(void *packet, int size)){
}
@ -43,7 +44,10 @@ static const char * get_transport_name(){
// private data
typedef struct {
typedef struct {
hci_uart_config_t *config;
void (*event_packet_handle)(void *packet, int size);
void (*acl_packet_handle)(void *packet, int size);
} hci_h4_transport_private_t;
// single instance

View File

@ -8,9 +8,25 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include "hci.h"
#include "hci_h4_transport.h"
#include "hci_transport_h4.h"
static hci_transport_t * transport;
static hci_uart_config_t config;
#if 0
static void *hci_daemon_thread(void *arg){
printf("HCI Daemon started\n");
hci_run(transport, &config);
return NULL;
}
#endif
int main (int argc, const char * argv[]) {
@ -21,16 +37,31 @@ int main (int argc, const char * argv[]) {
}
// H4 UART
hci_transport_t * transport = &hci_h4_transport;
transport = &hci_h4_transport;
// Ancient Ericsson ROK 101 007 (ca. 2001)
hci_uart_config_t config;
config.device_name = argv[1];
config.baudrate = 57600;
config.flowcontrol = 1;
// Go
hci_run(transport, &config);
#if 0
// create and start HCI daemon thread
pthread_t new_thread;
pthread_create(&new_thread, NULL, hci_daemon_thread, NULL);
// open UNIX domain socket
while(1){
sleep(1);
printf(".\n");
}
#endif
hci_init(transport, &config);
hci_power_control(HCI_POWER_ON);
//
// register callback
//
hci_run();
return 0;
}