Source language: Translate to:

Web Relay controll

Questions and information about creating Internet aware NeoBook applications. Including PHP, HTML, FTP, HTTP, Email, etc.

Moderator: Neosoft Support

Web Relay controll

Postby johnycorp » Wed Sep 23, 2015 1:46 am

Hi all!

I'm new at the NeoBook and try a new function.
I have this small ethernet board: http://www.ebay.com/itm/371368344640?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
The default IP link is a flllowing: http://192.168.1.4/3000
On this page appear 8 text link to toggle the outputs.

To switch on the output 1 from web browser: http://192.168.1.4/30000/01
To switch off the output 1 from web browser: http://192.168.1.4/30000/00
If put these link a web browser the output 1 working. But after a redirect executed and the main page appear: http://192.168.1.4/30000

How to make a simple POST command in NeoBook for these functions?
Sorry for the question and the bad english, i'm absolute beginner :-)

Thank you.

Karcsi
johnycorp
 
Posts: 4
Joined: Wed Sep 16, 2015 3:08 pm

Re: Web Relay controll

Postby stu » Wed Sep 23, 2015 4:35 am

Have you tried InternetPost fuction?

Code: Select all
InternetPost

Purpose        : Send an HTTP command and data to an Internet server. The response from the server will be stored in the supplied variable.
Category       : Internet
Syntax         : InternetPost "url" "data" "variable" "options"

url
The url that will receive the post command.

data
Additional data (if any) to send to the server. The formatting requirements for this data is highly server and application specific.

variable
The name of the variable to store the server’s response.

options
Enter "Async" here to allow NeoBook to respond to other input while waiting for the server to reply. Leave this parameter blank to suspend user input until the action is complete.

Example        : SetVar "[Host]" "http://www.yoursite.com/test.php"
                 SetVar "[Data]" "fname=Larry&lname=Morton"
                 InternetPost "[Host]" "[Data]" "[Result]" "Async"
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Web Relay controll

Postby johnycorp » Sun Sep 27, 2015 11:53 am

Sorry for the delayed reply. I working hard.

Yes, tried the InternetPost function with variable mode to http://192.168.3.221/30000/01
(with option data send and without).
Not working.
A message received from the modul. This message: Fail to change the IP & port.
This weird, because the IP & port changing url: http://192.168.3.221/30000/42

Code for the button Left Click (i tried with fill data fieldon other case):
InternetPost "http://192.168.3.221/3000/01" "" "[post]" "Async"

I add a textbox, and the General tab add this: [post]. Where receive the message.

Does not work....
johnycorp
 
Posts: 4
Joined: Wed Sep 16, 2015 3:08 pm

Re: Web Relay controll

Postby Gaev » Sun Sep 27, 2015 1:56 pm

johnycorp:

I searched the internet for documentation about interacting with the ENC28J60 Network Module 8-Channel Network Controller but did not find any.

When you said that ...
To switch on the output 1 from web browser: http://192.168.1.4/30000/01
To switch off the output 1 from web browser: http://192.168.1.4/30000/00

... did you achieve this by typing the above values in the address box of your Browser ... or was this request POSTed from some javascript/form inside an html document ?

If you typed it, then that qualifies as a GET method ... perhaps you need to use the InternetGet command in NeoBook ... so try ...
Code: Select all
InternetGet "!http://192.168.1.4/30000/01" "[OnResult]" ""
AlertBox "Response" "[OnResult]"

and


InternetGet "!http://192.168.1.4/30000/00" "[OffResult]" ""
AlertBox "Response" "[OffResult]"


Note1: To be safe, include the ! before the http:

Note2: To make sure that you know when the command is responded to, do NOT specify the Async option


Are you in possession of documentation which specifies what method is to be used to communicate with the server software on the board ?
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Web Relay controll

Postby johnycorp » Sat Oct 03, 2015 1:01 pm

Thanks for help stu!

And big thanks Gaev!
The InternetGet method working good. I make the app.
Only small design editing remain.
See the attached images :D

Only a problem remain.
On attached image appear this: webio_status.png
I want the get the string (marked red), because these numbers have status of output 1-8.
What sould be the solution this?

http://www.mediafire.com/view/hz0msl5s1qmwfke/webio_edit.png

http://www.mediafire.com/view/ai38mvcbth63cli/webio_main.png

http://www.mediafire.com/view/qi479bm4tbvmqqq/webio_status.png
johnycorp
 
Posts: 4
Joined: Wed Sep 16, 2015 3:08 pm

Re: Web Relay controll

Postby Gaev » Sat Oct 03, 2015 2:11 pm

johnycorp:

Only a problem remain.
On attached image appear this: webio_status.png
I want the get the string (marked red), because these numbers have status of output 1-8.
What sould be the solution this?

Tell me if my understanding of your enquiry is correct.

1) the text in black with a grey background (directly above the button labelled Get Relay Status) is what is being returned from a command like ...
Code: Select all
InternetGet "!http://192.168.1.4/something/or/other" "[StatusResult]" ""


2) You want to know how to extract the 16 digits of information that you have enclosed in the red coloured rectangle


If this is so, you will need to use the StrParse and SubStr commands ... assuming the returned text is in variable called [StatusResult] ...
Code: Select all

StrParse "[StatusResult]" "!>" "[ResultPart]" "[ResultPartsCountcount]"
... now the first 16 characters of [ResultPart2] will contain the desired data


SubStr "[ResultPart2]" "1" "16" "[StatusOfAll8Ports]"
... all 16 digits are now in [StatusOfAll8Ports]


SubStr "[ResultPart2]" "1" "2" "[StatusOfPort1]"
... status of port 1 is now in [StatusOfPort1]

SubStr "[ResultPart2]" "3" "2" "[StatusOfPort2]"
... status of port 2 is now in [StatusOfPort2]

etc. etc.


If my understanding is incorrect, please elaborate on your needs.
User avatar
Gaev
 
Posts: 3737
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Web Relay controll

Postby johnycorp » Sat Oct 10, 2015 1:04 pm

Gaev:

Yes, this solution working!
Thank you!

I used the code in this format:

Code: Select all
InternetGet "http://[IPAddress]/[PortNumber]/99" "[StatusResult]" ""
... Used the previously defined variables

StrParse "[StatusResult]" "!00000000[#34]>" "[ResultPart]" "[ResultPartsCountcount]"
... !00000000[#34]> result the correct string.
... now the first 16 characters of [ResultPart2] will contain the desired data


SubStr "[ResultPart2]" "1" "16" "[StatusOfAll8Ports]"
... all 16 digits are now in [StatusOfAll8Ports]


SubStr "[ResultPart2]" "1" "1" "[StatusOfPort1]"
... status of port 1 is now in [StatusOfPort1]

SubStr "[ResultPart2]" "3" "1" "[StatusOfPort2]"
... status of port 2 is now in [StatusOfPort2]


Thanks again for the help!

Have a nice weekend!
johnycorp
 
Posts: 4
Joined: Wed Sep 16, 2015 3:08 pm


Return to NeoBook and the Internet

Who is online

Users browsing this forum: Bing [Bot] and 0 guests

cron