0% found this document useful (0 votes)
319 views53 pages

Flyport API 2.0

Uploaded by

Cesar Feliz
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
319 views53 pages

Flyport API 2.0

Uploaded by

Cesar Feliz
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

OpenPicus - Flyport

Wed Apr 27 2011 17:38:46

Contents

1 2

OpenPicus Module Index


2.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 3
3

Data Structure Index


3.1 Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5
5

File Index
4.1 File List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7
7

Module Documentation
5.1 Delays 5.1.1 5.1.2 5.1.3 . . . . . . . . . . . . . . Detailed Description . . Delays . . . . . . . . . . Function Documentation 5.1.3.1 DelayMs . . . . 5.1.3.2 DelayUs . . . . 5.1.3.3 vTaskDelay . .
5.1.3.4 5.1.3.5

9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 9 9 9
9 10 10 10 11

vTaskSuspendAll xTaskResumeAll .

5.2

ARPlib stack . . . . . . . . . . . 5.2.1 Detailed Description . . 5.2.2 ARP library . . . . . . . 5.2.3 Function Documentation
5.2.3.1 ARPResolveMAC

. . . . . . . . . . . . . . . . . .

11 11 11 11
11

5.3

FTPlib stack . . . . . . . . . . . 5.3.1 Detailed Description . . 5.3.2 library . . . . . . . . . . 5.3.3 Function Documentation
5.3.3.1 5.3.3.2 5.3.3.3 5.3.3.4 5.3.3.5 5.3.3.6 FTPClientOpen FTPClose . . . FTPisConn . . FTPRead . . . FTPRxLen . . . FTPWrite . . .

12 12 12 12
12 12 13 13 13 14

5.4

ADC . . . . . . . . . . . . . . . 5.4.1 Detailed Description . . 5.4.2 Function Documentation 5.4.2.1 ADCInit . . . .

14 14 14
14

ii

CONTENTS

5.5

5.6

5.4.2.2 ADCVal . . . . GPIOs . . . . . . . . . . . . . . 5.5.1 Detailed Description . . 5.5.2 Function Documentation 5.5.2.1 IOButtonState . 5.5.2.2 IOGet . . . . . 5.5.2.3 IOInit . . . . . 5.5.2.4 IOPut . . . . . UART . . . . . . . . . . . . . . 5.6.1 Detailed Description . . 5.6.2 Function Documentation 5.6.2.1 5.6.2.2 5.6.2.3 5.6.2.4 5.6.2.5 5.6.2.6 5.6.2.7 5.6.2.8 UARTBufferSize UARTFlush . . UARTInit . . . UARTOff . . . UARTOn . . . UARTRead . . UARTWrite . . UARTWriteCh .

5.7

5.8

5.9

PWM . . . . . . . . . . . . . . . 5.7.1 Detailed Description . . 5.7.2 Function Documentation 5.7.2.1 PWMDuty . . . 5.7.2.2 PWMInit . . . . 5.7.2.3 PWMOff . . . . 5.7.2.4 PWMOn . . . . I2C . . . . . . . . . . . . . . . . 5.8.1 Detailed Description . . 5.8.2 Function Documentation 5.8.2.1 I2CInit . . . . . 5.8.2.2 I2CRead . . . 5.8.2.3 I2CRestart . . . 5.8.2.4 I2CStart . . . . 5.8.2.5 I2CStop . . . . 5.8.2.6 I2CWrite . . . SMTPlib stack . . . . . . . . . . 5.9.1 Detailed Description . . 5.9.2 Function Documentation 5.9.2.1 SMTPBusy . . 5.9.2.2 SMTPSend . . 5.9.2.3 SMTPSetMsg .
5.9.2.4 5.9.2.5 5.9.2.6 SMTPSetServer SMTPStart . . SMTPStop . .

5.10 TCPlib stack . . . . . . . . . . . 5.10.1 Detailed Description . . 5.10.2 library . . . . . . . . . . 5.10.3 Function Documentation
5.10.3.1 5.10.3.2 TCPClientClose TCPClientOpen

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

15 15 15
15 16 16 16

17 17 17
17 17 18 18 18 18 19 19

19 20 20
20 20 20 21

21 21 21
21 22 22 22 22 23

23 23 23
23 24 24 24 25 25

25 26 26 26
26 26

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

CONTENTS

iii

5.10.3.3 5.10.3.4 5.10.3.5 5.10.3.6 5.10.3.7 5.10.3.8 5.10.3.9

TCPisConn . . . TCPRead . . . . TCPRxLen . . . TCPServerClose . TCPServerDetach TCPServerOpen . TCPWrite . . . .

5.11 UDPlib stack . . . . . . . . . . . 5.11.1 Detailed Description . . 5.11.2 UDP library . . . . . . . 5.11.3 Function Documentation
5.11.3.1 5.11.3.2 5.11.3.3 5.11.3.4 5.11.3.5 5.11.3.6 5.11.3.7 5.11.3.8

. . . .

. . . . . . . . . . .

UDPBroadcastOpen UDPClientClose . . UDPClientOpen . . UDPRead . . . . . UDPRxLen . . . . UDPServerClose . UDPServerOpen . . UDPWrite . . . . .

5.12 WiFi . . . . . . . . . . . . . . . 5.12.1 Detailed Description . . 5.12.2 Function Documentation 5.12.2.1 WFConnect . .
5.12.2.2 5.12.2.3 5.12.2.4 5.12.2.5 5.12.2.6 5.12.2.7 5.12.2.8 5.12.2.9 5.12.2.10 5.12.2.11 5.12.2.12 5.12.2.13

. . . .

WFCustomDelete WFCustomExist . WFCustomLoad . WFCustomSave . WFDisconnect . . WFHibernate . . WFPsPollEnable . WFScan . . . . . WFScanList . . . WFSetParam . . WFSetSecurity . WFStopConnecting

. . . . . . . . . . . . . . .

5.13 System . . . . . . . . . . . . . . . 5.14 Net . . . . . . . . . . . . . . . . . . 5.15 Hardware . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

27 27 27 28 28 28 28

29 29 29 29
29 30 30 30 30 31 31 31

31 32 32
32 32 33 33 33 34 34 34 34 35 35 36 37

37 37 38

Data Structure Documentation


6.1

39

tWFNetwork Struct Reference . . . . . . . . . . . . . . . . . . . . . . . 39

File Documentation
7.1 7.2 7.3 7.4 C:/openpicus/X Release 2.0/Flyport libs/ARPlib.c File Reference 7.1.1 Detailed Description . . . . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/FTPlib.c File Reference . 7.2.1 Detailed Description . . . . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/HWlib.c File Reference . 7.3.1 Detailed Description . . . . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/SMTPlib.c File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . .

