Adjust timeout LE and API
Subsystems (2)
PATCH 1/1 Adjust timeout LE and API
The hci_send_req 100ms timeout is not enough when the chip is in deep sleep.
The timeout value has been hardcoded on hci_send_req call and, instead, it should be passed from above (for ex from hci_le_set_scan_enable). This patch removes the hardcoded value from hci_send_req and it increases the timeout to 1000ms.
From: Marco Sinigaglia, [email protected]
--- lib/hci.c | 12 ++++++------ lib/hci_lib.h | 6 +++--- tools/hciconfig.c | 2 +- tools/hcitool.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-)
lib/hci.c +6 -6
@@ -2735,7 +2735,7 @@ int hci_read_clock(int dd, uint16_t handle, uint8_t which, uint32_t *clock,return 0 ; } -int hci_le_set_scan_enable (int dd,uint8_t enable,uint8_t filter_dup) +int hci_le_set_scan_enable (int dd,uint8_t enable,uint8_t filter_dup,int to) {struct hci_request rq;le_set_scan_enable_cp scan_cp;
@@ -2753,7 +2753,7 @@ int hci_le_set_scan_enable(int dd, uint8_t enable, uint8_t filter_dup) rq.rparam = &status; rq.rlen =1 ; -if (hci_send_req (dd, &rq,100 ) <0 ) +if (hci_send_req (dd, &rq, to) <0 )return -1 ;if (status) {
@@ -2766,7 +2766,7 @@ int hci_le_set_scan_enable(int dd, uint8_t enable, uint8_t filter_dup)int hci_le_set_scan_parameters (int dd,uint8_t type,uint16_t interval,uint16_t window, -uint8_t own_type,uint8_t filter) +uint8_t own_type,uint8_t filter,int to) {struct hci_request rq;le_set_scan_parameters_cp param_cp;
@@ -2787,7 +2787,7 @@ int hci_le_set_scan_parameters(int dd, uint8_t type, rq.rparam = &status; rq.rlen =1 ; -if (hci_send_req (dd, &rq,100 ) <0 ) +if (hci_send_req (dd, &rq, to) <0 )return -1 ;if (status) {
@@ -2798,7 +2798,7 @@ int hci_le_set_scan_parameters(int dd, uint8_t type,return 0 ; } -int hci_le_set_advertise_enable (int dd,uint8_t enable) +int hci_le_set_advertise_enable (int dd,uint8_t enable,int to) {struct hci_request rq;le_set_advertise_enable_cp adv_cp;
@@ -2815,7 +2815,7 @@ int hci_le_set_advertise_enable(int dd, uint8_t enable) rq.rparam = &status; rq.rlen =1 ; -if (hci_send_req (dd, &rq,100 ) <0 ) +if (hci_send_req (dd, &rq, to) <0 )return -1 ;if (status) {
lib/hci_lib.h +0 -0
@@ -115,11 +115,11 @@ int hci_read_rssi(int dd, uint16_t handle, int8_t *rssi, int to); int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t
*map, int to);
int hci_read_clock(int dd, uint16_t handle, uint8_t which, uint32_t
*clock, uint16_t *accuracy, int to);
-int hci_le_set_scan_enable(int dev_id, uint8_t enable, uint8_t filter_dup); +int hci_le_set_scan_enable(int dev_id, uint8_t enable, uint8_t filter_dup, int to);
int hci_le_set_scan_parameters(int dev_id, uint8_t type, uint16_t
interval,
uint16_t window, uint8_t own_type,
- uint8_t filter);
-int hci_le_set_advertise_enable(int dev_id, uint8_t enable);
+ uint8_t filter, int to);
+int hci_le_set_advertise_enable(int dev_id, uint8_t enable, int to);
int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
uint8_t initiator_filter, uint8_t peer_bdaddr_type,
bdaddr_t peer_bdaddr, uint8_t own_bdaddr_type,
tools/hciconfig.c +1 -1
@@ -268,7 +268,7 @@ static void cmd_le_adv(int ctl, int hdev, char *opt) rq.rparam = &status; rq.rlen =1 ; - ret =hci_send_req (dd, &rq,100 ); + ret =hci_send_req (dd, &rq,1000 );hci_close_dev (dd);
tools/hcitool.c +3 -3
@@ -2467,13 +2467,13 @@ static void cmd_lescan(int dev_id, int argc, char **argv) } err =hci_le_set_scan_parameters (dd, scan_type, interval, window, - own_type,0x00 ); + own_type,0x00 ,1000 );if (err <0 ) {perror ("Set scan parameters failed" );exit (1 ); } - err =hci_le_set_scan_enable (dd,0x01 ,0x00 ); + err =hci_le_set_scan_enable (dd,0x01 ,0x00 ,1000 );if (err <0 ) {perror ("Enable scan failed" );exit (1 );
@@ -2487,7 +2487,7 @@ static void cmd_lescan(int dev_id, int argc, char **argv)exit (1 ); } - err =hci_le_set_scan_enable (dd,0x00 ,0x00 ); + err =hci_le_set_scan_enable (dd,0x00 ,0x00 ,1000 );if (err <0 ) {perror ("Disable scan failed" );exit (1 );
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Hi Marco,
Quoted 6 lines · Marco Sinigaglia
The
hci_send_req100ms timeout is not enough when the chip is in deep sleep. The timeout value has been hardcoded onhci_send_reqcall and, instead, it should be passed from above (for ex fromhci_le_set_scan_enable). This patch removes the hardcoded value fromhci_send_reqand it increases the timeout to 1000ms.
Quoted 8 lines
From: Marco Sinigaglia, [email protected]
--- lib/hci.c | 12 ++++++------ lib/hci_lib.h | 6 +++--- tools/hciconfig.c | 2 +- tools/hcitool.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-)
The patch looks good but doesn't apply with git am. Could you please recreate it with git format-patch and resend with git send-email? Thanks.
Johan