mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-10 15:44:32 +00:00
more fixes
This commit is contained in:
parent
145be03f61
commit
8cbb57e63c
@ -67,6 +67,70 @@ static int iphone_on (void *config){
|
|||||||
while (1){
|
while (1){
|
||||||
int chars = read(input, &buffer[pos], 1);
|
int chars = read(input, &buffer[pos], 1);
|
||||||
|
|
||||||
|
// end-of-line
|
||||||
|
if (chars == 0 || buffer[pos]=='\n' || buffer[pos]== '\r'){
|
||||||
|
if (store) {
|
||||||
|
// stored characters
|
||||||
|
write(output, buffer, pos+chars);
|
||||||
|
write(fileno(stdout), buffer, pos+chars);
|
||||||
|
}
|
||||||
|
if (mirror) {
|
||||||
|
write(output, "\n", 1);
|
||||||
|
write(fileno(stdout), "\n", 1);
|
||||||
|
}
|
||||||
|
pos = 0;
|
||||||
|
mirror = 0;
|
||||||
|
store = 1;
|
||||||
|
if (chars) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mirror
|
||||||
|
if (mirror){
|
||||||
|
write(output, &buffer[pos], 1);
|
||||||
|
write(fileno(stdout), &buffer[pos], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// store
|
||||||
|
if (store) {
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for "csr -p 0x002a=0x0011" (20)
|
||||||
|
if (store == 1 && pos == 20) {
|
||||||
|
int pskey, value;
|
||||||
|
store = 0;
|
||||||
|
if (sscanf(buffer, "csr -p 0x%x=0x%x", &pskey, &value) == 2){
|
||||||
|
if (pskey == 0x01f9) { // UART MODE
|
||||||
|
// write(output, buffer, pos);
|
||||||
|
write(fileno(stdout), "Skipping: ", 10);
|
||||||
|
write(fileno(stdout), buffer, pos);
|
||||||
|
mirror = 0;
|
||||||
|
} else if (pskey == 0x01be) { // UART Baud
|
||||||
|
// write(output, buffer, pos);
|
||||||
|
write(fileno(stdout), "Skipping: ", 10);
|
||||||
|
write(fileno(stdout), buffer, pos);
|
||||||
|
mirror = 0;
|
||||||
|
} else {
|
||||||
|
// dump buffer and start forwarding
|
||||||
|
write(output, buffer, pos);
|
||||||
|
write(fileno(stdout), buffer, pos);
|
||||||
|
mirror = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
write(output, buffer, pos);
|
||||||
|
write(fileno(stdout), buffer, pos);
|
||||||
|
mirror = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// close ports
|
||||||
|
close(input);
|
||||||
|
|
||||||
|
// log output
|
||||||
int ready;
|
int ready;
|
||||||
do {
|
do {
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
@ -82,59 +146,8 @@ static int iphone_on (void *config){
|
|||||||
}
|
}
|
||||||
} while (ready);
|
} while (ready);
|
||||||
|
|
||||||
// end-of-line
|
fflush(outputFile);
|
||||||
if (chars == 0 || buffer[pos]=='\n' || buffer[pos]== '\r'){
|
pclose(outputFile);
|
||||||
if (store) {
|
|
||||||
// stored characters
|
|
||||||
write(output, buffer, pos+chars);
|
|
||||||
}
|
|
||||||
if (mirror) {
|
|
||||||
write(output, "\n", 1);
|
|
||||||
}
|
|
||||||
pos = 0;
|
|
||||||
mirror = 0;
|
|
||||||
store = 1;
|
|
||||||
if (chars) {
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// mirror
|
|
||||||
if (mirror){
|
|
||||||
write(output, &buffer[pos], 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// store
|
|
||||||
if (store) {
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for "csr -p 0x002a=0x0011" (20)
|
|
||||||
if (store == 1 && pos == 20) {
|
|
||||||
int pskey, value;
|
|
||||||
store = 0;
|
|
||||||
if (sscanf(buffer, "csr -p 0x%x=0x%x", &pskey, &value) == 2){
|
|
||||||
if (pskey == 0x01f9) { // UART MODE
|
|
||||||
write(output, "Skipping: ", 10);
|
|
||||||
write(output, buffer, pos);
|
|
||||||
mirror = 1;
|
|
||||||
} else if (pskey == 0x01be) { // UART Baud
|
|
||||||
write(output, "Skipping: ", 10);
|
|
||||||
write(output, buffer, pos);
|
|
||||||
mirror = 1;
|
|
||||||
} else {
|
|
||||||
// dump buffer and start forwarding
|
|
||||||
write(output, buffer, pos);
|
|
||||||
mirror = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
write(output, buffer, pos);
|
|
||||||
mirror = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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