timer not freeing resources?

4 posts / 0 new
Last post
brian
Offline
Last seen:6 years 1 month ago
Expert Master
Joined:2014-10-16 18:10
timer not freeing resources?

I have created a connection-timeout timer as follows

app_timer_set(app_ble_dev[device_number].timer, TASK_APP, 700); //7 sec

where a connection timer id has been defined for each device that could be simultaneously connected. IN this case there is but one device a connection is being attempted to. So the cycle is:

Scan
Stop scan
call app_timer_set
attempt to connect
on timeout call cancel
on evt done callback case direct connection cancel repeat loop (start scan)

This sequence repeats potentially forever. But after N cycles (where N ranges from 2 to 15+) a hardfault is signaled. No indication of what method the fault occurs in is signaled.

If I do NOT attempt the connection with its timeout, the cycle is able to repeat forever (as far as I have been willing to wait).

Am I missing a step here? Do I also need to invoke the disconnect method though I am not connected? Do I need to still cancel the timer (as I do on a successful connection)?

MHv_Dialog
Offline
Last seen:1 month 2 weeks ago
Staff
Joined:2013-12-06 15:10
When a connection succeeds or

When a connection succeeds or fails for some reason other than timeout, do you clear the timer?

"on evt done callback case direct connection cancel repeat loop (start scan)" - I couldn't quite decipher that...

brian
Offline
Last seen:6 years 1 month ago
Expert Master
Joined:2014-10-16 18:10
Yes I clear the timer. So far

Yes I clear the timer. So far connection failure has only been due to timeouts. I see if the timer is active and if it is I clear it.

What I am stating in the last line when the direct-connection event is reported as completed (in this case it completed because I canceled the connection since it timed out), I repeat the loop. I restart the scan, and after 10 seconds when the scan stops. try and connect to a device that has been discovered and is disconnected. If the device is not there, the connection times out. I cancel the connection event, I get the cancel indication in the direct-connection complete event, and then I restart the scan, etc. The loop repeats indefinitely ... or at least it should. Eventually I get a hard fault but no indication as to what method was being executed that caused the hard fault. So it sounds like resources building up that eventually crash the system.

brian
Offline
Last seen:6 years 1 month ago
Expert Master
Joined:2014-10-16 18:10
I am still getting this error

I am still getting this error. Is there something one can do to get a better idea of what caused the hard fault? The last line of code executed, the method one was in, etc.?