GithubHelp home page GithubHelp logo

hologram-io / hologram-python Goto Github PK

View Code? Open in Web Editor NEW
88.0 28.0 46.0 537 KB

Hologram device-side Python SDK - Send messages to the cloud in just 3 lines of code!

Home Page: https://hologram.io/

License: MIT License

Python 96.47% Makefile 0.06% Shell 3.48%
python-sdk cloud iot python cellular sms ppp serial sdk modem

hologram-python's People

Contributors

akumlehn avatar dependabot[bot] avatar domamato avatar hectormendez avatar holograminterview avatar jtide avatar lalo-hologram avatar loganfrederick avatar parker-hologram avatar rbalik avatar rdotlee avatar tompethtel avatar ttapers avatar tzhenghao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hologram-python's Issues

python_sdk_auth

while trying to install the software

Could not find a version that satisfies the requirement python_sdk_auth~=0.3.0 (from versions: 0.1.2, 0.1.3, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.2.0, 0.2.1, 0.2.2)
No matching distribution found for python_sdk_auth~=0.3.0

Expected behavior

after running pip install hologram-python

i get the error above and am unable to get further.

Connection status is unique to each instance of the sdk

Describe the problem

If you were to create two instances of the HologramCloud object and connect with one of them one would show a status of CLOUD_CONNECTED and the other would be CLOUD_DISCONNECTED. While its a contrived example we should be smarter about monitoring the actual state. We also have unreachable states because nothing changes the status outside of the connect and disconnect functions and neither of them does anything with error handling

Expected behavior

If possible doing network.getConnectionStatus() should return the current connection status through a more involved process. Because some modems have a single serial connection querying them during a PPP session might not be possible be we could also check for an active PPP session and query the ppp0 interface to determine the status more reasonably.

Actual behavior

If you connect outside a script it will just return 0 because the status value is instanced

Steps to reproduce the behavior

Do sudo hologram connect
run a script that tries to query the connection status

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • Python SDK installed via PyPI or GitHub:
  • SDK version (use command below):
  • Python version:
  • Hardware (modem) model:

Intermittent TypeError when receiving

Describe the problem

The following error occurs from time to time when receiving a message from the Hologram dashboard. It seems to occur after successfully receiving a message or two.

pi@raspberrypi:~$ sudo hologram receive
Ready to receive data on port 4010
Received message: Thu Sep 15 2:26:02pm
Received message: Thu Sep 15 3;21:17pm
ERROR: AttributeError("'list' object has no attribute 'startswith'")
Traceback (most recent call last):
  File "/usr/local/bin/hologram", line 181, in <module>
    if __name__ == '__main__': main()
  File "/usr/local/bin/hologram", line 177, in main
    _command_handlers[command_selected_prefix](args)
  File "/usr/local/lib/python3.7/dist-packages/scripts/hologram_receive.py", line 63, in run_hologram_receive
    run_hologram_receive_data(args)
  File "/usr/local/lib/python3.7/dist-packages/scripts/hologram_receive.py", line 85, in run_hologram_receive_data
    handle_polling(args['timeout'], popReceivedMessage, 1)
  File "/usr/local/lib/python3.7/dist-packages/scripts/hologram_util.py", line 37, in handle_polling
    fx()
  File "/usr/local/lib/python3.7/dist-packages/scripts/hologram_receive.py", line 25, in popReceivedMessage
    recv = hologram.popReceivedMessage()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/CustomCloud.py", line 357, in popReceivedMessage
    return self.network.pop_received_message()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 141, in pop_received_message
    return self.modem.pop_received_message()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 269, in pop_received_message
    self.checkURC()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 391, in checkURC
    self.handleURC(urc)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Nova_U201.py", line 104, in handleURC
    super().handleURC(urc)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 415, in handleURC
    self._read_and_append_message_receive_buffer(socket_identifier, payload_length)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 281, in _read_and_append_message_receive_buffer
    msg = self.read_socket(socket_identifier=socket_identifier, payload_length=payload_length)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 337, in read_socket
    self.enable_hex_mode()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 825, in enable_hex_mode
    self.__set_hex_mode(1)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 831, in __set_hex_mode
    self.command('+UDCONF', '1,%d' % enable_hex_mode)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 776, in command
    retries, seteq, read, prompt, data, hide)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 526, in __command_helper
    self.result = self.process_response(cmd, timeout, hide=hide)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 475, in process_response
    self.handleURC(response)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Nova_U201.py", line 104, in handleURC
    super().handleURC(urc)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 415, in handleURC
    self._read_and_append_message_receive_buffer(socket_identifier, payload_length)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 281, in _read_and_append_message_receive_buffer
    msg = self.read_socket(socket_identifier=socket_identifier, payload_length=payload_length)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 342, in read_socket
    bytedata = binascii.unhexlify(resp)
