I don’t know too much about webhooks.
First a question:
RE: “…the webhook to send a packet to my SIM device.”
Don’t you have to have your sim device somehow connected to the cellular network to be able to receive the webhook?
RE: “It would be nice to know a little more about how you send something to your SIM device without the SIM device contacting the server first.”
I don’t. You had mentioned you need to do it without an SSH tunnel.
I do have my SIM device/Rpi set up a ppp connection:
Python code:
from Hologram.HologramCloud import HologramCloud
hologram=HologramCloud(dict(), network=‘cellular’) #setup hologram cloud
hologram.enableSMS #tell hologram to listen for sms
However I found the ppp connection does not stay connected forever - presumably the cellular carrier closes the connection after a (variable?) amount of time of inactivity.
My solution to this was to have a cronjob run my script every 15 minutes.
I send a sms and the Rpi checks what the message says (in the example below the sms message is “ping”). Then the Rpi runs a script which can include an sms with a topic and data back to the dashboard which could invoke a route/webhook.
I understand how much time you spent solving your problem and I’m glad you got it solved. I’m posting this to share information and perhaps save someone time.
Karl
P.S.
Just in case someone reads this post, here’s a reference and the important part of my python code on my SIM device/R pi:
Reference: Hologram Python SDK - Receiving Data - Hackster.io
Python script that a cronjob runs every 15 minutes:
import datetime
import time
import os
import subprocess
import re
from Hologram.HologramCloud import HologramCloud
hologram=HologramCloud(dict(), network=‘cellular’) #setup hologram cloud
hologram.enableSMS #tell hologram to listen for sms
time.sleep(300) # ample time for Hologram Nova modem to boot
def getsms():
global recv # need to be global if want to reference this outside this function (ie in main section)
recv = hologram.popReceivedSMS()
# print(recv) # if there is no message recv will be: None
# if there is a message recv will be(example): SMS: sender: 447937405250, timestamp: Fri May 27 00:21:50 2022, message: this is a test
if “None” in str(recv):
# print(“no message received”)
pass
else:
print(" ")
print(“Message received: “, recv)
# prepends to log file
# ref: Prepend a line to an existing file in Python - Stack Overflow
filename = ‘/home/karl/Data/logs/log_sms_received.txt’
with open(filename, ‘r’) as original: data = original.read()
now = datetime.datetime.now()
with open(filename, ‘w’) as modified: modified.write(str(recv) + " Cabinpi4 time is: " + now.strftime(” %a %d %b %Y %H:%M:%S %p %Z”) + “\n” + data)
if “ping” in str(recv):
sends_sms_received_ping()
def sends_sms_received_ping():
# will send sms to Hologram dashboard “received ping”
operator=hologram.network.operator
message=operator + " Cabinpi4 received sms ping"
response_code = hologram.sendMessage(message)
print(hologram.getResultString(response_code)) # Prints ‘Message sent successfully’
getsms()
hologram.network.disconnect() # This disconnect the ppp connection if it exists