diff --git a/device/cheetah/MODEM-CLIENT.md b/device/cheetah/MODEM-CLIENT.md index 8561bb114..2b1915296 100644 --- a/device/cheetah/MODEM-CLIENT.md +++ b/device/cheetah/MODEM-CLIENT.md @@ -122,9 +122,14 @@ registration indication), unless `ims_required = yes`. message appears in the daemon's log. - **Outgoing SMS** carry a durable 32-hex request id; an interrupted or uncertain send is marked `unknown`, never repeated automatically. -- **Calls**: a hangup whose release isn't confirmed within 12 s, or a call - left over from a previous run, turns the radio off (best effort, AT+CFUN=0) - and stops sitd with the call still recorded as its own, for an attended +- **Calls**: when a hangup's release isn't confirmed within 12 s, or the + modem refuses an answer or a hang-up, sitd first asks the modem for its + calls (`GET_CURRENT_CALLS`): if it lists none, and no dial is still being + set up, the calls shown here are stale and end here, and sitd keeps + running ("the modem lists no call; N stale call(s) ended here"). Otherwise + (the modem lists a call, the check fails, a dial is pending), and for a call + left over from a previous run, the radio goes off (best effort, AT+CFUN=0) + and sitd stops with the call still recorded as its own, for an attended reboot. The journal says "Call release not confirmed: ", the radio and CP states, and "attended reboot required". The RIL no longer stops the modem unit or powers the CP off: an in-place power-off reset the 9a once, diff --git a/packages/omamobile-modem-sit/lib/service.py b/packages/omamobile-modem-sit/lib/service.py index ab7d9be68..525faad82 100644 --- a/packages/omamobile-modem-sit/lib/service.py +++ b/packages/omamobile-modem-sit/lib/service.py @@ -514,9 +514,52 @@ def pump(self): break self.event(packet) if self.hangup_deadline and time.monotonic() > self.hangup_deadline: + if self.reconcile('the hangup deadline expired'): + return self.release_unconfirmed = True unconfirmed_release(self.client, 'hangup deadline expired') + def reconcile(self, why): + """Ask the modem before giving a call up as unconfirmed. + + A call forwarded straight back to this phone rings here, the + outgoing call ends with cause 17, and the modem never mentions the + incoming one again: it refuses the answer and the hang-up (error 2) + and lists no call. If GET_CURRENT_CALLS is empty, the calls still + shown here are stale and end here; True then. The dial action relies + on the same answer before it dials. + + Not while a dial's setup is pending (no status yet, so no modem ID): + the modem may not list a late dial yet, and ending it here would + drop the status of a call that then connects. That case, a modem + that lists a call and a check that fails in any way stay with + unconfirmed_release(). + """ + if self.pending or any(call['modem_id'] is None for call in self.live()): + return False + try: + listed = self.client.request(0x0000, timeout=5) + except Exception as error: + # Anything, not only a refusal or a timeout: the transport also + # raises RuntimeError (framing, a short write, the indication + # limit) and EOFError, and none of them may skip the radio-off. + print('Call check after', why, 'failed:', type(error).__name__, flush=True) + return False + if listed != bytes(4): + print('Call check after', why + ': the modem still lists a call', flush=True) + return False + stale = self.live() + for call in stale: + call['state'] = 'terminated' + call['reason'] = 'error' + call['since'] = time.time() + self.hangup_deadline = None + self.audio_stop() + self.save_calls() + print('Call check after', why + ': the modem lists no call;', len(stale), 'stale call(s) ended here', + flush=True) + return True + def send_sms(self, request): key = request.get('request_id', '') if not isinstance(key, str) or len(key) != 32 or any(c not in '0123456789abcdef' for c in key): @@ -794,12 +837,22 @@ def dispatch(self, request): try: # Ordinary voice, audio send/receive, no video. self.client.request(0x0d02, struct.pack('