iotconnectivity / python-gsmmodem-manager

A multi-platform framework for communicating and interacting with 2G/3G/4G usb modems
GNU General Public License v3.0
16 stars 5 forks source link

Python3 #3

Open eried opened 4 years ago

eried commented 4 years ago

Hola!

Genial encontrar este codigo, estaba tratando hacer algo similar para un modem huawei. Hay planes para actualizarlo a python3? O usan alguna alternativa?

>>> %Run test.py
Traceback (most recent call last):
  File "/home/pi/Desktop/test.py", line 24, in <module>
    from gsmmodem_manager import HuaweiE3372
  File "/home/pi/.local/lib/python3.7/site-packages/gsmmodem_manager/__init__.py", line 9, in <module>
    from lib import signal_quality, GSMModem, HuaweiModem, HuaweiMS2131, HuaweiMS2372h, HuaweiE3372
ModuleNotFoundError: No module named 'lib'
fontanon commented 4 years ago

Hi. Really thank you @eried .

I'm afraid we do not have any plans to update to python3 soon. We're using the python2.7 library as part of a couple of production projects, and it is running smooth on our raspberry pi zero units.

If you manage to do so, please PR back to us because this can be great contribution :)

Regards!

eried commented 4 years ago

Oh cool, it runs on python2.7 :) on a clone E3372, maybe that old version is good enough :D (porting is not my forte so it would mean a lot of hours googling)

small question: when you do the set operator, if you have a global sim (like hologram.io) can that operator be set automatically?

thanks

fontanon commented 4 years ago

Yep @eried runs on python2.7 very well.

We use the set operator because PodGroup global SIMs are multi-network SIMs (global SIMs): https://www.podgroup.com/products/iot-connectivity/multi-network-iot-sim-cards/

Please refer to your usb dongle AT commands manual to find the "automatic network selection mode". Usually is AT+COPS=0. Perhaps you could add a new method on the library ... something line set_automatic_network_selection that promots the AT+COPS=0 instead of AT+COPS=1,2,{PLMN}.

    def set_automatic_network_selection(self, plmn, sleeptime=2):
        command = 'AT+COPS=0'
        response = self._send_command(command, sleeptime)

        if len(response) and response[0] == 'OK': 
            return True, command, None
        elif response is None or response == []:
            return True, command, None
        else:
            self._logger.error('Set operator failed with: ' + str(response))
            return False, command, response

Would you please fork, add method, test and let us know if that worked for your purposes? PR are welcomed :smile:

eried commented 4 years ago

Oh yes, I will try to add stuff. Thanks