mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-24 15:02:43 +00:00
more fixes
This commit is contained in:
parent
145be03f61
commit
8cbb57e63c
@ -67,29 +67,16 @@ static int iphone_on (void *config){
|
|||||||
while (1){
|
while (1){
|
||||||
int chars = read(input, &buffer[pos], 1);
|
int chars = read(input, &buffer[pos], 1);
|
||||||
|
|
||||||
int ready;
|
|
||||||
do {
|
|
||||||
fd_set fds;
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
FD_SET(output,&fds);
|
|
||||||
ready=select(output+1,&fds,NULL,NULL,&noTime);
|
|
||||||
if (ready>0)
|
|
||||||
{
|
|
||||||
if (FD_ISSET(output,&fds)) {
|
|
||||||
char singlechar = fgetc(outputFile);
|
|
||||||
printf("%c", singlechar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (ready);
|
|
||||||
|
|
||||||
// end-of-line
|
// end-of-line
|
||||||
if (chars == 0 || buffer[pos]=='\n' || buffer[pos]== '\r'){
|
if (chars == 0 || buffer[pos]=='\n' || buffer[pos]== '\r'){
|
||||||
if (store) {
|
if (store) {
|
||||||
// stored characters
|
// stored characters
|
||||||
write(output, buffer, pos+chars);
|
write(output, buffer, pos+chars);
|
||||||
|
write(fileno(stdout), buffer, pos+chars);
|
||||||
}
|
}
|
||||||
if (mirror) {
|
if (mirror) {
|
||||||
write(output, "\n", 1);
|
write(output, "\n", 1);
|
||||||
|
write(fileno(stdout), "\n", 1);
|
||||||
}
|
}
|
||||||
pos = 0;
|
pos = 0;
|
||||||
mirror = 0;
|
mirror = 0;
|
||||||
@ -104,6 +91,7 @@ static int iphone_on (void *config){
|
|||||||
// mirror
|
// mirror
|
||||||
if (mirror){
|
if (mirror){
|
||||||
write(output, &buffer[pos], 1);
|
write(output, &buffer[pos], 1);
|
||||||
|
write(fileno(stdout), &buffer[pos], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store
|
// store
|
||||||
@ -117,24 +105,49 @@ static int iphone_on (void *config){
|
|||||||
store = 0;
|
store = 0;
|
||||||
if (sscanf(buffer, "csr -p 0x%x=0x%x", &pskey, &value) == 2){
|
if (sscanf(buffer, "csr -p 0x%x=0x%x", &pskey, &value) == 2){
|
||||||
if (pskey == 0x01f9) { // UART MODE
|
if (pskey == 0x01f9) { // UART MODE
|
||||||
write(output, "Skipping: ", 10);
|
// write(output, buffer, pos);
|
||||||
write(output, buffer, pos);
|
write(fileno(stdout), "Skipping: ", 10);
|
||||||
mirror = 1;
|
write(fileno(stdout), buffer, pos);
|
||||||
|
mirror = 0;
|
||||||
} else if (pskey == 0x01be) { // UART Baud
|
} else if (pskey == 0x01be) { // UART Baud
|
||||||
write(output, "Skipping: ", 10);
|
// write(output, buffer, pos);
|
||||||
write(output, buffer, pos);
|
write(fileno(stdout), "Skipping: ", 10);
|
||||||
mirror = 1;
|
write(fileno(stdout), buffer, pos);
|
||||||
|
mirror = 0;
|
||||||
} else {
|
} else {
|
||||||
// dump buffer and start forwarding
|
// dump buffer and start forwarding
|
||||||
write(output, buffer, pos);
|
write(output, buffer, pos);
|
||||||
|
write(fileno(stdout), buffer, pos);
|
||||||
mirror = 1;
|
mirror = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
write(output, buffer, pos);
|
write(output, buffer, pos);
|
||||||
|
write(fileno(stdout), buffer, pos);
|
||||||
mirror = 1;
|
mirror = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// close ports
|
||||||
|
close(input);
|
||||||
|
|
||||||
|
// log output
|
||||||
|
int ready;
|
||||||
|
do {
|
||||||
|
fd_set fds;
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
FD_SET(output,&fds);
|
||||||
|
ready=select(output+1,&fds,NULL,NULL,&noTime);
|
||||||
|
if (ready>0)
|
||||||
|
{
|
||||||
|
if (FD_ISSET(output,&fds)) {
|
||||||
|
char singlechar = fgetc(outputFile);
|
||||||
|
printf("%c", singlechar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (ready);
|
||||||
|
|
||||||
|
fflush(outputFile);
|
||||||
|
pclose(outputFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +184,9 @@ void hci_init(hci_transport_t *transport, void *config, bt_control_t *control){
|
|||||||
transport->register_event_packet_handler( event_handler);
|
transport->register_event_packet_handler( event_handler);
|
||||||
transport->register_acl_packet_handler( acl_handler);
|
transport->register_acl_packet_handler( acl_handler);
|
||||||
|
|
||||||
|
// turn on
|
||||||
|
hci_power_control(HCI_POWER_ON);
|
||||||
|
|
||||||
// open low-level device
|
// open low-level device
|
||||||
transport->open(config);
|
transport->open(config);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ int main (int argc, const char * argv[]) {
|
|||||||
|
|
||||||
bt_control_t * control = NULL;
|
bt_control_t * control = NULL;
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
//
|
//
|
||||||
if (argc <= 1){
|
if (argc <= 1){
|
||||||
printf("HCI Daemon tester. Specify device name for Ericsson ROK 101 007\n");
|
printf("HCI Daemon tester. Specify device name for Ericsson ROK 101 007\n");
|
||||||
@ -114,7 +114,7 @@ int main (int argc, const char * argv[]) {
|
|||||||
config.flowcontrol = 1;
|
config.flowcontrol = 1;
|
||||||
#else
|
#else
|
||||||
// iPhone
|
// iPhone
|
||||||
config.device_name = "/dev/bluetooth";
|
config.device_name = "/dev/tty.bluetooth";
|
||||||
config.baudrate = 115200;
|
config.baudrate = 115200;
|
||||||
config.flowcontrol = 1;
|
config.flowcontrol = 1;
|
||||||
control = &bt_control_iphone;
|
control = &bt_control_iphone;
|
||||||
@ -125,7 +125,6 @@ int main (int argc, const char * argv[]) {
|
|||||||
|
|
||||||
// init HCI
|
// init HCI
|
||||||
hci_init(transport, &config, control);
|
hci_init(transport, &config, control);
|
||||||
hci_power_control(HCI_POWER_ON);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// register callbacks
|
// register callbacks
|
||||||
|
Loading…
x
Reference in New Issue
Block a user