Getting and Setting Modem Parameters
Use the Popoto Python API to read and change modem parameters such as payload mode and transmit power.
Connect to the Modem
Import the popoto class and create a modem object using the modem IP address and command port:
from popoto import popoto
modem = popoto("10.0.0.242", 17000)
Replace 10.0.0.242 with the IP address of your modem.
Set a Parameter
Use set() with the parameter name and new value:
modem.set("PayloadMode", 1)
modem.set("TxPowerWatts", 4.0)
You can also use a typed setter. Use setValueI() for an integer or setValueF() for a floating-point number:
modem.setValueI("PayloadMode", 1)
modem.setValueF("TxPowerWatts", 4.0)
Get a Parameter
First, request the parameter:
modem.get("PayloadMode")
The modem returns the value asynchronously. Wait for a response containing the requested parameter:
reply = modem.waitForSpecificReply("PayloadMode", None, 3)
if "Timeout" in reply:
print("The modem did not respond.")
else:
print(reply["PayloadMode"])
note
get() and the typed getter methods send a request but do not return the parameter value directly. Read the value from the modem response returned by waitForSpecificReply().
Complete Example
from popoto import popoto
modem = popoto("10.0.0.242", 17000)
modem.set("PayloadMode", 1)
modem.get("PayloadMode")
reply = modem.waitForSpecificReply("PayloadMode", None, 3)
if "Timeout" in reply:
print("The modem did not respond.")
else:
print(f"PayloadMode: {reply['PayloadMode']}")
modem.tearDownPopoto()
modem.close()