cancel
Showing results for 
Search instead for 
Did you mean: 

SPWF01SC.21 module AT-commands library

Grigori
Associate II
Posted on September 25, 2015 at 13:41

Hi,

Is there any reference AT-commands library written in C for SPWF01 modules? Googling didn't help. Target OS is FreeRTOS, but generic C library is acceptable.

I know, I can write it using state machines etc. It will take time. I believe many of you have already implemented something related.

I would also glad to hear any clues on generic AT-commands libraries which could be easily extended for this module.

They should support at least following functionality:

- data and command states

- async status messages from modem

Could also somebody answer two additional questions:

- if there any status messages while module is in data mode? So, should I check RX buffer in data mode for something like ''+WIND:''?

- what happens in case of closed socket on remote end or lost network? Will module return to command mode itself?

Answer to these additional questions would help in implementing own state machine.

Thank you.

#spwf #spwf01s-wifi #spwf01
13 REPLIES 13
Posted on September 28, 2015 at 16:43

Hi,

About additional questions:

1 - When module is into DataMode, WINDs are not transmitted on UART; you should stay as long as possible in CommandMode, and switch into DataMode on incoming ''+WIND:64:Sockd Pending Data''

2 - In both cases (TCP remote connection down and Network Lost), module automatically turns to command mode (notifying thet remote host has gone). In the second case, socket server is automatically closed also.

Note: UDP connection down cannot be triggered by remote peers...

Regards

jerry

Posted on September 29, 2015 at 11:37

Hi,

I have an answer also for main question.

By Y2015 end, STM32 C libraries to manage the Wi-Fi module will be available in the framework of STM32 Open Development Environment.

Thanks

jerry

Grigori
Associate II
Posted on September 30, 2015 at 11:27

So, does this generally mean we still have to check data in RX buffer and wait for a status message from module? What's the right way to get notified that module has returned to command mode because of network error and to change state of host state machine?

Is there any AT library preliminary drafts available? We have to have fully working product in earl December at latest.

BR,

Grigori

markb
Associate II
Posted on September 30, 2015 at 12:25

Hi,

I am using the SPWF01 module to provide a single websocket connection. My client is a web browser.

What I do is buffer all the characters received from the SPWF01 in a circular buffer. The code that removes the

characters from the buffer checks to see if an indication has been received (all of ''\r\n+WIND:'' are present) and if so,

it reads the indication. There's some subtlety here because you can't let the consumer see the leading \r\n in the indication

until you have made sure that what comes next isn't ''+WIND:'' but if the other end just sends \r\n as part of the data stream

it will get stuck in the circular buffer. To overcome this, I set a maximum time to receive the +WIND: after the \r\n has been

received and if it doesn't arrive, I let the consumer have the \r\n.

My code is working reliably, my biggest problems with the SPWF01 are:

1 - the inbuilt HTTP server doesn't work with the Chrome browser at all well because chrome likes to open multiple sockets

concurrently. Any web browser that opens lots of sockets is going to be a problem. Firefox works well, Safari on an ipad works well.

Chrome is very poor.

2 - could be faster, it would be good to get better throughput. I am using 115K baud with no flow control. Perhaps I should use a faster baud rate

with flow control. Has anyone done that? Is it reliable?

Cheers,

Mark

Posted on September 30, 2015 at 21:17

Hi Grigori,

External host needs always to check rxbuffer to parse received async messages, called WINDs. On almost every received indication, an action is required. When network is lost module prints WINDs ''59:back to command mode'' and ''62:client gone'' (if in DataMode), and ''33:network lost''.

If module is in command mode, WIND:33 is always preceeded by WIND:30 ''bss lost''.

If you don't like parsing rxbuffer, there is an alternative HW way: check (e.g. by interrupt on external host) the GPIO13. It changes its status when module gets the IP address (GPIO low -> wifi up) and lost the network (GPIO high -> wifi down, or network lost).

About the preliminary library, I'll try to get infos. I think the best way is to contact your local ST support/distributor.

Hope to be helpful

Thanks

jerry

Posted on September 30, 2015 at 21:30

Hi Mark,

about the issue with Chrome, I'd like to reproduce this problem. What should I do?

Another info: did you already tried to reduce ip_wait_timeout config variable value?

About flow control, it's ok. RTS and CTS lines allow up to 1Mbps without bytes loss on UART. It's really useful for socket server DataMode...

Thanks

jerry

markb
Associate II
Posted on October 01, 2015 at 09:01

Hi Jerry,

Just put some HTML/JS/CSS files onto the SPWF01 flash and then try accessing them using Chrome. It often works the first time but when you hit

reload, it will often stall. This appears to be because Chrome attempts to do 6 HTTP requests concurrently and so tries to open 6 sockets at the same time.

Firefox doesn't do this and neither does Safari on the ipad. It's a well known problem with Chrome (see chrome issue 85229).

No, I haven't tried altering ip_wait_timeout value yet, I will try that.

Question about flow control: if I want to send more data to the client than the SPWF01 has buffer space for, will it use flow control (when enabled) to

indicate that the module cannot accept more data because the socket is stalled? At the moment, I use a protocol that sends the data to the client

in 1K chunks and doesn't send the next chunk until the client has acknowledged reception. This assumes the module can always accept 1K of data.

Cheers,

Mark

Posted on October 01, 2015 at 09:18

Hi Mark,

module request external host to stop sending by RTS line.

RTS goes high (stop) when internal buffers are full.

Using low baudrates, this usually never happens. To observe an RTS switch, you need to directly stream into DataMode, or call SOCKW in loop, etc...

I assume you are using latest FW3.4.

Ciao

jerry

benny23
Associate II
Posted on November 17, 2015 at 08:47

Hi Jerry,

In the previous message, you inform that 

''By Y2015 end, STM32 C libraries to manage the Wi-Fi module will be available in the framework of STM32 Open Development Environment.''

Do you have any update on this?

Please advise.

Thank you.

Benny