This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Using mobile phone gps to notify location for panic button
#1
Hello everyone. 

I am involved in developing a “panic button” app for mobile phones and watches so that a worker in a hotel, hospital, or other environment can press a button and have their location sent to a safety response team. I’ve written some python code on my laptop that uses the GPS experiment to poll lat, Lon, z, and time data every second. 

I am trying to setup the GPS app to send info to my local python flask web service / sensor-data endpoint.

I've editted the .phyphox file to include this entry, then loaded into a new experiment and used QR to create my new experiment. However I do not see the network block in the generated XML nor do I see any updates to <>/config output. Can you see anything wrong?
...
<network>
<connection id="gps_stream" service="http/post" address="http:---.---.---.---/sensor-data" interval="1">
<send id="gps_latitude" type="buffer" datatype="number" keep="false">lat</send>
<send id="gps_longitude" type="buffer" datatype="number" keep="false">lon</send>
<send id="gps_longitude" type="buffer" datatype="number" keep="false">z</send>
</connection>
</network>
...
Reply
#2
Hi Ken,

as far as I know, our editors do not yet support “network connections”. It (likely) should be included when we are finished with a bit of refactoring of the new editor code.

Are you aware of the REST interface that comes with the remote access feature? I know that it does not entirely suit your plans, however, it might work for some testing purposes.
Reply
#3
(02-10-2025, 11:37 PM)Jens Noriʇzsɔɥ Wrote: Hi Ken,

as far as I know, our editors do not yet support “network connections”. It (likely) should be included when we are finished with a bit of refactoring of the new editor code.

Are you aware of the REST interface that comes with the remote access feature? I know that it does not entirely suit your plans, however, it might work for some testing purposes.

Thank you for your response, Jens. 

If I can't use the web editor to generate the config the uploaded <network> block, what  is the alternative approach? 

I have tried to to use this command to upload a /phyphox command from a local web server, but how can I do this if the GPS experiment is already running? 

I assume I have to insert the config file before I start the GPS experiment, otherwise how can it listen on port 80?

    phone_url = myphone-ip-address/control?cmd=load&url=mylaptop-ip-address:8000/myfile.phyphox"
    try:
        response = requests.get(phone_url)
        print(response.status_code, response.text)
    except Exception as e:
        print(f"Failed to load config file: {e}")
Reply
#4
(02-11-2025, 07:01 PM)kencottrell Wrote: If I can't use the web editor to generate the config the uploaded <network> block, what  is the alternative approach? 
You need to edit the source itself for now, unfortunately.

Quote:I have tried to to use this command to upload a /phyphox command from a local web server, but how can I do this if the GPS experiment is already running? 

I assume I have to insert the config file before I start the GPS experiment, otherwise how can it listen on port 80?

    phone_url = myphone-ip-address/control?cmd=load&url=mylaptop-ip-address:8000/myfile.phyphox"
    try:
        response = requests.get(phone_url)
        print(response.status_code, response.text)
    except Exception as e:
        print(f"Failed to load config file: {e}")
First, you need to activate the “remote access” in the three dots menu. An ip address will show up then in the footer and that's just what you need as source address, so something like
Code:
phone_url = footer-ip-address:optional-port/get?…
(see https://phyphox.org/wiki/index.php/Remot...munication or search the forum for quite some examples)

The response is in JSON format.
Reply


Forum Jump: