mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 12:40:42 +00:00
prototyping
This commit is contained in:
parent
6d1cc1cacd
commit
76a09ef37a
11
trunk/hci.c
Normal file
11
trunk/hci.c
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* hci.c
|
||||
*
|
||||
* Created by Matthias Ringwald on 4/29/09.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hci.h"
|
||||
|
||||
void hci_run(hci_transport_t *transport, void *config){
|
||||
}
|
14
trunk/hci.h
Normal file
14
trunk/hci.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* hci.h
|
||||
*
|
||||
* Created by Matthias Ringwald on 4/29/09.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hci_transport.h"
|
||||
|
||||
// run the hci daemon loop
|
||||
void hci_run(hci_transport_t *transport, void *config);
|
||||
|
62
trunk/hci_h4_transport.c
Normal file
62
trunk/hci_h4_transport.c
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* hci_h4_transport.c
|
||||
* project
|
||||
*
|
||||
* Created by Matthias Ringwald on 4/29/09.
|
||||
* Copyright 2009 Dybuster AG. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hci_h4_transport.h"
|
||||
|
||||
// prototypes
|
||||
static int open(void *transport_config){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int close(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int send_cmd_packet(void *packet, int size){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int send_acl_packet(void *packet, int size){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void register_event_packet_handler(void (*handler)(void *packet, int size)){
|
||||
}
|
||||
static void register_acl_packet_handler (void (*handler)(void *packet, int size)){
|
||||
}
|
||||
|
||||
static int get_fd() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int handle_data() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * get_transport_name(){
|
||||
return "H4";
|
||||
}
|
||||
|
||||
// private data
|
||||
|
||||
typedef struct {
|
||||
} hci_h4_transport_private_t;
|
||||
|
||||
// single instance
|
||||
hci_transport_t hci_h4_transport = {
|
||||
open,
|
||||
close,
|
||||
send_cmd_packet,
|
||||
send_acl_packet,
|
||||
register_acl_packet_handler,
|
||||
register_event_packet_handler,
|
||||
get_fd,
|
||||
handle_data,
|
||||
get_transport_name
|
||||
};
|
11
trunk/hci_h4_transport.h
Normal file
11
trunk/hci_h4_transport.h
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* hci_h4_transport.h
|
||||
*
|
||||
* Created by Matthias Ringwald on 4/29/09.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "hci_transport.h"
|
||||
|
||||
extern hci_transport_t hci_h4_transport;
|
31
trunk/hci_transport.h
Normal file
31
trunk/hci_transport.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* hci_transport.h
|
||||
*
|
||||
* HCI Transport API -- allows hcid to use different transport protcols
|
||||
*
|
||||
* Created by Matthias Ringwald on 4/29/09.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
int (*open)(void *transport_config);
|
||||
int (*close)();
|
||||
int (*send_cmd_packet)(void *packet, int size);
|
||||
int (*send_acl_packet)(void *packet, int size);
|
||||
void (*register_event_packet_handler)(void (*handler)(void *packet, int size));
|
||||
void (*register_acl_packet_handler) (void (*handler)(void *packet, int size));
|
||||
int (*get_fd)(); // <-- only used for select(..) call
|
||||
int (*handle_data)(); // -- to be called when select( .. ) returns for the fd
|
||||
const char * (*get_transport_name)();
|
||||
} hci_transport_t;
|
||||
|
||||
typedef struct {
|
||||
const char *device_name;
|
||||
int baudrate;
|
||||
int flowcontrol; //
|
||||
} hci_uart_config_t;
|
||||
|
||||
typedef struct {
|
||||
// unique usb device identifier
|
||||
} hci_libusb_config_t;
|
@ -8,6 +8,8 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
9C46FBAF0FA8F31800ABEF05 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 9C46FBAE0FA8F31800ABEF05 /* main.c */; };
|
||||
9C46FBCD0FA8FEA000ABEF05 /* hci.c in Sources */ = {isa = PBXBuildFile; fileRef = 9C46FBCC0FA8FEA000ABEF05 /* hci.c */; };
|
||||
9C46FBD00FA8FF3700ABEF05 /* hci_h4_transport.c in Sources */ = {isa = PBXBuildFile; fileRef = 9C46FBCF0FA8FF3700ABEF05 /* hci_h4_transport.c */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
@ -25,6 +27,11 @@
|
||||
/* Begin PBXFileReference section */
|
||||
8DD76FB20486AB0100D96B5E /* project */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = project; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9C46FBAE0FA8F31800ABEF05 /* main.c */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.c; name = main.c; path = src/main.c; sourceTree = "<group>"; usesTabs = 0; };
|
||||
9C46FBC70FA8F3B800ABEF05 /* hci_transport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hci_transport.h; sourceTree = "<group>"; };
|
||||
9C46FBCB0FA8FEA000ABEF05 /* hci.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hci.h; sourceTree = "<group>"; };
|
||||
9C46FBCC0FA8FEA000ABEF05 /* hci.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hci.c; sourceTree = "<group>"; };
|
||||
9C46FBCE0FA8FF3700ABEF05 /* hci_h4_transport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hci_h4_transport.h; sourceTree = "<group>"; };
|
||||
9C46FBCF0FA8FF3700ABEF05 /* hci_h4_transport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hci_h4_transport.c; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -52,6 +59,11 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9C46FBAE0FA8F31800ABEF05 /* main.c */,
|
||||
9C46FBCB0FA8FEA000ABEF05 /* hci.h */,
|
||||
9C46FBCC0FA8FEA000ABEF05 /* hci.c */,
|
||||
9C46FBCE0FA8FF3700ABEF05 /* hci_h4_transport.h */,
|
||||
9C46FBCF0FA8FF3700ABEF05 /* hci_h4_transport.c */,
|
||||
9C46FBC70FA8F3B800ABEF05 /* hci_transport.h */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
@ -116,6 +128,8 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9C46FBAF0FA8F31800ABEF05 /* main.c in Sources */,
|
||||
9C46FBCD0FA8FEA000ABEF05 /* hci.c in Sources */,
|
||||
9C46FBD00FA8FF3700ABEF05 /* hci_h4_transport.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -1,7 +1,36 @@
|
||||
/*
|
||||
* main.c
|
||||
*
|
||||
* Simple tests
|
||||
*
|
||||
* Created by Matthias Ringwald on 4/29/09.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hci.h"
|
||||
#include "hci_h4_transport.h"
|
||||
|
||||
int main (int argc, const char * argv[]) {
|
||||
// insert code here...
|
||||
printf("Hello, World!\n");
|
||||
|
||||
//
|
||||
if (argc <= 1){
|
||||
printf("HCI Daemon tester. Specify device name for Ericsson ROK 101 007\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// H4 UART
|
||||
hci_transport_t * 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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user