I have been doing some more testing with the R410 and here is what I have come up with. The PPP session that it creates in the python SDK seems to hate me. I have really good signal (22), but I can’t keep it connected. Its the same script I’m running on the u201 that runs like a champ with potato signal.
Sometimes it will complain that maybe I have an unregistered SIM, sometimes it wont be able to find the serial port. The latest one it failed to run and instead of presenting ttyUSB0 and ttyUSB1 like normal, I had ttyUSB0 and ttyUSB2. A lot of the time it will run my script through perfect once, and then it will fail every time after that until it restarts the service (my script).
I have updated the sdk, updated the R410 firmware, I even ran the AT commands to switch it to profile 2 and then back to 0.
Here is my script for reference. I have a lot of sleeps in it to hopefully give the modem time to free up the serial port.
#! /usr/bin/python2.7
import os
import sys
from Hologram.HologramCloud import HologramCloud
import json
credentials = {'devicekey': 'bananas'}
import logging
import time
from logging.handlers import RotatingFileHandler
from random import randint
bc_logger = logging.getLogger("Rotating Log")
bc_logger.setLevel(logging.INFO)
my_formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
handler = RotatingFileHandler("/home/pi/client/logs/nova_service.log", maxBytes=10000, backupCount=5)
handler.setFormatter(my_formatter)
bc_logger.addHandler(handler)
hologram = HologramCloud(credentials, network='cellular')
print("Waiting 30 seconds for modem...")
bc_logger.info("Waiting 30 seconds for modem...")
time.sleep(30)
error_count = 0
while True:
if error_count >10:
hologram.network.disconnect()
bc_logger.info("******************* RESTARTING SERVICE *******************")
os.execv(__file__, sys.argv)
try:
status = hologram.network.getConnectionStatus()
if status == 1:
bc_logger.info('already connected')
print('already connected')
else:
bc_logger.info('no active PPP session, connecting...')
print('no active PPP session, connecting...')
hologram.network.disconnect()
time.sleep(10)
hologram.network.connect(timeout=20)
time.sleep(30)
status = hologram.network.getConnectionStatus()
if status == 1:
bc_logger.info('Got connected!')
print('Got connected!')
else:
bc_logger.info('Failed, to connect to hologram network')
print('Failed, to connect to hologram network')
error_count += 1
time.sleep(10)
continue
time.sleep(5)
level = randint(50,55)
level = str(level)
data = {"level": level,"tank_id": "bananas","auth_token": "bananas","sensor_problem": "False"}
data = json.dumps(data)
recv2 = hologram.sendMessage(message=data, timeout=10)
if str(recv2)=="0":
bc_logger.info("Update Sent!")
print("Update Sent!")
time.sleep(5)
bc_logger.info("Signal Strength: " + str(hologram.network.signal_strength))
print("Signal Strength: " + str(hologram.network.signal_strength))
time.sleep(2*60)
except:
bc_logger.info("There was an error: Count: "+str(error_count))
print("There was an error: Count: "+str(error_count))
error_count=error_count+1
hologram.network.disconnect()
time.sleep(20)