Device status update in Asterisk Queue after Dial action

Hello,

I need to add a remote PSTN phone number as a member in a queue and update a device’s status to reflect the real state as soon as an agent answers. Setting the IN_USE state is successful, but resetting the status to NOT_INUSE either does not occur before the end of the call or never occurs.

Here are the different tests I have done.
What is the solution to modify the variable just after the end of the call ?

Test 1

[demo-context]
exten => _800Z,1,Verbose(1,Calling queue)
same => n,Queue(Queue01)
same => n,Hangup()

exten => johnRemote,1,NoOp()
same => n,Set(DEVICE_STATE(Custom:johnRemote)=INUSE)
same => n,Dial(PJSIP/gw/sip:0600112233@<ip SIP gateway>:5060)
same => n,Set(DEVICE_STATE(Custom:johnRemote)=NOT_INUSE)

Result: It doesn’t work; the last line is never reached.

Test 2

[demo-context]
exten => _800Z,1,Verbose(1,Calling queue)
same => n,Queue(Queue01)
same => n(after),Verbose(1, Test after)
same => n(reset),Set(DEVICE_STATE(Custom:johnRemote)=NOT_INUSE)
same => n,Hangup()

exten => johnRemote,1,NoOp()
same => n,Set(DEVICE_STATE(Custom:johnRemote)=INUSE)
same => n,Dial(PJSIP/gw/sip:0600112233@<ip SIP gateway>:5060)

Result: It doesn’t work; the (reset) priority is never reached even after the end of the call.

Test 3

[demo-context]
exten => _800Z,1,Verbose(1,Calling queue)
same => n,Queue(Queue01)
same => n(after),Verbose(1, Test after)
same => n,Hangup()

exten => johnRemote,1,NoOp()
same => n,Set(DEVICE_STATE(Custom:johnRemote)=INUSE)
same => n,Dial(PJSIP/gw/sip:0600112233@<ip SIP gateway>:5060,30,G(demo-context,johnRemote,reset))
same => n(reset),Set(DEVICE_STATE(Custom:johnRemote)=NOT_INUSE)

Result: It doesn’t work; soon after the hang up, the status is modified to NOT_USE before the end of the call, and a second call is initiated on the ongoing call.

Test 4

[demo-context]
exten => _800Z,1,Verbose(1,Calling queue)
same => n,Queue(Queue01)
same => n(after),Verbose(1, Test after)
same => n(reset),Set(DEVICE_STATE(Custom:johnRemote)=NOT_INUSE)
same => n,Hangup()

exten => johnRemote,1,NoOp()
same => n,Set(DEVICE_STATE(Custom:johnRemote)=INUSE)
same => n,Dial(PJSIP/gw/sip:0600112233@<ip SIP gateway>:5060,30,G(demo-context,_800Z,after))

Result: It doesn’t work; soon after the hang up, the status is modified to NOT_USE before the end of the call, and a second call is initiated on the ongoing call.

Put a hangup handler[1] on the dialed channel that is executed when the channel hangs up in which you could change the custom device state, by using a pre-dial handler[2] when dialing. Though if a Local channel is used for dialling, and the same one also for device state, I believe it should automatically do not in use/in use for the device state assuming /n is used so that the Local channel doesn’t go away.

[1] Hangup Handlers - Asterisk Documentation
[2] Pre-Dial Handlers - Asterisk Documentation

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.