Civlo85 / gsmHat

Using the Waveshare GSM/GPRS/GNSS Hat for Raspberry Pi with Python
MIT License
61 stars 26 forks source link

if no SIM card is entered - the __startWorking will timeout #2

Open fdominik opened 3 years ago

fdominik commented 3 years ago

Have you noticed, that if you start the Waveshare module without a SIM card (you want to test just the GPS part), the gsmHat will timeout and never get to the GPS code? I am getting stuck here:

gsmHat.gsmHat - ERROR - Timeout during data reception
gsmHat.gsmHat - INFO - Command sent: AT+CMGF=1

I was going through the code and the problem is, that if the SIM card is missing, it starts with this command: if self.__sendToHat('AT+CMGF=1'): however the CMGF will return error:

AT
OK
AT+CMGF=1
ERROR

The reason is, that initial state is 1. But if SIM card is missing, initial state should probably be 97?

fdominik commented 3 years ago

So I was looking into the commands and if I execute: AT+CMEE=2 -> enables richer output I can then use: AT+cpin? command to test if this message is outputed: +CME ERROR: SIM not inserted

I was thiknig how to implement it in your code. However I wasnt sure if to put it to __worker_thread() or to a separate method which will be called in __startWorking() method

fdominik commented 3 years ago

@Civlo85 Do you have comment on this? Could you help me to finalize this?