Closed strunker closed 1 year ago
If you have Xcode you can simulate locations on your connected iOS device.
Or - much more simple - send your OwnTracks payload from a script in your favorite language to your HTTP or MQTT backend see our booklet
I don't see why this is asked in ios/
.
IIRC you use HTTP but even so the following is trivial to convert to use mosquitto_pub
:
#/bin/sh
tics=$(date +%s)
topic="owntracks/<username>/<devicename>"
payload=$(jo _type=location \
cog=271 \
batt=11 \
lat=48.85833 \
t=u \
lon=2.29513 \
acc=5 \
tid=JJ \
vel=12 \
vac=21 \
alt=167 \
tst=${tics} \
topic="${topic}")
echo $payload
curl -i --data "${payload}" https://<your-recorder-hostname>/owntracks/<username>/<devicename>
It would seem @ckrey and I pressed submit at exactly the same time. :)
Thank you both it's a little hard for me to send random requests via rest. The backend code checks for encrypted payload and TLS and header info etc, it does a bunch of validation on each request. So I'll have to turn all that stuff off while testing which is fine. Was just hoping there was a simple way to test sending a fake location from within the app. But if not no big deal thanks!
Will close this at this time as this doesn't seem to be an app feature.
You ought to be able to create your encrypted payload along the lines of how we recently decrypted:
#!/usr/bin/env python
import base64
import nacl.secret # http://pynacl.readthedocs.org/en/latest/secret/
import json
import time
key = b's3cr1t'
data = {
"_type" : "location",
"tid" : "JJ",
"lat" : 48.856826,
"lon" : 2.292713,
"tst" : int(time.time()),
}
payload = json.dumps(data).encode("utf-8")
box = nacl.secret.SecretBox(key + bytearray(nacl.secret.SecretBox.KEY_SIZE - len(key)))
nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE)
nonce64 = base64.b64encode(nonce)
encrypted = box.encrypt(payload, nonce)
assert len(encrypted) == len(payload) + box.NONCE_SIZE + box.MACBYTES
enc64 = base64.b64encode(encrypted)
print(enc64.decode('utf-8'))
For testing purposes I would like to send fake locations so I can test the back end code that is looking to see if I am in a known region. Hard to develop when you cant simulate being elsewhere. Thanks!