41
41 41 41 41 42 42 42

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

iv

CONTENTS

7.5 7.6 7.7

7.4.1 Detailed Description . . . . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/TCPlib.c File Reference 7.5.1 Detailed Description . . . . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/UDPlib.c File Reference 7.6.1 Detailed Description . . . . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/WFlib.c File Reference . 7.7.1 Detailed Description . . . . . . . . . . . . . . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

43 43 43 43 44 44 44

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

Chapter 1

OpenPicus
OpenPicus is open source Hardware and Software wireless project to enable Smart Sensors and Internet of Things. Hardware platform: its modular, the Modules are PICUSes while the Carrier Boards are their NESTs Wireless: Wi-Fi or Bluetooth. You have full control of the Stack and power down modes. Software Framework: your Apps can control the functions of the Protocol Stack, but you dont need to be an expert of it. Development tool: free IDE is ready to let you start development immediately. Serial Bootloader: Brutus loaded on modules, you dont need a programmer Flyport is the rst OpenPicus device, embedding the TCP/IP and WiFi stack for wireless communication with 802.11 devices. The Flyport also includes a real time operating system (FreeRTOS - www.freertos.org) to manage easily the TCP/IP stack and the user application in two different tasks.

Authors Gabriele Allegria Claudio Carnevali Special thanks to Andrea Seraghiti for the support in development.

OpenPicus

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

Chapter 2

Module Index
2.1 Modules

Here is a list of all modules: System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Delays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ARPlib stack . FTPlib stack . SMTPlib stack TCPlib stack . UDPlib stack . WiFi . . . . . ADC . GPIOs UART PWM . I2C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 11 12 23 25 29 31 14 15 17 19 21 Net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Module Index

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

Chapter 3

Data Structure Index


3.1 Data Structures

Here are the data structures with brief descriptions: tWFNetwork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Data Structure Index

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

Chapter 4

File Index
4.1 File List

