diff --git a/trunk/hci.c b/trunk/hci.c new file mode 100644 index 000000000..c2cd010c1 --- /dev/null +++ b/trunk/hci.c @@ -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){ +} diff --git a/trunk/hci.h b/trunk/hci.h new file mode 100644 index 000000000..f91df93b4 --- /dev/null +++ b/trunk/hci.h @@ -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); + diff --git a/trunk/hci_h4_transport.c b/trunk/hci_h4_transport.c new file mode 100644 index 000000000..0dde587ae --- /dev/null +++ b/trunk/hci_h4_transport.c @@ -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 +}; diff --git a/trunk/hci_h4_transport.h b/trunk/hci_h4_transport.h new file mode 100644 index 000000000..d968aa100 --- /dev/null +++ b/trunk/hci_h4_transport.h @@ -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; diff --git a/trunk/hci_transport.h b/trunk/hci_transport.h new file mode 100644 index 000000000..9eb03726a --- /dev/null +++ b/trunk/hci_transport.h @@ -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; diff --git a/trunk/project.xcodeproj/project.pbxproj b/trunk/project.xcodeproj/project.pbxproj index 867a9e2dc..69956002e 100644 --- a/trunk/project.xcodeproj/project.pbxproj +++ b/trunk/project.xcodeproj/project.pbxproj @@ -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 = ""; usesTabs = 0; }; + 9C46FBC70FA8F3B800ABEF05 /* hci_transport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hci_transport.h; sourceTree = ""; }; + 9C46FBCB0FA8FEA000ABEF05 /* hci.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hci.h; sourceTree = ""; }; + 9C46FBCC0FA8FEA000ABEF05 /* hci.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hci.c; sourceTree = ""; }; + 9C46FBCE0FA8FF3700ABEF05 /* hci_h4_transport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hci_h4_transport.h; sourceTree = ""; }; + 9C46FBCF0FA8FF3700ABEF05 /* hci_h4_transport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hci_h4_transport.c; sourceTree = ""; }; /* 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 = ""; @@ -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; }; diff --git a/trunk/src/main.c b/trunk/src/main.c index 8f50f3008..5ba160409 100644 --- a/trunk/src/main.c +++ b/trunk/src/main.c @@ -1,7 +1,36 @@ +/* + * main.c + * + * Simple tests + * + * Created by Matthias Ringwald on 4/29/09. + */ + #include +#include + +#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; }