TypeError: argument should be bytes, buffer or ASCII string, not 'NoneType'

Expected behavior

Multiple messages should be able to be received without error

Actual behavior

See above

Steps to reproduce the behavior

See above

System information

Pi 400

pi@raspberrypi:~$ uname -a
Linux raspberrypi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux
pi@raspberrypi:~$ python3 --version
Python 3.7.3
pi@raspberrypi:~$ hologram version
0.9.1

ImportError: bad magic number in 'HologramAuth': b'B\r\r\n'

Describe the problem

Running the install scripts recommended on the Hologram.io site on a clean Odroid N2 Linux install (arm64) produces and error when loading or running Hologram. I've tried using pipenv for a Python 3.6 and normal pip3 install with no luck.

$ python -V
$> Python 3.6.9

Expected behavior

Please describe what you think the program should be doing here.

Actual behavior

(hologram) odroid@mali:~/hologram$ hologram --help
Traceback (most recent call last):
File "/home/odroid/.local/share/virtualenvs/hologram-2mxoctRU/bin/hologram", line 19, in
from scripts.hologram_send import parse_hologram_send_args
File "/home/odroid/.local/share/virtualenvs/hologram-2mxoctRU/lib/python3.6/site-packages/scripts/hologram_send.py", line 14, in
from Hologram.HologramCloud import HologramCloud
File "/home/odroid/.local/share/virtualenvs/hologram-2mxoctRU/lib/python3.6/site-packages/Hologram/HologramCloud.py", line 15, in
from HologramAuth import TOTPAuthentication, SIMOTPAuthentication
ImportError: bad magic number in 'HologramAuth': b'B\r\r\n'

Steps to reproduce the behavior

Please provide the exact command(s) to reproduce the error. If it's non-deterministic,
try your best to describe your observations that might help us troubleshoot the error.

System information

Linux mali 4.9.196-63 #1 SMP PREEMPT Thu Oct 17 00:44:03 -03 2019 aarch64 aarch64 aarch64 GNU/Linux

  • Hardware (modem) model: Odroid N2
    $ hologram version

Traceback (most recent call last):
File "/home/odroid/.local/share/virtualenvs/hologram-2mxoctRU/bin/hologram", line 19, in
from scripts.hologram_send import parse_hologram_send_args
File "/home/odroid/.local/share/virtualenvs/hologram-2mxoctRU/lib/python3.6/site-packages/scripts/hologram_send.py", line 14, in
from Hologram.HologramCloud import HologramCloud
File "/home/odroid/.local/share/virtualenvs/hologram-2mxoctRU/lib/python3.6/site-packages/Hologram/HologramCloud.py", line 15, in
from HologramAuth import TOTPAuthentication, SIMOTPAuthentication
ImportError: bad magic number in 'HologramAuth': b'B\r\r\n'

Add ability to send raw AT commands through the CLI

Is your feature request related to a problem? Please describe.

Would be a nice to have

Describe the solution you'd like

something like sudo hologram command <at command>

Describe alternatives you've considered

Use screen or other serial utilities.

Additional context

Could create a REPL environment but one off commands will do

install.sh supports only python3.7 not python3.8

Describe the problem

In the install.sh file is specified that one of the required libraries is: libpython3.7-dev
That caused issue if you want to install the library with Python 3.8 which seems to be supported looking at the following lines of code where you check the python version.

Failed to install

THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
pycryptodome==3.9.0 from https://www.piwheels.org/simple/pycryptodome/pycryptodome-3.9.0-cp37-cp37m-linux_armv7l.whl#sha256=573feb3c03aaec07beb5875d92a5d46cbcb1d3ffd8052a5801ede690262db940 (from python-sdk-auth~=0.3.0->hologram-python):
Expected sha256 573feb3c03aaec07beb5875d92a5d46cbcb1d3ffd8052a5801ede690262db940
Got 07e69b984c472ce52adbcc73f40aada519edee592383e0f6b598292c33c07958