Here is a list of all documented les with brief descriptions: C:/openpicus/X Release 2.0/Flyport libs/ARPlib.c (ARP wrapper for FreeRTOS ) C:/openpicus/X Release 2.0/Flyport libs/FTPlib.c (FTP wrapper for FreeRTOS ) C:/openpicus/X Release 2.0/Flyport libs/HWlib.c (Hardware library to manage the analog and digital IOs and UART ) . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/SMTPlib.c (SMTP wrapper for FreeRTOS ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/TCPlib.c (TCP wrapper for FreeRTOS ) C:/openpicus/X Release 2.0/Flyport libs/UDPlib.c (UDP wrapper for FreeRTOS ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/WFlib.c (Function to manage to Wi module and to change at runtime the network settings ) . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/Include/ARPlib.h . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/Include/FTPlib.h . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/Include/HWlib.h . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/Include/HWmap.h . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/Include/SMTPlib.h . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/Include/TCPlib.h . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/Include/UDPlib.h . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport libs/Include/WFlib.h . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport/HTTPPrint.h . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport/taskFlyport.h . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport/taskTCPIP.h . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport/TCPIPCong.h . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport/WF Cong.h . . . . . . . . . . . . . . . . C:/openpicus/X Release 2.0/Flyport/WF Events.h . . . . . . . . . . . . . . . . 41 41 42 42 43 43 44 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??

File Index

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

Chapter 5

Module Documentation
5.1 Delays

Functions
void vTaskDelay (int delay) void DelayMs (WORD ms) void DelayUs (WORD ms) void vTaskSuspendAll () void xTaskResumeAll ()

5.1.1

Detailed Description

In this section are explained all the commands to manage delays and task execution.

5.1.2 5.1.3
5.1.3.1

Delays Function Documentation


void DelayMs ( WORD ms )

DelayMs - Introduces a delay inside the execution of the rmware. Parameters delay - time to delay expressed in 1ms. DelayMS(100) = delay of 0.1 second.

Returns None

10 Warning

Module Documentation

this command can assure a real delay ONLY if included inside a critical section.

5.1.3.2

void DelayUs ( WORD ms )

Delay10us - Introduces a delay inside the execution of the rmware. Parameters delay - time to delay expressed in 10 microseconds. Delay10us(100) = delay of 1 millisecond. Returns None Warning this command can assure a real delay ONLY if included inside a critical section.

5.1.3.3

void vTaskDelay ( int delay )

vTaskDelay - Delays the Flyport task and executes the TCP task. This delay is the preferred way to delay the task, because optimizes the time the microcontroller dedicates to any task. Parameters delay - time to delay expressed in 10ms. vtaskDelay(100) = delay of one second. Returns None

5.1.3.4

void vTaskSuspendAll ( )

vTaskSuspendAll - this function suspend any other working task on the Flyport. So enters in the such called critical section. The OS resident in the Flyport can accomplish different tasks (in particular, your task and the task with the TCP/IP and WiFi stack), but if you want to execute ONLY your Task, you must enter into the critical section. Parameters None

Returns None
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.2 ARPlib stack Warning

11

when inside the crtitical section, the stack will not work, so use it with caution. It can be useful if you have some time critical operation to do, or some delay you must strict respect. Once you issue this command you MUST ALWAYS exit from the critical section. Otherwise, the WiFi will stop working.

5.1.3.5

void xTaskResumeAll ( )

xTaskResumeAll - exits from the critical section. Parameters None Returns None

5.2

ARPlib stack

Functions
BYTE ARPResolveMAC (char ipaddr[ ])

5.2.1

Detailed Description

ARP provides the commands to manage ARP-IP association. With ARPResolveMAC is possible to force an arp request, but usually this operation in managed by TCP-IP Stack.

5.2.2 5.2.3
5.2.3.1

ARP library Function Documentation


BYTE ARPResolveMAC ( char ipaddr[ ] )

ARPResolveMAC - Force an arp request for specic IP address Parameters ipaddr IP address

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

12

Module Documentation

5.3

FTPlib stack

Functions
TCP_SOCKET FTPClientOpen (char ftpaddr[ ], char ftpport[ ]) void FTPRead (TCP_SOCKET ftpsockread, char ftpreadch[ ], int ftprlen) WORD FTPWrite (TCP_SOCKET ftpsockwr, BYTE ftpstrtowr, int ftpwlen) void FTPClose (TCP_SOCKET Sockclose) BOOL FTPisConn (TCP_SOCKET sockcon) WORD FTPRxLen (TCP_SOCKET ftpsocklen)

5.3.1

Detailed Description

FTP provides Internet communication abilities.

5.3.2 5.3.3
5.3.3.1

library Function Documentation


TCP SOCKET FTPClientOpen ( char ftpaddr[ ], char ftpport[ ] )

FTPClientOpen - Creates a FTP client on specied IP address and port Parameters ftpaddr - IP address of the remote server. Example: "192.168.1.100" (the char array must be NULL terminated). ftpport - Port of the remote server to connect. Example: "1234" (the char array must be NULL terminated). Returns - INVALID_SOCKET: the operation was failed. Maybe there are not available sockets. - A TCP_SOCKET handle to the created socket. It must be used to access the socket in the program (read/write operations and close socket).

5.3.3.2

void FTPClose ( TCP SOCKET Sockclose )

FTPClose - Closes the client socket specied by the handle. Parameters Sockclose - The handle of the socket to close (the handle returned by the command FTPClientOpen).

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.3 FTPlib stack Returns None.

13

5.3.3.3

BOOL FTPisConn ( TCP SOCKET sockcon )

FTPisConn - Veries the connection of a remote FTP device with the socket. Parameters sockcon - The handle of the socket to control (the handle returned by the command FTPOpen). Returns TRUE - The remote connection is established. FALSE - The remote connection is not established.

5.3.3.4

void FTPRead ( TCP SOCKET ftpsockread, char ftpreadch[ ], int ftprlen )

FTPRead - Reads the specied number of characters from a FTP socket and puts them into the specied char array Parameters ftpsockread - The handle of the socket to read (the handle returned by the command FTPClientOpen). ftpreadch - The char array to ll with the read characters. ftprlen - The number of characters to read. Warning The length of the array must be AT LEAST = ftprlen+1, because at the end of the operation the array its automatically NULL terminated (is added the \0 character). Returns None.

5.3.3.5

WORD FTPRxLen ( TCP SOCKET ftpsocklen )

FTPRxLen - Veries how many bytes can be read from the specied FTP socket. Parameters ftpsocklen - The handle of the socket to control (the handle returned by the command FTPOpen).

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

14 Returns The number of bytes available to be read.

Module Documentation

5.3.3.6

WORD FTPWrite ( TCP SOCKET ftpsockwr, BYTE ftpstrtowr, int ftpwlen )

FTPWrite - Writes an array of characters on the specied socket. Parameters ftpsockwr - The socket to which data is to be written (its the handle returned by the command TCPClientOpen or TCPServerOpen). ftpstrtowr - Pointer to the array of characters to be written. ftpwlen - The number of characters to write. Returns The number of bytes written to the socket. If less than ftpwlen, the buffer became full or the socket is not conected.

5.4

ADC

Functions
void ADCInit () int ADCVal (int ch)

5.4.1

Detailed Description

The ADC library contains the command to manage the ADC, so its possible to easy convert an analog voltage value. The precision of the ADC is 10 bit.

5.4.2
5.4.2.1

Function Documentation
void ADCInit ( )

ADCInit - initializes the ADC module with default values. NOTE: this function is already called at Flyport startup. Parameters None

Returns None

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.5 GPIOs

15

5.4.2.2

int ADCVal ( int ch )

ADCVal - Reads the value of the analog channel specied. Parameters ch - the number of the analog channel to read. For the number of the channel, refer to the Flyport pinout. Returns the value read by the function.

5.5

GPIOs

Functions
void IOPut (int io, int putval) void IOInit (int io, int putval) int IOGet (int io) int IOButtonState (int io)

5.5.1

Detailed Description

The GPIOs commands can be used the manage the IO pins, to congure, to change or to read their values.

5.5.2
5.5.2.1

Function Documentation
int IOButtonState ( int io )

IOButtonState - Polls for the state of the button implemented on the specied pin. This command doesnt return the voltage level of the pin, but if the button has been pressed or released. No problem with the "debounce" of the button. It doesnt matter if the button is implemented with a "low logic" or "high logic". You just have to initialize the pin like "inup" or "indown". Parameters io - the pin to read.

Returns pressed: if the button has been pressed. released: if the button has been released.

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

16

Module Documentation

5.5.2.2

int IOGet ( int io )

IOGet - Reads the value of the specied pin. Parameters io - the pin to read. Returns the value read by the function.

5.5.2.3

void IOInit ( int io, int putval )

IOInit - Initializes the specied pin like output, input, input with pull-up or pull-down resistor. Parameters io - species the pin. putval - species how the pin must be initialized. The valid parameters are the following: in (or IN) input pin. inup (or INUP) input pin with pullup resistor (about 5 KOhm). indown (or INDOWN) input pin with pulldown resistor (about 5 Kohm). out (or OUT) output pin.

Returns None

5.5.2.4

void IOPut ( int io, int putval )

IOPut - Puts the putval value on the specied IO output pin. Parameters io - species the ouput pin. putval - the value to assign to the pin: on (or ON, or 1) high level (about 3.3V). off (or OFF, or 0) low level (0V).

Returns None
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.6 UART

17

5.6

UART

Functions
void UARTInit (int port, long int baud) void UARTOn (int port) void UARTOff (int port) void UARTFlush (int port) int UARTBufferSize (int port) int UARTRead (int port, char towrite, int count) void UARTWrite (int port, char buffer) void UARTWriteCh (int port, char chr)

5.6.1

Detailed Description

The UART section provides serial communication. The yport implements a buffer of 256 characters for the UART, to make serial communicate easier.

5.6.2
5.6.2.1

Function Documentation
int UARTBufferSize ( int port )

UARTBufferSize - Returns the RX buffer size of the specied UART port. Parameters port - the UART port to read. Returns the number of characters that can be read from the specied serial port.

5.6.2.2

void UARTFlush ( int port )

UARTFlush - Flushes the buffer of the specied UART port. Parameters port - the UART port to ush.

Returns None

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

18

Module Documentation

5.6.2.3

void UARTInit ( int port, long int baud )

UARTInit - Initializes the specied uart port with the specied baud rate. Parameters port - the UART port to initialize. Note: at the moment the Flyport Framework supports just one UART, but the hardware allows to create up to four UARTs. Others will be added in next release, however is possible to create them with standard PIC commands. baud - the desired baudrate. Returns None

5.6.2.4

void UARTOff ( int port )

UARTOff - Turns off the specied UART port. Parameters port - the UART port to turn off. Returns None

5.6.2.5

void UARTOn ( int port )

UARTOn - After the initialization, the UART must be turned on with this command. Parameters port - the UART port to turn on. Returns None

5.6.2.6

int UARTRead ( int port, char towrite, int count )

UARTRead - Reads characters from the UART RX buffer and put them in the char pointer "towrite" . Also returns the report for the operation. Parameters port - the UART port to read. towrite - the char pointer to ll with the read characters. count - the number of characters to read
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.7 PWM Returns the report for the operation: N>0: N characters correctly read. N<0: N characters read, but buffer overow detected. Warning The output of this function is changed between IDE 1.0 and IDE 2.0

19

5.6.2.7

void UARTWrite ( int port, char buffer )

UARTWrite - writes the specied string on the UART port. Parameters port - the UART port to write to. buffer - the string to write (a NULL terminated char array). Returns None

5.6.2.8

void UARTWriteCh ( int port, char chr )

UARTWriteCh - writes a single character on the UART port. Parameters port - the UART port to write to. char - the char to write.

Returns None

5.7

PWM

Functions
void PWMInit (BYTE pwm, oat freq, oat dutyc) void PWMOn (BYTE io, BYTE pwm) void PWMDuty (oat duty, BYTE pwm) void PWMOff (BYTE pwm)
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

20

Module Documentation

5.7.1

Detailed Description

With the PWM library is possible to easily manage up to nine different PWM (different frequency and duty cycle). To use the PWM on a pin you rst have to initialize the PWM, then assign it to the desired pin. At runtime it possible to change the duty cycle of the PWM. NOTE :it possible to assign a PWM to any pin, also to the input pins.

5.7.2
5.7.2.1

Function Documentation
void PWMDuty ( oat duty, BYTE pwm )

PWMDuty - changes the duty cycle of the PWM without turning it off. Useful for motors or dimmers. Parameters duty - new duty cycle desired (0-100). pwm - PWM number previously dened in PWMInit. Returns None

5.7.2.2

void PWMInit ( BYTE pwm, oat freq, oat dutyc )

PWMInit - initializes the specied PWM with the desired frequency and duty cycle . Parameters freq - frequency in hertz. dutyc - ducty cycle for the PWM in percent (0-100). Returns None

5.7.2.3

void PWMOff ( BYTE pwm )

PWMOff - turns off the specied PWM. Parameters pwm - PWM number previously dened in PWMInit. Returns None

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.8 I2C

21

5.7.2.4

void PWMOn ( BYTE io, BYTE pwm )

PWMOn - turns on the specied PWM on the specied pin. Parameters io - pin to assign the PWM. pwm - PWM number previously dened in PWMInit. Returns None

5.8

I2C

Functions
void I2CInit (BYTE I2CSpeed) void I2CStart () void I2CRestart () void I2CStop () void I2CWrite (BYTE data) BYTE I2CRead (BYTE ack)

5.8.1

Detailed Description

The I2C library allows the user to communicate with external devices with I2C bus, like ash memories or sensors. The Flyport is initialized as I2C master.

5.8.2
5.8.2.1

Function Documentation
void I2CInit ( BYTE I2CSpeed )

I2CInit - Initializes the I2C module. Parameters I2CSpeed - can use HIGH_SPEED for 404K or use LOW_SPEED for 100K. Returns None Warning This function changed between IDE 1.0 and IDE 2.0. IDE 1.0 doesnt accept I2CSpeed parameter

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

22

Module Documentation

5.8.2.2

BYTE I2CRead ( BYTE ack )

I2CRead - Reads one byte from the data bus . Parameters None Returns None

5.8.2.3

void I2CRestart ( )

I2CRestart - Sends a repeated start sequence on the bus . Parameters None Returns None

5.8.2.4

void I2CStart ( )

I2CStart - Sends a start sequence on the bus. Parameters None Returns None

5.8.2.5

void I2CStop ( )

I2CStop - Stops the trasmissions on the bus. Parameters None

Returns None

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.9 SMTPlib stack

23

5.8.2.6

void I2CWrite ( BYTE data )

I2CWrite - writes one byte on the bus. Parameters None Returns None

5.9

SMTPlib stack

Functions
BOOL SMTPStart () void SMTPSetServer (int servparam, char parameld) void SMTPSetMsg (int msgparam, char mparameld) BOOL SMTPSend () BOOL SMTPBusy () BOOL SMTPStop ()

5.9.1

Detailed Description

The SMTP commands allows to set the parameters for the SMTP connection, and to send emails from the Flyport.

5.9.2
5.9.2.1

Function Documentation
BOOL SMTPBusy ( )

SMTPBusy - Veries if the SMTP client is busy perfoming some action. Until the client is busy is not possible to other SMTP commands. Parameters None

Returns TRUE: the client is busy. FALSE: the client is not performing any action, and can be used by the rmware.

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

24

Module Documentation

5.9.2.2

BOOL SMTPSend ( )

SMTPSend - Once all the connection and message settings are done, its possible to send the desired email message with this command Parameters None Returns TRUE: the message was correctly sent. FALSE: there was an error. Maybe the SMTP client is still busy in sending another message, or its not initialized.

5.9.2.3

void SMTPSetMsg ( int msgparam, char mparameld )

SMTPSetMsg - Sets all the parameters for the email message to send (the sender, the destination address, the cc and bcc addresses, email subject and body). Parameters msgparam the parameter to set. Available list is the following: MSG_TO: the destination address. MSG_CC: the cc address.</L1> MSG_BCC: the bcc address.</L1> MSG_FROM: the sender of the email message.</L1> MSG_SUBJECT: the object of the email message.</L1> MSG_BODY: the body of the email message.</L1> mparameld a string containing the associated value to the parameter. For example: if we want to send a message to [email protected]. SMTPSetMsg(MSG_TO , "[email protected]") Returns None.

5.9.2.4

void SMTPSetServer ( int servparam, char parameld )

SMTPSetServer - Sets all the parameters for the SMTP remote server (server name, username, password and port). Parameters

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.10 TCPlib stack

25

servparam the parameter to set. Available list is the following: SERVER_NAME: the name of the SMTP server. SERVER_USER: the username for access to the server.</L1> SERVER_PASS: the password associated to the username.</L1> SERVER_PORT: the port of the SMTP server.</L1> parameld a string containing the associated value to the parameter (server name, username, password or SMTP port). For example: SMTPSetServer(SERVER_NAME , "smtp.serverxyz.com") Returns None.

5.9.2.5

BOOL SMTPStart ( )

SMTPStart - Initializes the SMTP module. If the client is already in use, the initialization will not be possible. Parameters None Returns TRUE: the SMTP client was correctly initialized. FALSE: the SMTP client wasnt initialized. Maybe its already used

5.9.2.6

BOOL SMTPStop ( )

SMTPStop - Closes the SMTP client. To use it again must restart it. Parameters None Returns TRUE: the client correctly closed. FALSE: an error occured closing the client.

5.10

TCPlib stack

Functions
void TCPServerDetach (TCP_SOCKET sockdet)
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

26

Module Documentation

TCP_SOCKET TCPClientOpen (char tcpaddr[ ], char tcpport[ ]) TCP_SOCKET TCPServerOpen (char tcpport[ ]) void TCPRead (TCP_SOCKET socktoread, char readch[ ], int rlen) WORD TCPWrite (TCP_SOCKET socktowrite, char writech, int wlen) void TCPClientClose (TCP_SOCKET Sockclose) void TCPServerClose (TCP_SOCKET Sockclose) BOOL TCPisConn (TCP_SOCKET sockconn) WORD TCPRxLen (TCP_SOCKET socklen)

5.10.1

Detailed Description

The TCP library contains all the command to manage the TCP sockets. If you need to use a TCP client or server inside your application, this is the correct section.

5.10.2 5.10.3
5.10.3.1

library Function Documentation


void TCPClientClose ( TCP SOCKET Sockclose )

TCPClientClose - Closes the client socket specied by the handle. Parameters Sockclose - The handle of the socket to close (the handle returned by the command TCPClientOpen). Returns None.

5.10.3.2

TCP SOCKET TCPClientOpen ( char tcpaddr[ ], char tcpport[ ] )

TCPClientOpen - Creates a TCP client on specied IP address and port Parameters tcpaddr - IP address of the remote server. Example: "192.168.1.100" (the char array must be NULL terminated). tcpport - Port of the remote server to connect. Example: "1234" (the char array must be NULL terminated). Returns - INVALID_SOCKET: the operation was failed. Maybe there are not available sockets. - A TCP_SOCKET handle to the created socket. It must be used to access the socket in the program (read/write operations and close socket).
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.10 TCPlib stack

27

5.10.3.3

BOOL TCPisConn ( TCP SOCKET sockconn )

TCPisConn - Veries the connection of a remote TCP device with the socket. It can be useful to catch an incoming new connection to a TCP server. Parameters sockconn - The handle of the socket to control (the handle returned by the command TCPServerOpen). Returns TRUE - The remote connection is established. FALSE - The remote connection is not established.

5.10.3.4

void TCPRead ( TCP SOCKET socktoread, char readch[ ], int rlen )

TCPRead - Reads the specied number of characters from a TCP socket and puts them into the specied char array Parameters socktoread - The handle of the socket to read (the handle returned by the command TCPClientOpen or TCPServerOpen). readch - The char array to ll with the read characters. rlen - The number of characters to read. Warning The length of the array must be AT LEAST = rlen+1, because at the end of the operation the array its automatically NULL terminated (is added the \0 character). Returns None.

5.10.3.5

WORD TCPRxLen ( TCP SOCKET socklen )

TCPRxLen - Veries how many bytes can be read from the specied TCP socket. Parameters socklen - The handle of the socket to control (the handle returned by the command TCPClientOpen or TCPServerOpen).

Returns The number of bytes available to be read.

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

28

Module Documentation

5.10.3.6

void TCPServerClose ( TCP SOCKET Sockclose )

TCPServerClose - Closes the server socket specied and destroys the handle. Any remote client connected with the server will be disconnected. Parameters Sockclose - The handle of the socket to close (the handle returned by the command TCPServerOpen). Returns None.

5.10.3.7

void TCPServerDetach ( TCP SOCKET sockdet )

TCPServerDetach - Detaches the remote client from the server Parameters sockdet - Socket of the server (the handle returned by the command TCPServerOpen). Returns None

5.10.3.8

TCP SOCKET TCPServerOpen ( char tcpport[ ] )

TCPServerOpen - Creates a TCP server on specied port Parameters tcpport - Number of the port for the server. Example: "1234" (the array must be NULL terminated). Returns - INVALID_SOCKET: the operation was failed. Maybe there are not available sockets. - A TCP_SOCKET handle to the created socket. It must be used to access the socket in the program (read/write operations and close socket).

5.10.3.9

WORD TCPWrite ( TCP SOCKET socktowrite, char writech, int wlen )

TCPWrite - Writes an array of characters on the specied socket. Parameters

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.11 UDPlib stack

29

socktowrite - The socket to which data is to be written (its the handle returned by the command TCPClientOpen or TCPServerOpen). writech - Pointer to the array of characters to be written. wlen - The number of characters to write. Returns The number of bytes written to the socket. If less than len, the buffer became full or the socket is not conected.

5.11

UDPlib stack

Functions
BYTE UDPServerOpen (char udpport[ ]) BYTE UDPClientOpen (char udpaddr, char udpport[ ]) BYTE UDPBroadcastOpen (char udpport[ ]) BYTE UDPServerClose (BYTE sock) BYTE UDPClientClose (BYTE sock) WORD UDPRxLen (BYTE sock) int UDPRead (BYTE sock, char str2rd[ ], int lstr) WORD UDPWrite (BYTE sockwr, BYTE str2wr, int lstr)

5.11.1

Detailed Description

UDP provides the commands to manage UDP connections. Flyport supports the creation of two different UDP socket, with their own RX buffer.

5.11.2 5.11.3
5.11.3.1

UDP library Function Documentation


BYTE UDPBroadcastOpen ( char udpport[ ] )

UDPBroadcastOpen - Create a UDP broadcast on specied port Parameters udpport Remote Port for UDP

Returns The number of current socket or 0 if an error occured during the opening of the socket.

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

30

Module Documentation

5.11.3.2

BYTE UDPClientClose ( BYTE sock )

UDPClientClose - Closes UDP Client socket Parameters sock UDP Socket number

5.11.3.3

BYTE UDPClientOpen ( char udpaddr, char udpport[ ] )

UDPClientOpen - Create a UDP client on specied port, try more time for arp request. Parameters udpaddr IP address of server udpport Remote Port of UDP server Returns The number of current socket or 0 if an error occured during the opening of the socket.

5.11.3.4

int UDPRead ( BYTE sock, char str2rd[ ], int lstr )

UDPRead - Reads a byte from the RX buffer Parameters sock UDP socket number str2rd Buffer for data lstr lenght of string Returns The number of read characters from the specied UDP socket.

5.11.3.5

WORD UDPRxLen ( BYTE sock )

UDPRxLen - Reads the length of the RX buffer Parameters sock UDP socket number

Returns The number of char that can be read from the UDP buffer.

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.12 WiFi

31

5.11.3.6

BYTE UDPServerClose ( BYTE sock )

UDPServerClose - Closes UDP Server socket Parameters sock UDP Socket number

5.11.3.7

BYTE UDPServerOpen ( char udpport[ ] )

UDPServerOpen - Create a UDP server on specied port Parameters udpport Local Port for UDP server Returns The number of current socket, or 0 if an error occured during the opening of the socket.

5.11.3.8

WORD UDPWrite ( BYTE sockwr, BYTE str2wr, int lstr )

UDPWrite - Writes on the UDP socket Parameters sockwr UDP socket number str2wr String to write lstr String lenght Returns The number of write characters to the specied UDP socket.

5.12

WiFi

Functions
void WFGeneric (int function) void WFConnect (int pconn) void WFDisconnect () void WFScan () void WFCustomSave () void WFCustomDelete () BOOL WFCustomExist () void WFCustomLoad ()
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

32

Module Documentation

tWFNetwork WFScanList (int ntscn) void WFSetParam (int paramtoset, char paramstring) void WFStopConnecting () void WFSetSecurity (BYTE mode, char keypass, BYTE keylen, BYTE keyind) void WFHibernate () void WFPsPollEnable (BOOL ps_active)

5.12.1

Detailed Description

Introduction The WiFi library contains all the functions to manage the WiFi stack. Its possible to connect or disconnect from a network, change the settings, and save them inside the falsh memory of the device, to recall at the startup.

Connection proles A connection prole contains all the information to connect to or to create a WiFi network. The Flyport module has two possible prole to use: WF_DEFAULT: contains all the values set in the IDE, with the TCP/IP Setup. WF_CUSTOM: its the customizable prole. The user can change any parameter and save them in the ash memory of the Flyport. At the device startup it is the same of WF_DEFAULT

5.12.2
5.12.2.1

Function Documentation
void WFConnect ( int pconn )

WFConnect - Veries how many bytes can be read from the specied TCP socket. Parameters pconn - Species the prole used to connect to the network. The following prole are available: WF_DEFAULT : uses the settings choosen in the IDE TCP/IP setup. This prole cannot be changed. WF_CUSTOM : this prole can be customized by the user and even saved in the ash memory. At the startup is identical to the default, but you can change it anytime you want. Returns None

5.12.2.2

void WFCustomDelete ( )

WFCustomDelete - Deletes the custom settings for the network prole WF_CUSTOM.
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.12 WiFi Parameters None Returns None

33

5.12.2.3

BOOL WFCustomExist ( )

WFCustomExist - Veries if in memory is present some data for the WF_CUSTOM prole. It can be useful at the startup of the device, because its possible to control if in a previous session (before any power off)has been saved some conguration data. Parameters None Returns FALSE: no data present. TRUE: valid data present.

5.12.2.4

void WFCustomLoad ( )

WFCustomLoad - Loads from the ash memory the previously set parameters for the WF_CUSTOM prole. Parameters None Returns None

5.12.2.5

void WFCustomSave ( )

WFCustomSave - When the Flyport is powered down, all the changes on the WF_CUSTOM prole will be lost, because are stored in RAM. To prevent the loosing of all the data, you can use the command WFCustomSave. It saves all the network parameters for the WF_CUSTOM connection prole. No need to set anything, the data will be saved in a reserved part of the ash memory, so will be available also if you power off the Flyport. Parameters None

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

34 Returns None

Module Documentation

5.12.2.6

void WFDisconnect ( )

WFDisconnect - Disconnects the device from the network. No parameters required. Parameters None Returns None

5.12.2.7

void WFHibernate ( )

WFHibernate - Enables Hibernate mode on the MRF24WB0M, which effectively turns off the device for maximum power savings. At the moment to exit from hybernate state a Reset() is nedded. Parameters None Returns None

5.12.2.8

void WFPsPollEnable ( BOOL ps active )

WFPsPollEnable - Enables or Disable Power-Save Pool at runtime Parameters ps_active TRUE to enable Poll mode for longer battery life or FALSE to disable PS Poll mode, MRF24WB0M will stay active and not go sleep. Returns None

5.12.2.9

void WFScan ( )

WFScan - Starts a scan to detect all the WiFi networks available. The function doesnt return anything. When it has nished, it generates an event, you can catch in the WiFi events le.
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.12 WiFi Parameters None Returns

35

None. The number of the retrieved WiFi networks found is passed in the function WF_events like an "event info". All the data for the retrieved networks can be accessed with the command WFScanList. Attention The command must be issued when the device is not connected to any network, otherwise it wont give any error message, but it wont work.

5.12.2.10

tWFNetwork WFScanList ( int ntscn )

WFScanList - This command must be issued after a WFScan request has been completed (so the event is generated). The WFScan command returns in the event handler the number of the WiFi networks found, but all the data related to the networks, can be accessed using the function WFScanList. Parameters ntscn - number of the wi network (1 to number of the found networks). Returns A tWFNetwork structure, which contains all the informations about the specied network. Warning The function cant be called inside the WiFi Event handler. You always must call it from the FlyportTask.

5.12.2.11

void WFSetParam ( int paramtoset, char paramstring )

WFSetParam - With this command is possible to change any network parameter of the WF_CUSTOM prole. Parameters paramtoset - the parameter to change. paramstring - value of the parameter. Returns None. Sintax of the command to set the parameters:
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

36

Module Documentation

IP address of the device: WFSetParam(MY_IP_ADDR , string with the IP address, for example "192.168.1.100") Primary DNS server: WFSetParam(PRIMARY_DNS , string with the IP address, for example "192.168.1.1") Secondary DNS server: WFSetParam(SECONDARY_DNS , string with the IP address, for example "192.168.1.1") Default gateway: WFSetParam(MY_GATEWAY , string with the IP address, for example "192.168.1.1") Subnet mask: WFSetParam(SUBNET_MASK , string with the subnet mask, for example "255.255.255.0") Netbios name: WFSetParam(NETBIOS_NAME , string with the Netbios name, for example "Flyport") SSID: WFSetParam(SSID_NAME , string with the SSID name, for example "FlyportNet") DHCP client enabled or not: WFSetParam(DHCP_ENABLE , ENABLED or DISABLED) Network type (adhoc or infrastructure): WFSetParam(NETWORK_TYPE , ADHOC or INFRASTRUCTURE)

5.12.2.12

void WFSetSecurity ( BYTE mode, char keypass, BYTE keylen, BYTE keyind )

WFSetSecurity - This command is used to set all the security parameters for the WF_CUSTOM connection prole Parameters mode - the security mode. Valid security mode are the following: WF_SECURITY_OPEN: no security. WF_SECURITY_WEP_40: WEP security, with 40 bit key. WF_SECURITY_WEP_104: WEP security, with 104 bit key. WF_SECURITY_WPA_WITH_KEY: WPA-PSK personal security, the user species the hex key. WF_SECURITY_WPA_WITH_PASS_PHRASE: WPA-PSK personal security, the user species only the passphrase. WF_SECURITY_WPA2_WITH_KEY: WPA2-PSK personal security, the user species the hex key. WF_SECURITY_WPA2_WITH_PASS_PHRASE:WPA2-PSK personal security, the user species only the passphrase. WF_SECURITY_WPA_AUTO_WITH_KEY: WPA-PSK personal or WPA2-PSK personal (the Flyport will auto select the mode) with hex key. WF_SECURITY_WPA_AUTO_WITH_PASS_PHRASE: WPA-PSK personal or WPA2-PSK personal (autoselect) with pass phrase.

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

5.13 System

37

keypass - the key or passphrase for the network. A key must be specied also for open connections (you can put a blank string, like ""). keylen - length of the key/passphrase. Must be specied also for open connections (can be 0). keyind - index of the key (used only for WEP security, but must be specied also for all others, in that case, can be 0). Attention For WPA/WPA2 with passphrase, the Flyport must calculate the hex key. The calculation is long and difcult, so it will take about 20 seconds to connect! Returns None.

5.12.2.13

void WFStopConnecting ( )

WFStopConnecting - When the command WFConnect is lauched, the device tries to connect to the selected WiFi network until it doesnt nd it. If you want to stop the retries, you have to issu the command WFStopConnecting. Parameters None Returns None

5.13

System

Modules
Delays

5.14

Net

Modules
ARPlib stack FTPlib stack SMTPlib stack TCPlib stack UDPlib stack WiFi

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

38

Module Documentation

5.15

Hardware

Modules
ADC GPIOs UART PWM I2C

Functions
void HWInit (int conf)

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

Chapter 6

Data Structure Documentation


6.1 tWFNetwork Struct Reference

Data Fields
BYTE bssid [WF_BSSID_LENGTH] char ssid [WF_MAX_SSID_LENGTH+1] UINT8 channel UINT8 signal BYTE security BYTE type UINT8 beacon UINT8 preamble

The documentation for this struct was generated from the following le: C:/openpicus/X Release 2.0/Flyport libs/Include/WFlib.h

40

Data Structure Documentation

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

Chapter 7

File Documentation
7.1 C:/openpicus/X Release 2.0/Flyport libs/ARPlib.c File Reference

ARP wrapper for FreeRTOS.

Functions
BYTE ARPResolveMAC (char ipaddr[ ])

7.1.1

Detailed Description

ARP wrapper for FreeRTOS.

7.2

C:/openpicus/X Release 2.0/Flyport libs/FTPlib.c File Reference

FTP wrapper for FreeRTOS.

Functions
TCP_SOCKET FTPClientOpen (char ftpaddr[ ], char ftpport[ ]) void FTPRead (TCP_SOCKET ftpsockread, char ftpreadch[ ], int ftprlen) WORD FTPWrite (TCP_SOCKET ftpsockwr, BYTE ftpstrtowr, int ftpwlen) void FTPClose (TCP_SOCKET Sockclose) BOOL FTPisConn (TCP_SOCKET sockcon) WORD FTPRxLen (TCP_SOCKET ftpsocklen)

7.2.1

Detailed Description

FTP wrapper for FreeRTOS.

42

File Documentation

7.3

C:/openpicus/X Release 2.0/Flyport libs/HWlib.c File Reference

Hardware library to manage the analog and digital IOs and UART.

Functions
void ADCInit () int ADCVal (int ch) void IOPut (int io, int putval) void IOInit (int io, int putval) int IOGet (int io) int IOButtonState (int io) void UARTInit (int port, long int baud) void UARTOn (int port) void UARTOff (int port) void UARTFlush (int port) int UARTBufferSize (int port) int UARTRead (int port, char towrite, int count) void UARTWrite (int port, char buffer) void UARTWriteCh (int port, char chr) void PWMInit (BYTE pwm, oat freq, oat dutyc) void PWMOn (BYTE io, BYTE pwm) void PWMDuty (oat duty, BYTE pwm) void PWMOff (BYTE pwm) void I2CInit (BYTE I2CSpeed) void I2CStart () void I2CRestart () void I2CStop () void I2CWrite (BYTE data) BYTE I2CRead (BYTE ack) void HWInit (int conf)

7.3.1

Detailed Description

Hardware library to manage the analog and digital IOs and UART.

7.4

C:/openpicus/X Release 2.0/Flyport libs/SMTPlib.c File Reference

SMTP wrapper for FreeRTOS.


Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

7.5 C:/openpicus/X Release 2.0/Flyport libs/TCPlib.c File Reference

43

Functions
BOOL SMTPStart () void SMTPSetServer (int servparam, char parameld) void SMTPSetMsg (int msgparam, char mparameld) BOOL SMTPSend () BOOL SMTPBusy () BOOL SMTPStop ()

7.4.1

Detailed Description

SMTP wrapper for FreeRTOS.

7.5

C:/openpicus/X Release 2.0/Flyport libs/TCPlib.c File Reference

TCP wrapper for FreeRTOS.

Functions
void TCPServerDetach (TCP_SOCKET sockdet) TCP_SOCKET TCPClientOpen (char tcpaddr[ ], char tcpport[ ]) TCP_SOCKET TCPServerOpen (char tcpport[ ]) void TCPRead (TCP_SOCKET socktoread, char readch[ ], int rlen) WORD TCPWrite (TCP_SOCKET socktowrite, char writech, int wlen) void TCPClientClose (TCP_SOCKET Sockclose) void TCPServerClose (TCP_SOCKET Sockclose) BOOL TCPisConn (TCP_SOCKET sockconn) WORD TCPRxLen (TCP_SOCKET socklen)

7.5.1

Detailed Description

TCP wrapper for FreeRTOS.

7.6

C:/openpicus/X Release 2.0/Flyport libs/UDPlib.c File Reference

UDP wrapper for FreeRTOS.

Functions
BYTE UDPServerOpen (char udpport[ ]) BYTE UDPClientOpen (char udpaddr, char udpport[ ]) BYTE UDPBroadcastOpen (char udpport[ ])
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

44

File Documentation

BYTE UDPServerClose (BYTE sock) BYTE UDPClientClose (BYTE sock) WORD UDPRxLen (BYTE sock) int UDPRead (BYTE sock, char str2rd[ ], int lstr) WORD UDPWrite (BYTE sockwr, BYTE str2wr, int lstr)

7.6.1

Detailed Description

UDP wrapper for FreeRTOS.

7.7

C:/openpicus/X Release 2.0/Flyport libs/WFlib.c File Reference

Function to manage to Wi module and to change at runtime the network settings.

Functions
void WFGeneric (int function) void WFConnect (int pconn) void WFDisconnect () void WFScan () void WFCustomSave () void WFCustomDelete () BOOL WFCustomExist () void WFCustomLoad () tWFNetwork WFScanList (int ntscn) void WFSetParam (int paramtoset, char paramstring) void WFStopConnecting () void WFSetSecurity (BYTE mode, char keypass, BYTE keylen, BYTE keyind) void WFHibernate () void WFPsPollEnable (BOOL ps_active)

7.7.1

Detailed Description

Function to manage to Wi module and to change at runtime the network settings.

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

Index
FTPClose FTPlib, 12 FTPisConn FTPlib, 13 FTPlib FTPClientOpen, 12 FTPClose, 12 FTPisConn, 13 FTPRead, 13 FTPRxLen, 13 FTPWrite, 14 FTPlib stack, 12 FTPRead C:/openpicus/X Release 2.0/Flyport libs/ARPlib.c, FTPlib, 13 41 FTPRxLen C:/openpicus/X Release 2.0/Flyport libs/FTFTPlib, 13 Plib.c, 41 FTPWrite C:/openpicus/X Release 2.0/Flyport libs/HFTPlib, 14 Wlib.c, 42 C:/openpicus/X Release 2.0/Flyport libs/SMTGPIOs, 15 Plib.c, 42 IOButtonState, 15 C:/openpicus/X Release 2.0/Flyport libs/TCIOGet, 15 Plib.c, 43 IOInit, 16 C:/openpicus/X Release 2.0/Flyport libs/UDIOPut, 16 Plib.c, 43 Hardware, 38 C:/openpicus/X Release 2.0/Flyport libs/WFlib.c, 44 I2C, 21 I2CInit, 21 DelayMs I2CRead, 21 Delays, 9 I2CRestart, 22 Delays, 9 I2CStart, 22 DelayMs, 9 I2CStop, 22 DelayUs, 10 I2CWrite, 22 vTaskDelay, 10 I2CInit vTaskSuspendAll, 10 I2C, 21 xTaskResumeAll, 11 I2CRead DelayUs I2C, 21 Delays, 10 I2CRestart FTPClientOpen I2C, 22 I2CStart FTPlib, 12 ADC, 14 ADCInit, 14 ADCVal, 14 ADCInit ADC, 14 ADCVal ADC, 14 ARPlib ARPResolveMAC, 11 ARPlib stack, 11 ARPResolveMAC ARPlib, 11

46

INDEX

I2C, 22 I2CStop I2C, 22 I2CWrite I2C, 22 IOButtonState GPIOs, 15 IOGet GPIOs, 15 IOInit GPIOs, 16 IOPut GPIOs, 16 Net, 37 PWM, 19 PWMDuty, 20 PWMInit, 20 PWMOff, 20 PWMOn, 20 PWMDuty PWM, 20 PWMInit PWM, 20 PWMOff PWM, 20 PWMOn PWM, 20 SMTPBusy SMTPlib, 23 SMTPlib SMTPBusy, 23 SMTPSend, 23 SMTPSetMsg, 24 SMTPSetServer, 24 SMTPStart, 25 SMTPStop, 25 SMTPlib stack, 23 SMTPSend SMTPlib, 23 SMTPSetMsg SMTPlib, 24 SMTPSetServer SMTPlib, 24 SMTPStart SMTPlib, 25 SMTPStop SMTPlib, 25

System, 37 TCPClientClose TCPlib, 26 TCPClientOpen TCPlib, 26 TCPisConn TCPlib, 27 TCPlib TCPClientClose, 26 TCPClientOpen, 26 TCPisConn, 27 TCPRead, 27 TCPRxLen, 27 TCPServerClose, 27 TCPServerDetach, 28 TCPServerOpen, 28 TCPWrite, 28 TCPlib stack, 25 TCPRead TCPlib, 27 TCPRxLen TCPlib, 27 TCPServerClose TCPlib, 27 TCPServerDetach TCPlib, 28 TCPServerOpen TCPlib, 28 TCPWrite TCPlib, 28 tWFNetwork, 39 UART, 17 UARTBufferSize, 17 UARTFlush, 17 UARTInit, 17 UARTOff, 18 UARTOn, 18 UARTRead, 18 UARTWrite, 19 UARTWriteCh, 19 UARTBufferSize UART, 17 UARTFlush UART, 17 UARTInit UART, 17 UARTOff UART, 18
Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

INDEX

47

UARTOn UART, 18 UARTRead UART, 18 UARTWrite UART, 19 UARTWriteCh UART, 19 UDPBroadcastOpen UDPlib, 29 UDPClientClose UDPlib, 29 UDPClientOpen UDPlib, 30 UDPlib UDPBroadcastOpen, 29 UDPClientClose, 29 UDPClientOpen, 30 UDPRead, 30 UDPRxLen, 30 UDPServerClose, 30 UDPServerOpen, 31 UDPWrite, 31 UDPlib stack, 29 UDPRead UDPlib, 30 UDPRxLen UDPlib, 30 UDPServerClose UDPlib, 30 UDPServerOpen UDPlib, 31 UDPWrite UDPlib, 31 vTaskDelay Delays, 10 vTaskSuspendAll Delays, 10 WFConnect WiFi, 32 WFCustomDelete WiFi, 32 WFCustomExist WiFi, 33 WFCustomLoad WiFi, 33 WFCustomSave WiFi, 33

WFDisconnect WiFi, 34 WFHibernate WiFi, 34 WFPsPollEnable WiFi, 34 WFScan WiFi, 34 WFScanList WiFi, 35 WFSetParam WiFi, 35 WFSetSecurity WiFi, 36 WFStopConnecting WiFi, 37 WiFi, 31 WFConnect, 32 WFCustomDelete, 32 WFCustomExist, 33 WFCustomLoad, 33 WFCustomSave, 33 WFDisconnect, 34 WFHibernate, 34 WFPsPollEnable, 34 WFScan, 34 WFScanList, 35 WFSetParam, 35 WFSetSecurity, 36 WFStopConnecting, 37 xTaskResumeAll Delays, 11

Generated on Wed Apr 27 2011 17:38:46 for OpenPicus - Flyport by Doxygen

You might also like