AllStar to DMR bridge Intro Few days ago I talked to 4X1DA and he challenged…
This post is part of the series OpenSPOT
Other posts in this series:
Last year I wrote about the OpenSPOT and OpenWRT integration but now I encountered an issue.
When I want to connect it to public WiFi network, I can connect it to my phone’s WiFi first then add the public network name to Travelmate and reboot it.
But, how can I tell what’s the IP of the OpenSPOT so I can control it?
At home, I can check the IP on the router but on public networks I don’t have any way to know the IP (don’t want to scan the network, it takes too much time).
Simple!
Make OpenWRT send its IP to external service.
I use service called Dweet.io which allows to send messages for IOT devices.
All you need is to send simple HTTP request and send the data you want.
This is the script:
#!/bin/ash
ips=$(ifconfig | awk '/inet addr/{print substr($2,6)}')
ip1=$(echo $ips | cut -d' ' -f1)
ip2=$(echo $ips | cut -d' ' -f2)
ip3=$(echo $ips | cut -d' ' -f3)
echo $ip1
echo $ip2
echo $ip3
wget -O/dev/null "http://dweet.io/dweet/for/YOUR-NAME?ip1=$ip1&ip2=$ip2&ip3=$ip3"
Quick explanation:
Usually only the last IP is what you need but I decided to leave all of them.
You’ll need to change the YOUR-NAME to unique name.
Then copy the script to /etc/hotplug.d/iface
And change the permissions: chmod +x dweet.sh
Later, I built simple web page to show me the IPs.
If you’re a programmer you probably wonder why not using CURL?
That’s because I wanted to use native OpenWRT tools and it doesn’t include CURL right out of the box.
Actually, I have 127kb left on OpenWRT so I had some limits 🙂
73!