Add disable eDRX function for CAT-M1 devices

Is your feature request related to a problem? Please describe.

eDRX and other power saving modes prevents the modems from working in many cases

Describe the solution you'd like

add an easy way to turn off these modes through a function command

Describe alternatives you've considered

Additional context

R410 Does not free up serial port after scanning for modems

Describe the problem

When setting up the modems we scan for hardware and then send AT commands to the ports to see which responds. For one reason or another the R410, which only has 1 AT command port, seems to get tied up and does not return an OK when probing the ports.

2021-07-07 16:44:31,703 [INFO] Hologram.Network.Network (1): Detected modem NovaM
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/src/app/hologram/__main__.py", line 105, in <module>
    pinger = CarrierPinger()
  File "/usr/src/app/hologram/__main__.py", line 40, in __init__
    self.hologram = HologramCloud({}, authentication_type='totp', network='cellular')
  File "/usr/local/lib/python3.7/site-packages/Hologram/HologramCloud.py", line 70, in __init__
    network=network)
  File "/usr/local/lib/python3.7/site-packages/Hologram/CustomCloud.py", line 35, in __init__
    network=network)
  File "/usr/local/lib/python3.7/site-packages/Hologram/Cloud.py", line 36, in __init__
    self.initializeNetwork(network)
  File "/usr/local/lib/python3.7/site-packages/Hologram/Cloud.py", line 50, in initializeNetwork
    self._networkManager = NetworkManager.NetworkManager(self.event, network)
  File "/usr/local/lib/python3.7/site-packages/Hologram/Network/NetworkManager.py", line 37, in __init__
    self.network = network
  File "/usr/local/lib/python3.7/site-packages/Hologram/Network/NetworkManager.py", line 68, in network
    self._network.autodetect_modem()
  File "/usr/local/lib/python3.7/site-packages/Hologram/Network/Cellular.py", line 53, in autodetect_modem
    self.modem = dev_devices[0]
  File "/usr/local/lib/python3.7/site-packages/Hologram/Network/Cellular.py", line 243, in modem
    self._modem = self._modemHandlers[modem](event=self.event)
  File "/usr/local/lib/python3.7/site-packages/Hologram/Network/Modem/NovaM.py", line 27, in __init__
    chatscript_file=chatscript_file, event=event)
  File "/usr/local/lib/python3.7/site-packages/Hologram/Network/Modem/Nova.py", line 22, in __init__
    chatscript_file=chatscript_file, event=event)
  File "/usr/local/lib/python3.7/site-packages/Hologram/Network/Modem/Modem.py", line 79, in __init__
    self._initialize_device_name(device_name)
  File "/usr/local/lib/python3.7/site-packages/Hologram/Network/Modem/Modem.py", line 120, in _initialize_device_name
    raise SerialError('Unable to detect a usable serial port')
Exceptions.HologramError.SerialError: Unable to detect a usable serial port

Expected behavior

The modem should be properly detected

Actual behavior

Serial port is not available and prevents the modem from being able to be setup properly

Steps to reproduce the behavior

Plug in an R410 and use our SDK to try and run code with it.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • Python SDK installed via PyPI or GitHub:
  • SDK version (use command below):
  • Python version:
  • Hardware (modem) model:

DriverLoader/Module Error

Describe the problem

Unable to activate sim/nova on a Google-Coral Dev board.

Expected behavior

Activating sim and registering with the network.

Actual behavior

Device is a Google-Coral Dev board running Mendel (custom Debian).

mendel@google-coral:~$ uname -a
Linux google-coral 4.14.98-imx #1 SMP PREEMPT Fri Nov 8 23:28:21 UTC 2019 aarch64 GNU/Linux

Traceback

mendel@google-coral:~$ sudo !!
sudo hologram activate
modprobe: FATAL: Module option not found in directory /lib/modules/4.14.98-imx
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/NetworkManager.py", line 68, in network
    self._network.autodetect_modem()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 50, in autodetect_modem
    raise NetworkError('Modem not detected')
