mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
fix bugs introduced yesterday
This commit is contained in:
parent
74aad56003
commit
b2ae9e32ee
@ -5,5 +5,5 @@ iphone_ip=@IPHONE_IP@
|
|||||||
install-iphone: src/BTdaemon
|
install-iphone: src/BTdaemon
|
||||||
cp $< $<-signed
|
cp $< $<-signed
|
||||||
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate ; ldid -S $<-signed
|
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate ; ldid -S $<-signed
|
||||||
scp $<-signed mobile@$(iphone_ip):/var/mobile/BTdaemon
|
scp $<-signed root@$(iphone_ip):/var/root/BTdaemon
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
9CC152C61009052100223347 /* config.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
|
9CC152C61009052100223347 /* config.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
|
||||||
9CC813A00FFC0774002816F9 /* btstack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = btstack.h; path = src/btstack.h; sourceTree = "<group>"; };
|
9CC813A00FFC0774002816F9 /* btstack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = btstack.h; path = src/btstack.h; sourceTree = "<group>"; };
|
||||||
9CC813A10FFC0774002816F9 /* btstack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = btstack.c; path = src/btstack.c; sourceTree = "<group>"; };
|
9CC813A10FFC0774002816F9 /* btstack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = btstack.c; path = src/btstack.c; sourceTree = "<group>"; };
|
||||||
9CC813A30FFC0A51002816F9 /* daemon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = daemon.h; path = src/daemon.h; sourceTree = "<group>"; };
|
|
||||||
9CC813A40FFC0A51002816F9 /* daemon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = daemon.c; path = src/daemon.c; sourceTree = "<group>"; };
|
9CC813A40FFC0A51002816F9 /* daemon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = daemon.c; path = src/daemon.c; sourceTree = "<group>"; };
|
||||||
9CEB22DC1005345400FA2B98 /* hci_transport_usb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hci_transport_usb.h; path = src/hci_transport_usb.h; sourceTree = "<group>"; };
|
9CEB22DC1005345400FA2B98 /* hci_transport_usb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hci_transport_usb.h; path = src/hci_transport_usb.h; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
@ -94,7 +93,6 @@
|
|||||||
9C7ECB830FCC85650085DAC5 /* bt_control_iphone.h */,
|
9C7ECB830FCC85650085DAC5 /* bt_control_iphone.h */,
|
||||||
9CC813A00FFC0774002816F9 /* btstack.h */,
|
9CC813A00FFC0774002816F9 /* btstack.h */,
|
||||||
9CC813A10FFC0774002816F9 /* btstack.c */,
|
9CC813A10FFC0774002816F9 /* btstack.c */,
|
||||||
9CC813A30FFC0A51002816F9 /* daemon.h */,
|
|
||||||
9CC813A40FFC0A51002816F9 /* daemon.c */,
|
9CC813A40FFC0A51002816F9 /* daemon.c */,
|
||||||
9C46FC350FA906F700ABEF05 /* hci.h */,
|
9C46FC350FA906F700ABEF05 /* hci.h */,
|
||||||
9C46FC340FA906F700ABEF05 /* hci.c */,
|
9C46FC340FA906F700ABEF05 /* hci.c */,
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
* Created by Matthias Ringwald on 5/19/09.
|
* Created by Matthias Ringwald on 5/19/09.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "../config.h"
|
||||||
|
|
||||||
#include "bt_control_iphone.h"
|
#include "bt_control_iphone.h"
|
||||||
#include "hci_transport.h"
|
#include "hci_transport.h"
|
||||||
#include "hci.h"
|
#include "hci.h"
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "daemon.h"
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -30,7 +28,6 @@
|
|||||||
|
|
||||||
#include "run_loop.h"
|
#include "run_loop.h"
|
||||||
#include "socket_server.h"
|
#include "socket_server.h"
|
||||||
#include "daemon.h"
|
|
||||||
|
|
||||||
#ifdef USE_BLUETOOL
|
#ifdef USE_BLUETOOL
|
||||||
#include "bt_control_iphone.h"
|
#include "bt_control_iphone.h"
|
||||||
|
@ -251,5 +251,5 @@ hci_transport_t * hci_transport_h4_instance() {
|
|||||||
hci_transport_h4->transport.register_acl_packet_handler = h4_register_acl_packet_handler;
|
hci_transport_h4->transport.register_acl_packet_handler = h4_register_acl_packet_handler;
|
||||||
hci_transport_h4->transport.get_transport_name = h4_get_transport_name;
|
hci_transport_h4->transport.get_transport_name = h4_get_transport_name;
|
||||||
}
|
}
|
||||||
return hci_transport_h4;
|
return (hci_transport_t *) hci_transport_h4;
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,39 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
#include "hci.h"
|
||||||
|
|
||||||
#define MAX_PENDING_CONNECTIONS 10
|
#define MAX_PENDING_CONNECTIONS 10
|
||||||
#define DATA_BUF_SIZE 80
|
#define DATA_BUF_SIZE 80
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct packet_header {
|
||||||
|
uint16_t length;
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t data[0];
|
||||||
|
} packet_header_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SOCKET_W4_HEADER,
|
||||||
|
SOCKET_W4_DATA,
|
||||||
|
} SOCKET_STATE;
|
||||||
|
|
||||||
|
typedef struct connection {
|
||||||
|
data_source_t ds;
|
||||||
|
struct connection * next;
|
||||||
|
SOCKET_STATE state;
|
||||||
|
uint16_t bytes_read;
|
||||||
|
uint16_t bytes_to_read;
|
||||||
|
char buffer[3+3+255]; // max HCI CMD + packet_header
|
||||||
|
} connection_t;
|
||||||
|
|
||||||
|
connection_t *connections = NULL;
|
||||||
|
|
||||||
static char test_buffer[DATA_BUF_SIZE];
|
static char test_buffer[DATA_BUF_SIZE];
|
||||||
|
|
||||||
static int socket_server_echo_process(struct data_source *ds, int ready);
|
static int socket_server_echo_process(struct data_source *ds, int ready);
|
||||||
@ -61,28 +87,67 @@ static int socket_server_echo_process(struct data_source *ds, int ready) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static int socket_server_connection_process(struct data_source *ds, int ready) {
|
||||||
|
connection_t *conn = (connection_t *) ds;
|
||||||
|
int bytes_read = read(ds->fd, &conn->buffer[conn->bytes_read],
|
||||||
|
sizeof(packet_header_t) - conn->bytes_read);
|
||||||
|
if (bytes_read < 0){
|
||||||
|
//
|
||||||
|
}
|
||||||
|
conn->bytes_read += bytes_read;
|
||||||
|
conn->bytes_to_read -= bytes_read;
|
||||||
|
if (conn->bytes_to_read > 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
switch (conn->state){
|
||||||
|
case SOCKET_W4_HEADER:
|
||||||
|
conn->state = SOCKET_W4_DATA;
|
||||||
|
conn->bytes_to_read = READ_BT_16( conn->buffer, 0);
|
||||||
|
break;
|
||||||
|
case SOCKET_W4_DATA:
|
||||||
|
// process packet !!!
|
||||||
|
|
||||||
|
|
||||||
|
// wait for next packet
|
||||||
|
conn->state = SOCKET_W4_HEADER;
|
||||||
|
conn->bytes_read = 0;
|
||||||
|
conn->bytes_to_read = sizeof(packet_header_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int socket_server_accept(struct data_source *socket_ds, int ready) {
|
static int socket_server_accept(struct data_source *socket_ds, int ready) {
|
||||||
|
|
||||||
// create data_source_t
|
// create data_source_t
|
||||||
data_source_t *ds = malloc( sizeof(data_source_t));
|
connection_t * conn = malloc( sizeof(connection_t));
|
||||||
if (ds == NULL) return 0;
|
if (conn == NULL) return 0;
|
||||||
ds->fd = 0;
|
conn->ds.fd = 0;
|
||||||
ds->process = socket_server_process;
|
conn->ds.process = socket_server_process;
|
||||||
|
|
||||||
/* We have a new connection coming in! We'll
|
// init state machine
|
||||||
try to find a spot for it in connectlist. */
|
conn->state = SOCKET_W4_HEADER;
|
||||||
ds->fd = accept(socket_ds->fd, NULL, NULL);
|
conn->bytes_read = 0;
|
||||||
if (ds->fd < 0) {
|
conn->bytes_to_read = 2;
|
||||||
|
|
||||||
|
/* New connection coming in! */
|
||||||
|
conn->ds.fd = accept(socket_ds->fd, NULL, NULL);
|
||||||
|
if (conn->ds.fd < 0) {
|
||||||
perror("accept");
|
perror("accept");
|
||||||
free(ds);
|
free(conn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// non-blocking ?
|
// non-blocking ?
|
||||||
// socket_server_set_non_blocking(ds->fd);
|
// socket_server_set_non_blocking(ds->fd);
|
||||||
|
|
||||||
|
// store reference to this connection
|
||||||
|
conn->next = NULL;
|
||||||
|
connections = conn;
|
||||||
|
|
||||||
// add this socket to the run_loop
|
// add this socket to the run_loop
|
||||||
run_loop_add( ds );
|
run_loop_add( &conn->ds );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user