cancel
Showing results for 
Search instead for 
Did you mean: 

remote control with SPWF01SA

nataut
Associate III
Posted on December 19, 2017 at 11:53

I have to use the SPWF01S module to do a remote control by means a smartphone. The

SPWF01S module communicates via UART with

 an electronic board connected to an asynchronous motor. I want to send to the electronic board the START, STOP, DIRECTION and SPEED commands and I want to read cyclically the motor status (SPEED and other parameter). In the future I'm going to use a custom smartphone app but for the moment I will use the browser web page. 

I followed the 'wifi Training - Hands On - FW3.5.pdf' and the 'AN4902' application note by ST. Now I can send a chars string to the module but I don't know how to read CYCLICALLY

 the data from the module. I read that #input SSI command allows to receive a chars string from the module. Using the 'input_demo.shtml' page I managed to receive a chars string from the module after pushing the 'Submit' button. In my case don't need the 'Submit' button because I have to read cyclically. Can you tell me how to do to read cyclically every (for example) 100 milliseconds?   

 

Thanks

5 REPLIES 5
Posted on December 19, 2017 at 13:35

Basically you need a server, and your smartphone will connect to module to exchange data. You can decide to:

  1. use webserver capability (TCP port number 80) + default input/out capabilities;
  2. open a socket server on some TCP or UDP port;
  3. open a socket server on TCP port numbero 80 (after disabled internal webserver).

Case number 1 is what you already know. Use input_demo and output_demo.

Case number 2 is the most simple case, BUT you need to develop on smartphone an ad-hoc APP.

Case number 3 is probably what you need. Once smartphone connected to module by standard web Browser, you can send/receive data without AT commands. It's a simple cable replacement called 'Data Mode'. BUT in this case your external host needs to parse the HTTP request, and reply accordingly with 200 OK etc...

Posted on December 19, 2017 at 14:26

At the moment I can use the case number 1. How can I do a cyclically read?  

Thanks.

nataut
Associate III
Posted on December 20, 2017 at 12:15

Hello.

To read cyclically the data from the WiFi module, my idea is to modify the 'input_demo.shtml' file (below), by removing the 'radio' and 'submit' input tag and adding a javascript function that periodically sends a GET request to the 'input.cgi' script stored on the server. Is it possible to do this?    

Is there any document where is explained how to use the 'input.cgi' and 'output.cgi' script? Are they modifiable? Have they any parameter that must be passed?   

Thanks

input_demo.shtml

<html>

<head><title>Input Demo</title></head>

<body bgcolor='white' text='black'>

<p>Input from Host: <!--#input--> </p>

<p>

<br/><br/>Again?<br/>

<form name='CGI Uart' method='GET' action='/input.cgi'>

<input type='radio' name='input' value='on'/>Yes, one more time. Please<br/>

<input type='radio' name='input' value='off'/>No, thanks. Bring me to HomePage<br/>

<input type='submit' name='submit' value='Submit' >

</form>

</p>

</body>

</html>
Posted on December 20, 2017 at 12:21

Input/output demos are based on simple HTTP GET requests. So, you need to trigger internal webserver with a new request every time you want to push/pop some data. You can do it cyclically (send a new request as soon as the previous one was completed), but it really depends on expected rate for requests. Be prepared to switch to case 2 or 3...

Take a look at

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/ad/43/83/a2/30/5f/41/6e/DM00321409/files/DM00321409.pdf/jcr:content/translations/en.DM00321409.pdf

nataut
Associate III
Posted on December 22, 2017 at 15:07

I'm tinking to modify the 

input_demo.shtml

  and 

output_demo.html

  files and make my 

input_demo_my.shtml

  and 

output_demo_my.html 

files leaving unchanged the part relating to the #input SSI command. I read in the AN4902 it is possible to store the new files in the

external

flash (while the input_demo.shtml

  and 

output_demo.html

  are in the

internal

flash ) . In this case, if I send the

https://community.st.com/external-link.jspa?url=http%3A%2F%2F

<<ip address>>/input.cgi?input=on&submit=Submit

URL which file does it answer to the http request,

input_demo.shtml

  or 

input_demo_my.shtml

?

Thanks