Exceptions.HologramError.NetworkError: Modem not detected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/hologram", line 181, in <module>
    if __name__ == '__main__': main()
  File "/usr/local/bin/hologram", line 169, in main
    run_hologram_activate(args)
  File "/usr/local/lib/python3.7/dist-packages/scripts/hologram_activate.py", line 36, in run_hologram_activate
    hologram = HologramCloud(dict(), network='cellular')
  File "/usr/local/lib/python3.7/dist-packages/Hologram/HologramCloud.py", line 70, in __init__
    network=network)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/CustomCloud.py", line 35, in __init__
    network=network)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Cloud.py", line 36, in __init__
    self.initializeNetwork(network)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Cloud.py", line 50, in initializeNetwork
    self._networkManager = NetworkManager.NetworkManager(self.event, network)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/NetworkManager.py", line 37, in __init__
    self.network = network
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/NetworkManager.py", line 71, in network
    self._network.load_modem_drivers()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 54, in load_modem_drivers
    self._load_modem_drivers()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 188, in _load_modem_drivers
    dl.force_driver_for_device(syspath, vid_pid[0], vid_pid[1])
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/DriverLoader.py", line 38, in force_driver_for_device
    with open(syspath, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/sys/bus/usb-serial/drivers/option1/new_id'

List of modules

mendel@google-coral:~$ sudo lsmod
Module                  Size  Used by
crc32_ce               16384  0
crct10dif_ce           16384  0
wlan                 4952064  0
galcore               401408  2
ina2xx                 16384  0
imx_sdma               36864  2
ip_tables              24576  0
x_tables               45056  1 ip_tables

Device is found

mendel@google-coral:~$ sudo lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 05c6:90b2 Qualcomm, Inc. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Device details

mendel@google-coral:~$ sudo lsusb -d 05c6:90b2 -v

Bus 001 Device 004: ID 05c6:90b2 Qualcomm, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x05c6 Qualcomm, Inc.
  idProduct          0x90b2 
  bcdDevice            0.00
  iManufacturer           1 Qualcomm CDMA Technologies MSM
  iProduct                2 QHSUSB__BULK
  iSerial                 3 95fb2822
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

PPP installed

mendel@google-coral:~$ apt-cache policy ppp
ppp:
  Installed: 2.4.7-2+4.1+deb10u1
  Candidate: 2.4.7-2+4.1+deb10u1
  Version table:
 *** 2.4.7-2+4.1+deb10u1 500
        500 https://packages.cloud.google.com/apt mendel-day/main arm64 Packages
        100 /var/lib/dpkg/status

Steps to reproduce the behavior

curl -L hologram.io/python-install | bash
curl -L hologram.io/python-update | bash
sudo hologram activate

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux google-coral 4.14.98-imx #1 SMP PREEMPT Fri Nov 8 23:28:21 UTC 2019 aarch64 GNU/Linux
  • Python SDK installed via PyPI or GitHub: Python installed via APT package manager
  • SDK version (use command below): 0.9.0
  • Python version: 3.7
  • Hardware (modem) model: SARA-R410M

NameError: global name 'SerialError' is not defined

Hello, I am seeing an issue on top of probably another issue. See the stacktrace below from when I try to do a basic sudo hologram modem connect. It actually connects fine, but for some reason it is unable to move the serial port. However, in an attempt to trigger this error, it actually causes another error due to what looks like a missing import.

  File "/usr/local/lib/python2.7/dist-packages/scripts/hologram_modem.py", line 43, in run_modem_connect
    cloud.network.connect()
  File "/usr/local/lib/python2.7/dist-packages/Hologram/Network/Cellular.py", line 60, in connect
    success = self.modem.connect(timeout = timeout)
  File "/usr/local/lib/python2.7/dist-packages/Hologram/Network/Modem/Nova.py", line 39, in connect
    raise SerialError('Not enough serial ports detected for Nova')
NameError: global name 'SerialError' is not defined

So two questions:

  • Can we get this import fixed? Seems like it should be pretty simple
  • Why would this error occur to begin with? I've tried my nova out of the box on both a Rpi B and an RPi A+, and get this everytime. I'm able to connect fine so it really just makes me want to swallow the error messages which I don't like to do.

thanks!

Disconnecting from a PPP session that was started in a different script fails

Describe the problem

A script tries to disconnect when a PPP session was started and not closed in a separate script. It fails to tear down that PPP session

2020-04-21 20:33:43,414 [INFO] Hologram.Network.Network (2670): Disconnecting from cell network
2020-04-21 20:33:43,415 [INFO] Hologram.Network.Network (2670): Failed to disconnect from cell network
2020-04-21 20:33:43,416 [INFO] Hologram.Network.Network (2670): Connecting to cell network with timeout of 200 seconds
2020-04-21 20:33:43,514 [INFO] Hologram.Network.Modem.ModemMode.ModemMode (2670): Checking for existing PPP sessions
2020-04-21 20:33:43,565 [INFO] Hologram.Network.Modem.ModemMode.ModemMode (2670): Found existing PPP session on pid: 2604
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/pi/ftp/hologram/__main__.py", line 32, in <module>
    pinger.run()
  File "/home/pi/ftp/hologram/pinger.py", line 51, in run
    self.hologram.network.connect()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 67, in connect
    success = self.modem.connect(timeout = timeout)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Nova_U201.py", line 36, in connect
    success = super().connect(timeout)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 97, in connect
    return self._mode.connect(timeout = timeout)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/ModemMode/PPP.py", line 43, in connect
    self.__enforce_no_existing_ppp_session()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/ModemMode/PPP.py", line 72, in __enforce_no_existing_ppp_session
    % pid_list)
Exceptions.HologramError.PPPError: Existing PPP session(s) are established by pid(s) [2604]. Please close/kill these processes first

Expected behavior

Calling disconnect should stop other PPP sessions that are open regardless of what script started them.

Actual behavior

It fails to disconnect

Steps to reproduce the behavior

have 2 python scripts, one that starts a PPP session and another the disconnects. Run 1 than the other. It should fail

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Raspbian Buster
  • Python SDK installed via PyPI or GitHub: Develop branch
  • SDK version (use command below):
  • Python version: 3.7.3
  • Hardware (modem) model: Pi 3 model b

Unable to receive data message from dashboard

Describe the problem

Upon receiving a data message from the dashboard, I'm getting the following error:

Actual behavior

Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/dist-packages/Hologram/CustomCloud.py", line 336, in __incoming_connection_thread
recv += result
TypeError: can only concatenate str (not "bytes") to str

Steps to reproduce the behavior

result = hologram.network.connect()
hologram.initializeReceiveSocket()
for i in range(20):
   message = self.hologram.popReceivedMessage()
   print(f"Data_msg received:  {message}" if message else "no data_msg")

System information

  • Linux
  • hologram-python version: 0.9.0
  • Python 3.7
  • NOVA + SARA-R10M

PDP Context is not torn down after socket message

Describe the problem

When sending a message using sudo hologram send "message" it creates and activates a PDP context but it never tears it down afterwards

Expected behavior

The code should clean up after itself and destroy the PDP context using CGACT=1,0

Actual behavior

Does not tear down the context

Steps to reproduce the behavior

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
  • Python SDK installed via PyPI or GitHub:
  • SDK version (use command below):
  • Python version:
  • Hardware (modem) model:

Allow setting APN programmatically

Is your feature request related to a problem? Please describe.

Changing the APN in the code is not easy as it requires finding the installed code and changing a few lines.

Describe the solution you'd like

Making it an accessible parameter would help with this issue

Describe alternatives you've considered

Additional context

The biggest issue is the chatscript which is not a python class and therefore does not have fields that can be changed in a pythonic manner

remove apt-get update from install script

Describe the problem

In my opinion apt-get update shouldn't be written into the bash install script for two reasons. The instructions on the hologram site to install the sdk use the command

curl -L hologram.io/python-install | bash
There's an issue on the raspbian where apt uses IPv6 and the raspbian mirrors don't like IPv6 so you have to add the option Acquire::forceIPv4=true to successfully grab updates. Therefore, this command will fail, and an inexperienced Linux user won't understand why the curl command fails. A more experienced user will use a command like
curl -L hologram.io/python-install > holo_install.sh
and then edit the file to include the option in the apt-get update and install commands.
Furthermore, if the install fails for some reason (for example, the pip that comes with Raspbian is pip 1.5.6, which is incompatible with python requests (a pip upgrade is necessary for a successful build)), then another call to the install bash script will update again, which is mildly irritating.

Expected behavior

A system update should be done separately from the installation of the SDK (typical protocol for package install on Linux distro is to first update, then install).

Actual behavior

As you've gathered, it's not really a bug I'm describing as much as feature request.

Steps to reproduce the behavior

System information

  • Linux on raspberry pi

install fails missing python-sdk-auth

If you run into SDK issues, please go here for help and support:

