cancel
Showing results for 
Search instead for 
Did you mean: 

BLE_STATUS_TIMEOUT with terminate_gap_procedure

GBara.3
Associate II

Hi everyone,

I am developing an IOT solution using the BLUENRG-M0 from ST.

I am coding in C and I use a custom board with SPI communication between the BLUENRG and my MSP430F5255 from T.I . I am using the ACI API to transmit commands to the BLE module. 

I have 2 boards, and while one is advertising, I want the other to perform scanning in order to receive an advertising report. (And to get the RSSI after). 

My issue is when I want to make another scan. I use the aci_gap_terminate_gap_procedure() with the good opcode link to the function that I use for scanning, but I always receive a BLE_Timeout error. Therefore my primary scan has not ended correctly and I can’t begin a new one. 

I have tried increasing the time before TIMEOUT but nothing changes. 

I didn’t see people talking about the issue with the gap_terminate function, so I ask this here. 

It would be nice if someone could clarify for me the use of this function and why it has this behavior.  

Best regards.

11 REPLIES 11
GBara.3
Associate II

Update: To simplify my ask, I just want a solution to produce multiple scans. When I scan a second time with the discovery function, I got an error so maybe I have to do something before.

Winfred LU
ST Employee

Was the radio still busying?

Maybe try to set a smaller Scan window in the first scanning.

I have checked the radio with the aci_hal_get_link_status() and all the 8 channel are set to 0 when I call the terminate function.

I have also tried a shorter first scan but the aci_gap_terminate_gap_proc() still return me a timeout status.

Winfred LU
ST Employee

>I have checked the radio with the aci_hal_get_link_status() and all the 8 channel are set to 0

It means the links are all idling.

> the aci_gap_terminate_gap_proc() still return me a timeout status

It is expected.

The ACI is to terminate some on-going GAP procedure. The request would time out because it could not find the corresponding procedure to terminate. This is true since all links were idling already.

In your case, the GAP termination does not seem to be needed.

I think the following scanning shall succeed.

>I think the following scanning shall succeed.

That was my thinking too, but when I call a second time the aci_gap_start_general_discovery_proc(), it returns me also a Timeout status.

Winfred LU
ST Employee

This sounds ok in case it did not discover a new device.

When the discovery procedure was done, it would generate an ACI_GAP_PROC_COMPLETE_EVENT.

This could be a confirmation that your device worked normally.

Please test again with duplicate filtering disabled when calling aci_gap_start_general_discovery_proc(), and you would see a lot of duplicated reports.

GBara.3
Associate II

I've tested the ACI_GAP_PROC_COMPLETE_EVENT call, and there are none when I run a scan.

Do you agree that there should be some to signify the end of the scan procedure?

>Please test again with duplicate filtering disabled when calling aci_gap_start_general_discovery_proc(), and you would see a lot of duplicated reports.

I did this but it changes nothing and I don't see duplicates. The only scan that works is the aci_gap_start_selective_conn_establish_proc(), but it's not usable in my case, as I have to do without whitelist.

Still, I get the impression that scanner behavior is not good. However, I'm doing the initialization just right and I'm managing to do some advertising. But I still get the same number of advertising reports whether I enable or disable duplicates.

GBara.3
Associate II

Do you have any examples of code implementing a scanner? So I can check if I'm doing things right.

I've looked on github but there are mostly examples of advertising+connexion and often the scanner part is reduced to using the androit ST BLE application.

Winfred LU
ST Employee

> Do you agree that there should be some to signify the end of the scan procedure?

Agree, and as far as i understand ACI_GAP_PROC_COMPLETE_EVENT would be that event when the procedure is completed.

>The only scan that works is the aci_gap_start_selective_conn_establish_proc()

This is strange. I don't see differences between these scanning methods, since the radio was actually idling.

Maybe there are more clues from the sample projects.

Please check STSW-BLUENRG-DK:

https://www.st.com/en/embedded-software/stsw-bluenrg-dk.html

and X-CUBE-BLE1:

https://www.st.com/en/embedded-software/x-cube-ble1.html