Send or become a Json String from/ to a http ADR

Code tips and tricks for beginners
Post Reply
Helmut_number_one
Posts: 194
Joined: Fri Dec 09, 2022 10:03 am
Location: Flensburg Deutschland
Has thanked: 148 times
Been thanked: 30 times

Send or become a Json String from/ to a http ADR

Post by Helmut_number_one »

I want to send a JSON string to a web address, my exercises have no result.
The Code is

Code: [Local Link Removed for Guests]

if (token$ ="4157") then  ' if the token correspond to the read request
  if (word$(r$, 2) <> "Error") then  'if is not an error
    'assemble the 4 bytes in one 32 bits word
    value$ = "&h"+ word$(r$, 5) + word$(r$, 6) + word$(r$, 7) + word$(r$, 8)
    Ergebnis1= val(value$)
    Ergebnis =  ( CONVERT.FROM_IEEE754(Ergebnis1) )    
    Ergebnis4157$ = str$(Ergebnis,"%5.1f") + " W Momentleistung"
    wlog Ergebnis4157$
    
[b]    'a$ = WPOST$ ( "192.168.0.104/" ,  { "total": Ergebnis4157$ } , 80 )[/b]
  end if
Please can you help?
Last edited by Helmut_number_one on Mon May 20, 2024 8:56 pm, edited 2 times in total.
User avatar
cicciocb
Site Admin
Posts: 3067
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 627 times
Been thanked: 2186 times
Contact:

Re: Send Json String to a http ADR

Post by cicciocb »

What is the destination server?
Have you tried this ?

[Local Link Removed for Guests]
Helmut_number_one
Posts: 194
Joined: Fri Dec 09, 2022 10:03 am
Location: Flensburg Deutschland
Has thanked: 148 times
Been thanked: 30 times

Re: Send Json String to a http ADR

Post by Helmut_number_one »

Ah, I change my wish because it's more flexible.
Can I also make a JSON query on my ANNEX ESP32 IP address with the result?
If i write http://198.168.x.104/emeter i want the result in my Modbus RTO ESP32 Annex Basic PRG.
i become this JSON path example return :
power/total/watts - Finds 123.4 in { "power": { "phase1": { "factor": 0.98, "watts": 42 }, "total": { "watts": 123.4 } } }
total - Finds 123.4 in { "othervalue": 66, "total": 123.4 }
is that possible?
User avatar
cicciocb
Site Admin
Posts: 3067
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 627 times
Been thanked: 2186 times
Contact:

Re: Send or become a Json String from/ to a http ADR

Post by cicciocb »

Do you want receive an answer from Annex?
I mean, the address http://198.168.x.104/emet is an annex module ?
Helmut_number_one
Posts: 194
Joined: Fri Dec 09, 2022 10:03 am
Location: Flensburg Deutschland
Has thanked: 148 times
Been thanked: 30 times

Re: Send or become a Json String from/ to a http ADR

Post by Helmut_number_one »

When a request comes from a device to my Annex Basic ESP32,
a JSON response with my data from the energy measuring device should come to the requesting device.
User avatar
cicciocb
Site Admin
Posts: 3067
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 627 times
Been thanked: 2186 times
Contact:

Re: Send or become a Json String from/ to a http ADR

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Tue May 21, 2024 5:30 am When a request comes from a device to my Annex Basic ESP32,
a JSON response with my data from the energy measuring device should come to the requesting device.
In this case you must use the event OnUrlMessage
[Local Link Removed for Guests]
Post Reply