You should open a GitHub issue only if it is a bug or a feature request.


Describe the problem

The install fails with a missing package: python-sdk-auth.

Expected behavior

Not fail. not ever.

Actual behavior

Searching for python-sdk-auth==0.2.1
Reading https://pypi.org/simple/python-sdk-auth/
No local packages or working download links found for python-sdk-auth==0.2.1
error: Could not find suitable distribution for Requirement.parse('python-sdk-auth==0.2.1')
make: *** [Makefile:4: install] Error 1

Steps to reproduce the behavior

either make install from this repo, or executing the install script: http://hologram.io/python-install.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux raspberrypi 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux
  • Python SDK installed via PyPI or GitHub: n/a, tried with pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7) and make install from this repo
  • SDK version (use command below): n/a, trying to install 0.8.0
  • Python version: Python 2.7.13
  • Hardware (modem) model: Raspberry Pi 3 B+

Error in send message code when socket is closed shortly after opening

Describe the problem

2020-03-17 21:10:02,755 [DEBUG] Hologram.Network.Modem.IModem (7665): [AT+USOCR=6]
2020-03-17 21:10:03,758 [DEBUG] Hologram.Network.Modem.IModem (7665): [AT+USOCO=0,"cloudsocket.hologram.io",9999]
2020-03-17 21:10:21,568 [DEBUG] Hologram.Network.Modem.IModem (7665): {}
2020-03-17 21:10:21,571 [DEBUG] Hologram.Network.Modem.IModem (7665): {+USOCR: 0}
2020-03-17 21:10:21,572 [DEBUG] Hologram.Network.Modem.IModem (7665): URC! +USOCR: 0
2020-03-17 21:10:21,572 [DEBUG] Hologram.Network.Modem.IModem (7665): handleURC state: 0
2020-03-17 21:10:21,573 [DEBUG] Hologram.Network.Modem.IModem (7665): URC was not handled. '+USOCR: 0'
2020-03-17 21:10:21,574 [DEBUG] Hologram.Network.Modem.IModem (7665): {}
2020-03-17 21:10:21,575 [DEBUG] Hologram.Network.Modem.IModem (7665): {OK}
2020-03-17 21:10:21,575 [INFO] Hologram.Network.Modem.IModem (7665): Connect socket is successful
2020-03-17 21:10:23,578 [INFO] Hologram.Cloud (7665): Sending message with body of length 1071
2020-03-17 21:10:23,582 [DEBUG] Hologram.Network.Modem.IModem (7665): [AT+UDCONF=1,1]
2020-03-17 21:10:23,584 [DEBUG] Hologram.Network.Modem.IModem (7665): {+UUSOCL: 0}
2020-03-17 21:10:23,584 [DEBUG] Hologram.Network.Modem.IModem (7665): URC! +UUSOCL: 0
2020-03-17 21:10:23,585 [DEBUG] Hologram.Network.Modem.IModem (7665): handleURC state: 0
2020-03-17 21:10:23,587 [DEBUG] Hologram.Network.Modem.IModem (7665): {}
2020-03-17 21:10:23,588 [DEBUG] Hologram.Network.Modem.IModem (7665): {OK}
2020-03-17 21:10:23,591 [DEBUG] Hologram.Network.Modem.IModem (7665): [AT+USOWR=b'0,255,"hex encoded data"']
2020-03-17 21:10:23,602 [DEBUG] Hologram.Network.Modem.IModem (7665): {}
2020-03-17 21:10:23,607 [DEBUG] Hologram.Network.Modem.IModem (7665): {+CME ERROR: operation not allowed}
2020-03-17 21:10:23,607 [ERROR] Hologram.Network.Modem.IModem (7665): Failed to write to socket

Expected behavior

The operation should fail gracefully but it looks to keep trying to send the message indefinitely

Actual behavior

It gets into a loop of trying to send the message in what appears to be an endless loop

Steps to reproduce the behavior

Current device in the office always falls into this behavior

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Rasbian Buster
  • Python SDK installed via PyPI or GitHub: github
  • SDK version (use command below): Develop branch
  • Python version: 3.7
  • Hardware (modem) model: Pi 3 model b

Implement Location for Nova M

Is your feature request related to a problem? Please describe.

Location has not been implemented for NB-IoT/4G Nova.

https://github.com/hologram-io/hologram-python/blob/develop/Hologram/Network/Modem/NovaM.py

"raise NotImplementedError('The R404 and R410 do not support Cell Locate at this time')"

Describe the solution you'd like

Please implement or give suggestions to implement.

Describe alternatives you've considered

I tried to implement like Nova_U201 . but PDP mode is failing. See

 @property
def location(self):
    print('sending scan command')
    temp_loc = self.last_location
    if self._set_up_pdp_context():
        self.last_location = None
        ok, r = self.set('+ULOC','2,3,0,120,15,1')
        if ok!=ModemResult.OK:
          print('Location request failed')
          return None
        while self.last_location is None and self._is_pdp_context_active():
          self.checkURC()
    if self.last_location is None:
      self.last_location = temp_loc
    return self.last_location

but it seems the PDP mode doesn't work.

self._set_up_pdp_context

fails.

sending scan command
ERROR: PDP Context setup failed
ERROR: Failed PDP context setup

Additional context

Uses: https://www.u-blox.com/sites/default/files/SARA-R4_ATCommands_%28UBX-17003787%29.pdf CTL+F for "Cell Locate"
https://www.u-blox.com/sites/default/files/GNSS-Implementation_AppNote_%28UBX-13001849%29.pdf "AT Examples"

image

[Research] Use lib to parse PDU instead of doing it ourselves

Is your feature request related to a problem? Please describe.

Not really its just something we can unload and has more features that what we currently implement

Describe the solution you'd like

remove all the pdu stuff which is complex and not feature complete

Describe alternatives you've considered

Additional context

cannot import name 'TOTPAuthentication' from 'HologramAuth' (unknown location)

Describe the problem

I'm on ubuntu 20.04. I installed the packacke as described in the quickstart guide.
The problem is that the HologramAuth package seems to be empty.
When I try to run:

sudo hologram send "Hello World"

or when I try to update the firmware this error appears:

ImportError: cannot import name 'TOTPAuthentication' from 'HologramAuth' (unknown location)

I think the problem regards this line in the HologramCloud.py file when it tries to import such libraries that does not exists anywhere:

from HologramAuth import TOTPAuthentication, SIMOTPAuthentication

Reconnecting PPP after disconnecting fails with route error

Describe the problem

2020-04-21 20:58:01,370 [INFO] Hologram.Network.Network (2990): Adding routes to Hologram cloud
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/pi/ftp/hologram/__main__.py", line 32, in <module>
    pinger.run()
  File "/home/pi/ftp/hologram/pinger.py", line 67, in run
    self.upload()
  File "/home/pi/ftp/hologram/pinger.py", line 101, in upload
    self.hologram.network.connect()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 77, in connect
    self.__configure_routing()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 170, in __configure_routing
    self._route.add('10.176.0.0/16', self.localIPAddress)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Route.py", line 61, in add
    gateway=gateway)
  File "/usr/local/lib/python3.7/dist-packages/pyroute2/iproute/linux.py", line 1886, in route
    callback=callback)
  File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 375, in nlm_request
    return tuple(self._genlm_request(*argv, **kwarg))
  File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 867, in nlm_request
    callback=callback):
  File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 378, in get
    return tuple(self._genlm_get(*argv, **kwarg))
  File "/usr/local/lib/python3.7/dist-packages/pyroute2/netlink/nlsocket.py", line 703, in get
    raise msg['header']['error']
pyroute2.netlink.exceptions.NetlinkError: (101, 'Network is unreachable')

Expected behavior

It should reestablish a connection without error

Actual behavior

the IP route in pyroute 2 is not removed, we tried work around in another branch because of an error reported in the forums but that still failed.

Steps to reproduce the behavior

disconnect from a PPP session and then try to reconnect

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Raspbian Buster
  • Python SDK installed via PyPI or GitHub: Develop
  • SDK version (use command below):
  • Python version: 3.7.3
  • Hardware (modem) model: Pi 3 Model B

Ability to handle multiple modems on a single device

Is your feature request related to a problem? Please describe.

Currently the SDK always defaults to the first modem it can find and knowing what modem options exist could be useful if one modem is preferred over another.

Describe the solution you'd like

Can keep the current method for general use but also enable the ability to enumerate and choose modems that are attached.

Describe alternatives you've considered

It seems possible to specify the make of the modem but if there are two of the same kind it would always default to the first one it finds.

Additional context

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.