Re: How to end outgoing voice call in python

Sylvain <[email protected]> Thu, 30 Mar 2017 13:06:03 +0200
Newsgroups gmane.linux.drivers.gammu
Message-ID <[email protected]>

Le 30/03/2017 à 11:36, Michal Čihař a écrit :
> Sylvain píše v Čt 30. 03. 2017 v 11:24 +0200:
>> Le 30/03/2017 à 10:35, Michal Čihař a écrit :
>>> Hi
>>>
>>> Sylvain píše v St 29. 03. 2017 v 18:29 +0200:
>>>> I'm trying to make a program in python using gammu 1.37.4
>>>> installed
>>>> on
>>>> ubuntu 16.04. The device I use is a Huawei E180 modem.
>>>>
>>>> I'm able to start a voice call with dialVoice, but I can't figure
>>>> out
>>>> how to stop or hang-up the call. I tried with Abort and Terminate
>>>> but
>>>> it
>>>> doesn't work, my program continues but the voice call is still
>>>> active.
>>>> Almost all call related functions are for incoming calls.
>>>>
>>>> Is it doable in python? Any pointers?
>>> CancelCall should do that:
>>>
>>> https://wammu.eu/docs/manual/python/gammu.html#gammu.StateMachine.C
>>> ance
>>> lCall
>>>
>> I tried but it requires the ID of the call as parameter but
>> DialVoice
>> only returns None. I see a lot of functions that use the ID of the
>> call
>> as parameter but none that returns it. How can I get the call ID?
> Use anything as call ID and pass True as second parameter. That should
> do it.
>
It takes at least 30 seconds before the call stops and gives the 
following error after a few dozens of seconds later:
gammu.ERR_DEVICEWRITEERROR: {'Text': u"Erreur lors de l'\xe9criture sur 
le p\xe9riph\xe9rique.", 'Code': 11, 'Where': 'CancelCall'}

Any attempts to launch it again fails at init() with ERR_DEVICENOTEXIST: 
{'Text': u"Erreur \xe0 l'ouverture du p\xe9riph\xe9rique: il n'existe 
pas.", 'Code': 4, 'Where': 'Init'}. I have to physically disconnect and 
reconnect the USB dongle.

My code so far is:

import time
import gammu
sm = gammu.StateMachine()
sm.ReadConfig()
sm.Init()
sm.DialVoice('+xxxxxxxxxxx')
try:
     while True:
         time.sleep(1)
except KeyboardInterrupt:
     sm.CancelCall(0, True)
sm.Terminate()

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gammu-users mailing list - https://lists.sourceforge.net/lists/listinfo/gammu-users