506
Platforms
©2000-2008 Tibbo Technology Inc.
Dim
x
As
Byte
x = wln.buffrq(6)
' request 6 pages for the wln buffer. Out will then
contain how many can actually be allocated.
' .... Allocation requests for buffers of other objects ....
sys.buffalloc
'perform actual memory allocation, as per previous requests.
Actual memory allocation takes up to 100ms, so it is usually done just once, on
boot, for all required buffers.
You may not always get the full amount of memory you have requested. Memory is
not an infinite resource, and if you have already requested (and received)
allocations for 95% of the memory for your platform, your next request will get up
to 5% of memory, even if you requested for 10%.
Current wln buffer size in bytes can always be checked with the
read-only property.
Note that wln buffer size can't be changed when the Wi-Fi hardware is already
.
How many pages should the wln buffer get?
The size of the wln buffer directly dictates the maximum size of network packets
that the wln object will be able to send (this buffer has nothing to do with
incoming packets). Up to 100 bytes of the buffer space are required for various
packet headers, and the rest is available to packet payload. For example, if you
have allocated 2 pages for the buffer, then the buffer size is 512 bytes. Hence,
maximum payload size cannot exceed 412 bytes.
For TCP communications, the size of individual packets is not that critical. The
beauty of TCP is that it can work with whatever buffer space is available. It is true
that the bigger the buffer, the better TCP throughput is. In reality, you will stop
feeling any improvement in TCP performance once your wln buffer size exceeds 2
or 3 pages.
The UDP is another matter entirely. If you want to be able to send the packets of a
certain size, then you must make sure that you have created an adequate wln
buffer. For example, the DHCP protocol is based on UDP packets. The size of UDP-
DHCP packets can be as large as 1400 bytes. If you are planning to use DHCP on
the wln interface, you will have to allocate the wln buffer that allows the UDP
packets with the payload of at least 1400 bytes. Therefore, you will need at least
1500 bytes of buffer space. Round this to 256-byte pages, and we arrive at
required buffer size of 6 pages.
Applying Reset
The Wi-Fi module requires a hardware reset for correct operation and there is a
dedicated reset (RST) inteface pin for that. Any I/O line of your Tibbo module can
be used to control the reset line.
To reset the Wi-Fi module, enable the GPIO line that controls the reset (let's
assume it is GPIO #51) and set it to LOW first, HIGH next. The reset is complete!
'reset the Wi-Fi module
io.num=PL_IO_NUM_51
io.enabled=YES
'enable this line
io.state=LOW
'apply reset
io.state=HIGH
'remove reset
516
508