Sinusoidal36 / async-gsm-modem

Apache License 2.0
3 stars 2 forks source link

URC event handlers #7

Open sergzin opened 2 years ago

sergzin commented 2 years ago

Hi there,

I really like this project! I've experimented with a few python gsm libraries and yours is simple and easy to use. I am learning async python and wanted to ask if you could suggest best way to implement URC event handling in async-gms-modem?

I would like to have a couple of functions that would do something on reception of call or SMS. i.e. the script will query periodically some info from a modem but as soon as there is call or SMS, it should switch to other task like answering a call.

Thank you!

Sinusoidal36 commented 2 years ago

Hi, glad you found this library useful. I do not have any time/plans to maintain or further develop it. This library does not support voice.

There is support for URC handling, though I'm not sure how well it it tested:

https://github.com/Sinusoidal36/async-gsm-modem/blob/d220753a50b61a86faedfcdf4e4c52a959dbe882/async_gsm_modem/base/modem.py#L167

You just need to override that function and it should get invoked when an URC is received.

You will need to specify all the possible URCs for your device, as I've done for the EC25 driver: https://github.com/Sinusoidal36/async-gsm-modem/blob/d220753a50b61a86faedfcdf4e4c52a959dbe882/async_gsm_modem/quectel_ec25/constants.py#L31

which is passed in the constructor here: https://github.com/Sinusoidal36/async-gsm-modem/blob/d220753a50b61a86faedfcdf4e4c52a959dbe882/async_gsm_modem/quectel_ec25/modem.py#L17

Hope this helps.