Home
TK-850/SG2+UZ User`s Manual
Contents
1. API Specifications Chapter 4 4 1 6 4 1 7 Parameters I O Parameter struct netif netif Function Pointer to network information netif struct ip_addr ipadar Pointer to ip_addr where the modified IP address is stored struct ip_addr netmask Pointer to ip_addr where the modified subnet mask is stored struct ip_addr gw Pointer to ip_address where the modified gateway address is stored Functions Return values cnet_getipaddr Scope Format in C Parameters Modify the network information registered by netif_add to the IP address specified by ipaddr the subnet mask specified by netmask and the gateway address by gw Notes 1 The network interface information shall match the return value of the previous netif_add 2 Prior to this API netif_add has to be executed None Get IP address int cnet_getipadar struct netif netif I O Parameter Function struct netif netif Pointer to network information netif Functions Read out IP address which has been defined by netif_add or assigned after cnet_dhcpstart The returned IP address is in network byte order format Notes 1 The network interface information shall match the return value of the previous netif_add 2 Prior to this API netif_add or assignment of network information initiated by cnet_dhcpstart has to be executed
2. Parameters I O Parameter Function u32 tn 32 bit data in host byte order format User s Manual U19108EE1VOUMOO 25 Chapter 4 API Specifications 26 4 1 12 4 1 13 Functions Return values Convert 32 bit data in n from host byte order to network byte order format 32 bit data are returned in network byte order format Value Meaning Value 32 bit data are returned in network byte order format htons Scope Convert 16 bit data from host byte order to network Format in C Parameters byte order format u16_t htons u16_tn I O Parameter Function ul6 tn 16 bit data in host byte order format Functions Return values Convert 16 bit data in n from host byte order to network byte order format 16 bit data are returned in network byte order format Value Meaning Value 16 bit data are returned in network byte order format ntohl Scope Convert 32 bit data from network byte order to host Format in C Parameters byte order format u32_t ntohl u32_tn I O Parameter Function u32 tn 32 bit data in network byte order format Functions Return values Convert 32 bit data in n from network byte order to host byte order format 32 bit data are returned in host byte order format Value Meaning Value 32 bit data in host byte order format
3. Returns Value Meaning Value Normally completed with IP address in network byte order format cnet_getnetmask Scope Format in C Get subnet mask int cnet_getnetmask struct netif netif User s Manual U19108EE1VOUMOO 23 Chapter 4 API Specifications Parameters I O Parameter Function struct netif netif Pointer to network information netif Functions Read out subnet mask which has been defined by netif_add or assigned after cnet_dhcpstart The returned subnet mask is in network byte order format Notes 1 The network interface information shall match the return value of the previous netif_add 2 Prior to this API netif_add or assignment of network information initiated by cnet_dhcpstart has to be executed Returns Value Meaning Value Normally completed with subnet mask in network byte order format 4 1 8 cnet_getgwaddr Scope Get gateway address Format in C int cnet_getgwaddr struct netif netif Parameters I O Parameter Function struct netif netif Pointer to network information netif Functions Read out gateway address which has been defined by netif_add or assigned after cnet_dhcpstart The returned gateway address is in network byte order format Notes 1 The network interface information shall match the return value of the previous netif_add 2 Prior to this API net
4. User s Manual U19108EE1VOUMOO API Specifications Chapter 4 4 1 14 ntohs Scope Format in C Convert 16 bit data from network byte order to host byte order format u16_t ntohs u16_tn Parameters I O Parameter Function ul6 tn 16 bit data in network byte order format Functions Return values Convert 16 bit data in n from network byte order to host byte order format 16 bit data are returned in host byte order format Value Meaning Value 16 bit data are returned in host byte order format 4 2 Application layer API HTTP SMTP POP3 and DHCP 4 2 1 cnet_smtpinit Scope Format in C Parameters Initiate session with SMTP server int cnet_smtpinit unsigned int addr unsigned short port const char domain 1 0 Parameters Functions unsigned int addr IP address in network byte order format unsigned short port Port number in host byte order format Const char domain Functions Pointer to the memory domain name is stored Initiate session with SMTP server by sending HELO command and domain name to the port in the SMTP mail server specified by addr Notes 1 If 0x0 is found in the port number it is interpreted that the port number 25 is specified 2 This API is valid only if netif_set_default has assigned the default value or automatic assignment has been completed based on cne
5. Descriptions of circuits software and other related information in this document are provided for illustrative purposes in semiconductor product operation and application examples The incorporation of these circuits software and information in the design of a customer s equipment shall be done under the full responsibility of the customer NEC Electronics assumes no responsibility for any losses incurred by customers or third parties arising from the use of these circuits software and information e While NEC Electronics endeavors to enhance the quality reliability and safety of NEC Electronics products customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely To minimize risks of damage to property or injury including death to persons arising from defects in NEC Electronics products customers must incorporate sufficient safety measures in their design such as redundancy fire containment and anti failure features NEC Electronics products are classified into the following three quality grades Standard Special and Specific e The Specific quality grade applies only to NEC Electronics products developed based on a customer designated quality assurance program for a specific application The recommended applications of an NEC Electronics product depend on its quality grade as indicated below Customers must check the quality grade of each NEC Electronics product before using it
6. Device Driver Layer structure Network API Network API supports network configuration Application layer API Application Layer API supports HTTP POP3 SMTP and DHCP e HTTP C NET supports Hyper text transfer between Web server and Web client Therefore C NET enables for Web server to recognize and execute requests generated in Web clients e POP3 and SMTP C NET supports transmission and reception of e mail e DHCP User s Manual U19108EE1VOUMOO How to create your application Chapter 3 C NET can negotiate with Dynamic Host Configuration Protocol DHCP to acquire extend IP address subnet mask and gateway address 3 2 Steps to create your applications A flow chart to create user applications d Architecture Preparation of of the application Web contents Planning Please refer to API list and description Please refer to how to html create Web applications Registration to C source Compile and link Debug build or release build Download to Flash Figure 3 2 Creating user applications User s Manual U19108EE1VOUMOO 11 Chapter 3 How to create your application 12 3 2 1 Table 3 1 API list Network API Name of API Function cnet_init Initialization netif_add Add Network Information netif_remove Remove Network Information
7. 0 000 ccc ene ene 9 Chapter 3 How to create your application 10 3 1 OAT R EA A E A dd ed 10 3 1 1 NetworksAP liste A Meee CIM E T E 10 3 1 2 Application layer API 00 cece teens 10 3 2 Steps to create your applications ooooccccccccoocco eee 11 3 2 1 APM iii dies ai bb aa tia eae A AA da wees 12 3 3 How to program user application 0 000 ccc ete 14 3 3 1 How to use network API 0 600 ees 14 3 3 2 How to send receive e mail 0 cece eee teen eee nnnes 15 3 3 3 NN 15 3 4 How to create Web applications ooocooccccoocconc 16 3 4 1 IE E O raat 16 3 4 2 Note OREA A A A AS 17 3 4 3 Definition of method ocoocccccccoo eee ees 17 3 4 4 How to define user functions oocooccccccccocn nnne nnana 17 3 4 5 How to use the Web file registration tool makefsdata command 19 Chapter 4 API Specifications o ooooccccccccccccccccooo 21 4 1 Network API iiaii osin session ean Raed bene mena eee eel eden Reta 21 4 1 1 CNELANIETUNCTION tcc Bie scene A cae Maha tee bt ne renee i Pe eee 21 4 1 2 cnet add TUNCON 2 fcr eat ta Re Sete rd ae ae ee ate 21 4 1 3 Neti FEMOVE it A a ret teeta 22 4 1 4 netif_set_default 2 0 cece eee ees 22 4 1 5 Netitseteaddr e iii eae eA ee ee Pea ea a eG a eee a 22 4 1 6 CNet getipadar aise Adee chee eee cece keen 23 4 1 7 cnet_getnetMask cion ee eee ee ee eee eae ge dee eed 23 4 1 8 cnetcget
8. 3 3 3 output struct netif netif struct pbuf p struct ip_addr ipaddr Interface function to transmit data by TCP IP protocol stack is stored linkoutput struct netif netif struct pbuf p Interface function to transmit ARP data by TCP IP protocol stack is stored linkproc struct netif netif Pre occupied by system state Status information specified parameter when netif_add is issued is stored dhcp DHCP information acquired when cnet_dhcpstart is issued is stored hwaddr_len Size of Mac address stored in hwadadr is stored in byte hwaddr Mac address of the target system is stored mtu Pre occupied by system name Two bytes of ID of network interface is stored Network interface name in C NET is a concatenation of the two strings stored at NAME and NUM num Network interface number is stored flags Status flags of network interface are stored How to send receive e mail You can find an example at cnet src userap c of the sample program Caution Please do not touch or modify any file in cnet lib and cnet include directories If it is modified C NET will not work User s Manual U19108EE1VOUMOO 15 Chapter 3 How to create your application 3 4 How to create Web applications 3 4 1 Overview Planning and preparation of Web contents Create user defined functions Register the user defined functions to httpdfunc c Register CGI and h
9. O RETR command will be issued Otherwise TOP command will be issued 4 Information retrieved between this API and cnet_pop3getmsgend is interpreted as one mail 5 cnet_pop3auth has to be precedent to this API Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_GETEND No error End code was detected 0x1 or lines specified by maxline were retrieved POP3_ERROR_READ Oxffffffe0 POP3 server response timeout User s Manual U19108EE1VOUMOO API Specifications Chapter 4 Macro Value Meanings POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POPS server POPS server response error to POP3_ERROR_REPLY Oxfffffffc TOP or RETR command POP3_ERROR_STATE Oxfffffffe Wrong API sequence POP3_ERROR_PARAMETER Oxffffffff Illegal parameter 4 2 12 cnet_pop3getmsgnext Scope Format in C Parameters Continue reception of mail data int cnet_pop3getmsgnext char msgbuf unsigned short msglen unsigned char mode I O Parameters Functions O char msgbuf Pointer for the memory to store mail data unsigned short msglen Mail data size in bytes unsigned char mode Selection of receive mode POP3_MODE_TEXT Received line by line POP3_MODE_TRUNC Received line by line POP3_MODE_BINARY Received up to the size Functions Continue receiving the mail data after it has been initiated by cnet_pop3getmsgf
10. OxfffffffO Disconnected by POP3 server POP3_ERROR_REPLY Oxfffffffc pes once a to POP3_ERROR_STATE Oxfffffffe Wrong API sequence POP3_ERROR_PARAMETER Oxffffffff Illegal parameter cnet_pop3stat Scope Format in C Ask POP3 server to check mail status for the user int cnet_pop3stat unsigned int number unsigned int size Parameters I O Parameters Functions unsigned int number Pointer to number of spooled mails unsigned int size Pointer to the size of the spooled mails in byte Functions Send STAT command to the POP3 server This API is applied to the mails for the user specified in cnet_pop3auth Number of the spooled mail for the user is stored in number and the total size of the mails for the user is stored in size Notes 1 Spooled mails mean those mails undelivered to the user tentatively stored in the POP3 server 2 cnet_pop3auth has to be precedent to this API User s Manual U19108EE1VOUMOO API Specifications Chapter 4 Return values Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_READ Oxffffffe0 POP3 server response timeout POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POP3 server POP3_ERROR_REPLY oxfffffffe POP3 server response error to STAT command POP3_ERROR_STATE Oxfffffffe Wrong API sequence POP3_ERROR_PARAMETER Oxffffffff Illegal parameter 4 2 10 cnet_pop3gets
11. netif_set_default Set Default Network Information netif_set_addr Modify Network Information cnet_getipaddr Get IP address cnet_getnetmask Get subnet mask cnet_getgwaddr Get gateway address inet_addr Convert IP address from dot format to byte order format inet_ntoa Convert IP address to dot format from byte order format Convert 32 bit data from host byte order to network byte htonl order format Convert 16 bit data from host byte order to network byte htons order format Convert 32 bit data to host byte order from network byte ntohl order format ntohs Convert 16 bit data to host byte order from network byte order format Table 3 2 Application Layer API SMTP POP3 and HTTP Name of API Function SMTP cnet_smtpinit Initiate session with SMTP server cnet_smtpend Terminate session with SMTP server cnet_smtpdatafirst Initiate transmission of mail data cnet_smtpdatanext Transmission of mail text cnet_smtpdataend Terminate transmission of mail data POP3 cnet_pop3init Initiate session with POP3 server where mail is spooled cnet_pop3end Terminate session with POP3 server where mail is spooled cnet_pop3auth Send data for authentication to POP3 server cnet_pop3stat Ask POP3 server to check mail status for the user cnet_pop3getsize Ask POP3 server to check the mail size cnet_pop3getms
12. the memory where the mail is stored unsigned short msglen Size of the mail in bytes unsigned char mode Selection of receive mode POP3_MODE_TEXT Received line by line POP3_MODE_TRUNC Received line by line POP3_MODE_BINARY Received upto the size Functions Return values Send TOP command or RETR command to the POP3 server The mail specified by msgno is retrieved There are three operation modes POP3_MODE_TEXT The mail is retreived till LF or end code is detected Otherwise msglen is the maximum size to retrieve The mail is stored in the memory specified by msgbuf If the return value is 0x0 the rest of the mail text can be retrieved by issuing cnet_pop3getmsgnext POP3_MODE_TRUNC The mail is retreived till LF or end code is detected Otherwise msglen is the maximum size to retrieve The mail is stored in the memory specified by msgbuf If the return value is 0x0 the rest of the mail text can be retrieved from the next line by issuing cnet_pop3getmsgnext POP3_MODE_BINARY The mail is retreived till end code is detected Otherwise msglen is the maximum size to retrieve The mail is stored in the memory specified by msgbuf If the return value is 0x0 the rest of the mail text can be retrieved by issuing cnet_pop3getmsgnext Notes 1 The size of memory specified by msgbuf shall be msglen 1 bytes 2 If maxline is O all lines of the mail will be retrieved 3 If maxline is
13. to execute tasks in CGI you can define it by writing a definition of the function in httpd h and the mapping of function names and functions in the httpd_first structure You can call up the function if the function name is specified in CGI or data passed in the POST method User s Manual U19108EE1VOUMOO 17 Chapter 3 How to create your application 1 User defined functions Function A user defined function will be called up by specifying its function name in any of the following a parameter of the GET method data passed by the POST method or the c function execution command of CGI You can create user defined tonai in httpdsub c or in any other file 2 Format of user defined functions User defined functions have 3 parameters and the number and content of parameters are fixed First parameter int ID for HTTP server to manage Second parameter const char Function ID Third parameter const char Specified parameter for CGI or the received data for GET and POST method Format of cnet_httpd_datacmn cnet_httpd_datacmn is a function which is called up each time after the processing of data received in GET or POST method and has one parameter However it is not called up if no parameter is specified in GET method First parameter int ID for HTTP server to manage You can find some examples of implementation at cnet src httpdfunc c 3 Registration of user defined functions This is an example to register
14. 4 1 4 Return values Value Meaning Normally completed with the pointer to the network interface Any value A 4 information NULL Abnormal netif_ remove Scope Format in C Parameters Remove network information void netif_remove struct netif netif I O Parameters Functions struct netif netif Pointer to network interface information netif Functions Returns netif_set_default Scope Format in C Parameters I O Parameter This API erases the network information such as IP address subnet mask and gateway address Notes 1 The network interface information shall match the return value of the previous netif_add 2 Prior to this API netif_add has to be executed None Registration of default network information void netif_set_default struct netif netif Function struct netif netif Pointer to network information netif Functions Return values netif_set_addr Scope Format in C Network information sefined in netif is registered as default Notes 1 The network information registered shall be compatible with the return values in netif_add 2 Prior to this API netif_add has to be ececuted None Modification of network information void netif_set_adar struct netif netif struct ip_addr ipadar struct ip_addr netmask struct ip_addr gw User s Manual U19108EE1VOUMOO
15. NEC User s Manual TK 850 SG2 UZ ZigBee ready Wireless Networks to Ethernet Gateway V850ES 32 bit Microcontroller Evaluation Board Application Development Manual C NET API for HTTP SMTP POP3 and DHCP Document No U19108EE1VOUMOO Date published January 2008 O NEC Electronics 2008 Printed in Germany Legal Notes The information in this document is current as of November 2007 The information is subject to change without notice For actual design in refer to the latest publications of NEC Electronics data sheets or data books etc for the most up to date specifications of NEC Electronics products Not all products and or types are available in every country Please check with an NEC Electronics sales representative for availability and additional information No part of this document may be copied or reproduced in any form or by any means without the prior written consent of NEC Electronics NEC Electronics assumes no responsibility for any errors that may appear in this document NEC Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of NEC Electronics products listed in this document or any other liability arising from the use of such products No license express implied or otherwise is granted under any patents copyrights or other intellectual property rights of NEC Electronics or others
16. SEO et aia eid NS kee pct tied Rd aod acetal Ba 39 User s Manual U19108EE1VOUMOO 7 Chapter 1 Introduction C NET enables the TK 850 SG2 UZ board to offer TCP IP SMTP POP3 and HTTP functions This manual introduces you how to utilize these functions to develop your application software This manual does not provide with any information on IEEE 802 15 4 MAC stack and ZigBee because the wireless protocol is independent from C NET User s Manual U19108EE1VOUMOO Chapter 2 Preparations First of all the development environment is prepared in your PC 2 1 Installation of software When you installed a sample program for the TK 850 SG2 UZ board at C TK850 ZBV850 In this directory you will find a sub directory named CNET If you do not like to destroy the sample program you may copy the sub directory of CNET to your favorite location Now the CNET directory in the new location is the folder you are going to create your own application from now on PONE a User program folder PRAM ON Tools to registor web files F lt ee eee User html files FEF pS User cgi files gif User gif files User s Manual U19108EE1VOUMOO 9 10 Chapter 3 3 1 Figure 3 1 3 1 1 How to create your application Overview Application Programming Interface API is available for your development We have two kinds of API A Network API B Application Layer API Sample application User application SMTP POP HTTP TCP UDP Network
17. a user function in httpdfunc c Declare the structure defined in cnet_httpd h typedef struct const char fn Function ID void i int id const char name const char value Function Pointer cnet _finfo httpdfunc c 18 Definition of the user function in httpdfunc c and an example of httpd flist static void a int id const char name const char value static void b int id const char name const char value static void c int id const char name const char value static void funcl int id const char name const char value const cnet_finfo httpd _flist van al pr b e c funcl funcl NULL NULL User s Manual U19108EE1VOUMOO How to create your application Chapter 3 User defined function names and function pointers are specified in the httpd_first structure The end of registration is recognized by specifying a NULL pair as the function name and function pointer Therefore please write a NULL NULL at the end Example 1 Example of POST method POST cgi test cgi HTTP 1 0 Content Length 12 func1 param1 2 Example for CGI c func1 param1 3 Function call up func1 pcd hs func1 param1 3 4 5 How to use the Web file registration tool makefsdata command Files for http server need to be registered in fsdata c usi
18. d by network driver function err_t output struct netif netif struct pbuf p struct ip_addr ipaddr Transmission driver function on the network layer err_t linkoutput struct netif netif struct pbuf p Transmission driver function on the link layer void linkproc struct netif netif Event execution function of network driver void state Status LWIP_DHCP struct dhcp dhcp dhcp info is stored Hendif 14 unsigned char hwaddr len hardware address length unsigned char hwaddr NETIF_MAX HWADDR_LEN i Hardware address ul6_t mtu MTU char name 2 u8 t num u8 t flags Network interface information netif consists of the following members next Pointer to connect network interface information netif is stored ip_addr IP address network byte order format which is specified by parameter when netif_add or netif_set_addr is issued is stored netmask Subnet mask network byte order format which is specified by parameter when netif_add or netif_set_addr is issued is stored gw Gateway address network byte order format which is specified by parameter when netif_add or netif_set_addr is issued is stored input struct pbuf p struct netif inp This is pre occupied by system Fixed value of tcpip_input is stored User s Manual U19108EE1VOUMOO How to create your application Chapter 3 3 3 2
19. e of cnet_pop3end 2 cnet_pop3auth has to be precedent to this API Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_READ Oxffffffe0 POP3 server response timeout POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POP3 server POP3_ERROR_REPLY Oxfffffffc ay eee ere 2 POP3_ERROR_STATE Oxfffffffe Wrong API sequence POP3_ERROR_PARAMETER Oxffffffff Illegal parameter 4 2 15 cnet_pop3reset Scope Format in C Parameters Functions Clear delete mark int cnet_pop3reset void None Send RESET command to the POPS server 4 2 16 Delete mark assaigned by cnet_pop3delete is cleared Cnet_pop3auth has to be precedent to this API Return values Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_READ OxffffffeO POPS server response timeout POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POP3 server POP3_ERROR_REPLY Oxffftfffc POPS server response error to RSET command POP3_ERROR_STATE Oxfffffffe Wrong API sequence cnet_pop3getuid Scope Get Unique ID Format in C int cnet_pop3getuid unsigned int msgno char uidbuf unsigned short uidbuflen Parameters I O Parameters Functions unsigned int msgno Mail number O Char uidbuf Pointer to store Unique ID unsigned short uidbuflen User s Manual U19108EE1VOUMOO Size of memory which is pointed by uidbuf to sto
20. et_smtpdatafirst Scope Format in C Initiate transmission of mail data int cnet_smtpdatafirst const char sendaddr const char recvaddr const char databuf unsigned short datalen User s Manual U19108EE1VOUMOO API Specifications Chapter 4 4 2 4 Parameters I O Parameters Functions Pointer to the memory where sender s mail Const char sendaddr addr ssisstored Pointer to the memory where receiver s mail Const char recvaddr address is stored Const char databuf Pointer to the memory where mail text is stored unsigned short datalen Data size of the mail text specified by databuf in bytes Functions Send out MAIL command RCPT command DATA command and mail data to SMTP server which is specified in cnet_smtpinit Mail data comprises of sender s mail address which is specified in sendadar receiver s mail address which is specified in receiver s mail address and mail text which is specified in databuf and datalen Notes 1 C NET recognizes those information available between this API and net_smtpdataend as one e mail 2 This API is valid only after cnet_smtpinit has initiated a session with SMTP server Return values Macro Value Meanings SMTP_ERROR_NORMAL 0x0 No error SMTP_ERROR_READ oxffffffeo Timeout to wait for a response by SMTP server SMTP_ERROR_DISCONNECT OxfffffffO Disconnec
21. ffffeO Timeout of SMTP server response SMTP_ERROR_DISCONNECT _ Oxfffffff0 mit ate Network DYSMIE SMTP_ERROR_REPLY Oxffftfffc Response error in SMTP server to lt CR gt and lt LF gt SMTP_ERROR_STATE Oxfffffffe Wrong API sequence 4 2 6 cnet_pop3init Scope Format in C Parameters Initiate session with POPS server where mail is spooled int cnet_pop3init unsigned int addr unsigned short port I O Parameters Functions unsigned int addr IP address in network byte order format unsigned short port Port number in host byte order format Functions is spooled Notes Initiate session with the port of POP3 server where mail 1 If the port number is 0x0 the port number is assumed as 110 2 This API shall be issued after netif_set_default or cnet_dhcpstart User s Manual U19108EE1VOUMOO API Specifications Chapter 4 Return values Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_NOBUF Oxffffff80 Not enough buffer space POP3_ERROR_CONNECT Oxfffffff8 Failed to establish connection POP3_ERROR_STATE Oxfffffffe Wrong API sequence POP3_ERROR_PARAMETER Oxffffffff Illegal parameter 4 2 7 cnet_pop3end Scope Terminate session with POP3 server where mail is spooled Format in C int cnet_pop3end unsigned char mode Parameters I O Parameters Functions te iia ties Mode 0 Normal termination unsig
22. gfirst Initiate reception of mail data cnet_pop3getmsgnext Continue reception of mail data cnet_pop3getmsgend Declare termination of mail data reception cnet_pop3delete Ask POP3 server to put delete mark on a mail cnet_pop3reset Ask POP3 server to clear the delete mark cnet_pop3getuid Ask POP3 server to check Unique ID of the mail HTTP cnet_httpdinit Initialize transfer function of Hyper text User s Manual U19108EE1VOUMOO How to create your application Chapter 3 Name of API cnet_httpdsend Function Send data to Web client DHCP Client cnet_dhcpstart Ask DHCP server to assign network information automatically cnet_dhcpstop Clear the assigned network information User s Manual U19108EE1VOUMOO 13 Chapter 3 How to create your application st F st i 3 3 How to program user application 3 3 1 How to use network API Structure is used to call network API in_addr Structure cnet ipv4 lwip ip_addr h ruct in addr u32_t s_addr Network address Netif Structure cnet Iwip netif h ruct netif struct netif next Pointer for the next netif struct ip_addr ip_addr Host IP address Byte order format struct ip_addr netmask Netmask Byte order format struct ip_addr gw Gateway address Byte order format err_t input struct pbuf p struct netif inp TCP IP function call
23. i Mode 1 Forced termination Functions Terminate session with POP3 server where mail is spooled Mode 0 Terminate after receiving a POP3 server response to QUIT command Mode 1 Terminate immediately without receiving any response from POP3 server Note cnet_pop3init is assumed prior to this API Return values Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_READ Oxffffffe0 Response timeout of POP3 server POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POP3 server POP3_ERROR_REPLY oxfffffffc ra ale error to POP3_ERROR_STATE Oxfffffffe Wrong API sequence 4 2 8 cnet_pop3auth Scope Send data for authentication to POP3 server Format in C int cnet_pop3auth const char user const char pass User s Manual U19108EE1VOUMOO 31 Chapter 4 API Specifications 32 4 2 9 Parameters I O Parameters Const char user Functions Pointer to user ID Const char pass Pointer to password Functions Return values Send USER command PASS command and authentication data to the POP3 server Authentication data comprises of user name and password Authentication is executed by the POP3 server Note cnet_pop3init has to be completed prior to this API Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_READ Oxffffffe0 Response timeout of POP3 server POP3_ERROR_DISCONNECT
24. if_add or assignment of network information initiated by cnet_dhcpstart has to be executed Returns Value Meaning Normally completed with gateway address in network byte order Value format 4 1 9 inet_addr Scope Convert IP address from dot format to byte order format Format in C u32_t inet_adar const char cp 24 User s Manual U19108EE1VOUMOO API Specifications Chapter 4 4 1 10 4 1 11 Parameters 1 0 Parameter Function Const char cp Pointer to the memory where IP address with dot format is stored Functions Return values Convert IP address from dot format to byte order format Return IP address in byte order format dot format is something like 202 247 5 136 Value Meaning Value IP address with network byte order format inet_ntoa Scope Convert IP address to dot order format from byte Format in C format u8_t inet_ntoa u32_t addr Parameters I O Parameter Function U32_t addr IP address with network byte order format Functions Return values Convert IP address from byte format to dot order format Return IP address in dot order format dot format is something like 202 247 5 136 Value Meaning Value IP address with dot order format htonl Scope Convert 32 bit data from host byte order to network Format in C byte order format u32_t htonl u32_tn
25. in a particular application Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots Special Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime User s Manual U19108EE1VOUMOO systems safety equipment and medical equipment not specifically designed for life support Specific Aircraft aerospace equipment submersible repeaters nuclear reactor control systems life support systems and medical equipment for life support etc The quality grade of NEC Electronics products is Standard unless otherwise expressly specified in NEC Electronics data sheets or data books etc If customers wish to use NEC Electronics products in applications not intended by NEC Electronics they must contact an NEC Electronics sales representative in advance to determine NEC Electronics willingness to support a given application Note 1 NEC Electronics as used in this statement means NEC Electronics Corporation and also includes its majority owned subsidiaries 2 NEC Electronics products means any product developed or manufactured by or for NEC Electronics as defined above User s Manual U19108EE1VOUMOO 3 America NEC Electronics America Inc 2880 Scott Blvd Regional Information Some
26. information contained in this document may vary from country to country Before using any NEC product in your application please contact the NEC office in your country to obtain a list of authorized representatives anddistributors They will verify Device availability Ordering information Product release schedule Availability of related technical literature Development environment specifications for example specifications for third party tools and components host computers power plugs AC supply voltages and so forth Network requirements In addition trademarks registered trademarks export restrictions and otherlegal issues may also vary from country to country NEC Electronics Corporation 1753 Shimonumabe Nakahara ku Kawasaki Kanagawa 211 8668 Japan Tel 044 4355111 http www necel com Santa Clara CA 95050 2554 U S A Tel 408 5886000 http www am necel com Europe NEC Electronics Europe GmbH Arcadiastrasse 10 40472 D sseldorf Germany Tel 0211 65030 http www eu necel com United Kingdom Branch Cygnus House Sunrise Parkway Linford Wood Milton Keynes MK14 6NP U K Tel 01908 691133 Succursale Francaise 9 rue Paul Dautier B P 52 78142 Velizy Villacoublay C dex France Tel 01 30675800 Tyskland Filial Taby Centrum Entrance S 7th floor 18322 T by Sweden Tel 08 6387200 Filiale Italiana Via Fabio Filzi 25 A 20124 Milano Italy Tel 02 667541 Branch The Netherla
27. irst The mail data is stored in the memory specified by msgbuf There are three operation modes POP3_MODE_TEXT The mail is retreived till LF or end code is detected Otherwise msglen is the maximum size to retrieve The mail is stored in the memory specified by msgbuf If the return value is 0x0 the rest of the mail text can be retrieved by issuing another cnet_pop3getmsgnext POP3_MODE_TRUNC The mail is retreived till LF or end code is detected Otherwise msglen is the maximum size to retrieve The mail is stored in the memory specified by msgbuf If the return value is 0x0 the rest of the mail text can be retrieved by issuing another cnet_pop3getmsgnext POP3_MODE_BINARY The mail is retreived till end code is detected Otherwise msglen is the maximum size to retrieve The mail is stored in the memory specified by msgbuf If the return value is 0x0 the rest of the mail text can be retrieved by issuing another cnet_pop3getmsgnext Notes 1 The size of memory specified by msgbuf shall be msglen 1 bytes 2 cnet_pop3getmsgfirst has to be precedent to this API User s Manual U19108EE1VOUMOO 35 Chapter 4 API Specifications 36 Return values 4 2 13 cnet_pop3getmsgend 4 2 14 Macro Value Meanings POP3_ERROR NORMAL 0x0 No error but mail data is partially retrieved normally No error End code was detected POP3_ERROR_GETEND 0x1 or lines specified by maxline were ret
28. ize Scope Ask POP3 server to check the mail size Format in C int cnet_pop3getsize unsigned int msgno unsigned int size Parameters I O Parameters Functions unsigned int msgno NUMBER of a mail O unsigned int size Pointer to the mail size of the mail specified by msgno Functions Send LIST command and NUMBER of a mail to the POP3 server 4 2 11 Ifthe mail is being spooled in the POP3 server the size of the mail is stored at size in bytes Note cnet_pop3auth has to be precedent to this API Return values Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_READ Oxffffffe0 POP3 server response timeout POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POP3 server POP3_ERROR_REPLY Ox fftfffc POPS server response error to LIST command POP3_ERROR_STATE Oxfffffffe Wrong API sequence POP3_ERROR_PARAMETER Oxffffffff Illegal parameter cnet_pop3getmsgfirst Scope Initiate reception of mail data Format in C int cnet_pop3getmsgfirst unsigned int msgno unsigned int maxline char msgbuf unsigned short msglen unsigned char mode User s Manual U19108EE1VOUMOO 33 Chapter 4 API Specifications 34 Parameters I O Parameters Functions unsigned int msgno NUMBER of a mail unsigned int maxline Acceptable maximum lines of the mail If zero is specified all lines will be subject to processing O char msgbuf Pointer to
29. nds Steijgerweg 6 5616 HS Eindhoven The Netherlands Tel 040 2654010 User s Manual U19108EE1VOUMOO Asia amp Oceania NEC Electronics China Co Ltd 7th Floor Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100083 P R China Tel 010 82351155 http www cn necel com NEC Electronics Shanghai Ltd Room 2511 2512 Bank of China Tower 200 Yincheng Road Central Pudong New Area Shanghai 200120 P R China Tel 021 58885400 http www cn necel com NEC Electronics Hong Kong Ltd 12 F Cityplaza 4 12 Taikoo Wan Road Hong Kong Tel 2886 9318 http www hk necel com NEC Electronics Taiwan Ltd 7F No 363 Fu Shing North Road Taipei Taiwan R O C Tel 02 27192377 NEC Electronics Singapore Pte Ltd 238A Thomson Road 12 08 Novena Square Singapore 307684 Tel 6253 8311 http www sg necel com NEC Electronics Korea Ltd 11F Samik Lavied or Bldg 720 2 Yeoksam Dong Kangnam Ku Seoul 135 080 Korea Tel 02 558 3737 http www kr necel com Preface Copyright C NET is based on IwIP Light Weight TCP IP IwIP can be distributed with Modified BSD License Copyright c 2001 2002 Swedish Institute of Computer Science All rights reserved Redistribution and use in source and binary forms with or without modification are permitted provided that the following conditions are met 1 Redistributions of source code must retain the above copyright notice this list of c
30. ng the following makefsdata command The file registration procedure is as follows 1 Create the fs fixed name directory under the cnet src directory of the project gt In the operation environment of the preloaded sample fs and cgi are already created enet fs html file egi cgi file gif gif file sre fsdata c This is the data file of your new contents Create html cgi and image files which make up web pages under the created fs directory The directory tree can be created arbitrarily as loon as the cgi file is created under fs cgi Once you have created all files under the fs directory open a command prompt and run Gmakefsdata You can find Gmakefsdata exe at cnet bin You will see the following window Now you specify the source of the web data and the destination of the fs directory g GMakefsdata WEB Contents Folder C S50 SAMPLE_VB850 nec Web test iS Output Folder O CATEMP ES or Cancel Figure 3 5 Window of GMakefsdata exe User s Manual U19108EE1VOUMOO 19 Chapter 3 How to create your application 5 You will find GMakefsdata at the destination GMakefs data J makefsdata completed Figure 3 6 Gmakefsdata has been completed 6 Now you can make rebuild 20 User s Manual U19108EE1VOUMOO Chapter 4 4 1 4 1 1 API Specifications Network API cnet_init function Scope Format in C Parameters Functio
31. ns Return values cnet_add function Scope Format in C Parameters Initialization of the network void cnet_init void None The network information is initialized with the default value stored in Flash EEPROM None Add network information struct netif netif_add struct ip_addr ip_adar struct ip_addr netmask struct ip_addr gw void state err_t init struct netif netif err_t input struct pbuf struct netif netif I O Parameters Functions struct ip_addr ip_adar Pointer to the assigned IP adress struct ip_addr netmask Pointer to the netmask struct ip_addr gw Pointer to the gateway address Void state Pointer to the status info err_t init struct netif netif Pointer to the physical network driver err_t input struct pbuf struct netif netif tcpip_input is fixed Pre occupied by system Functions IP address netmask gateway address and status are registered on C NET At the same time initiation of the physical network driver is completed Notes 1 After this API is executed if you like to utilize cnet_dhcpstart please set 0x0 in ip_addr netmask and gw 2 Do not set any conflicting parameter in the physical network driver 3 This API is valid only after cnet_init User s Manual U19108EE1VOUMOO 21 Chapter 4 API Specifications 22
32. onditions and the following disclaimer 2 Redistributions in binary form must reproduce the above copyright notice this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution 3 The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE AUTHOR AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES INCLUDING BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE DATA OR PROFITS OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE This file is part of the lwIP TCP IP stack Author Adam Dunkels lt adam sics se gt http savannah nongnu org projects Iwip User s Manual U19108EE1VOUMOO 5 Table of Contents Chapter 1 Introduction 000 000 c ccc cece cece cece 8 Chapter 2 Preparations 000 000 00 ccc ereer rrer cence eee 9 2 1 Installation of software
33. qwaddr site sgete Nr k stein vea ie 24 4 1 9 inet addr 2 iz tetas O EA E dae eens 24 4 140 inet ntOa herrer fsck tees oe hea A ii 25 AAA OM sae ind ccd shea ati doles ee baa kai eG hae Ee alan 25 AWA NTON 46 A Se aS es inte aa Pe ee Tes a NA O 26 A Wabi AAA NA RE O 26 A MON a a da dns 27 4 2 Application layer API HTTP SMTP POP3 and DHCP occcccccc 27 4 2 1 AA PP eaves wa ad Mead Aare Sie eae eee ee ed 27 4 2 2 Cnet sMmtpendy whe ti a Ste we ag Aired 28 4 2 3 cnet_smtpdatafirst enssins 0 0 ccc ee ete 28 4 2 4 cnet smtpdatanext ects oe eel a ee ee eee gee a eek 29 4 2 5 cnet_smtpdataend 00 cece eee 30 4 2 6 CNEL POpSinite A Ase A Seen 30 4 2 7 Gnet_popsend A NE EO ee ah ab bale faa 31 4 2 8 CNEL POpSauth viet ee A a a Rita b aah 31 4 2 9 CNEL Popsstat 2k Aut ate Sedat a T E A 32 A210 ChEt2POPSOCtSIZE tinci n A eae wn wee a et te eae 33 User s Manual U19108EE1VOUMOO 4 2 11 4 2 12 4 2 13 4 2 14 4 2 15 4 2 16 4 2 17 4 2 18 4 2 19 4 2 20 cnet_popSgetmsofirst cece eee eee ee eee 33 cnet_pop3getmsgnext cece ee ee eee eee eee 35 cnet_pop3getmsgend cece cee ee ee eee eens 36 Cnet_pop3delete i er siaa at eal Meee ka ee aa aes 36 Cnet_popSreset iii eed Puen ge eee eee eens 37 cnet_popSgetuid star ir le ee alee a ee ai oe ga ea 37 chet dhcpstart cios Sat lesen ade AAA 38 cnet dhepstop a2 sii west daira a wee eee aes oie we cag aes 39 GMETNTIPGIN Es AO 39 CNEA PA
34. re Unique ID in bytes 37 Chapter 4 API Specifications 38 4 2 17 Functions Send UIDL command and Mail Number to the POP3 server Unique ID of the mail is stored in memory where uidbuf specified Cnet_pop3auth has to be precedent to this API Return values Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_NOBUF Oxffffff80 or id POP3_ERROR_READ OxffffffeO POPS server response timeout POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POP3 server POP3 server response error to POP3_ERROR_REPLY Oxfffffffc UIDL command POP3_ERROR_STATE Oxfffffffe Wrong API sequence POP3_ERROR_PARAMETER Oxffffffff Illegal parameter cnet_dhcpstart Scope Ask DHCP server to assign network information automatically Format in C int cnet_dhcpstart struct netif netif Parameters I O Parameters Functions struct netif netif Pointer to network information netif Functions Ask DHCP server to assign network information automatically Network information comprises of IP address subnet mask and gateway address The network information is stored in the memory which is pointed by netif Notes 1 The network information shall match the return value of the previous netif_add 2 Valid period of the network information depends on a DHCP server Therefore it is suggested to update it in every 100 msec by cnet_dhcptmr 3 Once the automatic a
35. rieved POP3_ERROR_READ OxffffffeO POPS server response timeout POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POP3 server POP3_ERROR_STATE Oxfffffffe Wrong API sequence POP3_ERROR_PARAMETER Oxffffffff Illegal parameter Scope Declare termination of mail data reception Format in C int cnet_pop3getmsgend void Parameters None Functions Declare termination of mail data reception to C NET Notes 1 Information retrieved between cnet_pop3getmsgfirst and cnet_pop3getmsgend is interpreted as one mail 2 cnet_pop3getmsgfirst has to be precedent to this API Return values Macro Value Meanings POP3_ERROR_NORMAL 0x0 No error POP3_ERROR_READ Oxffffffe0 POP3 server response timeout POP3_ERROR_DISCONNECT OxfffffffO Disconnected by POP3 server POP3_ERROR_STATE Oxfffffffe Wrong API sequence cnet_pop3delete Scope Format in C Parameters Assignment of delete mark int cnet_pop3delete unsigned int msgno I O Parameters Functions unsigned int msgno NUMBER of a mail Functions Send DELE command and the NUMBER of a mail which is to be deleted to the POP3 server The POPS server assigns a delete mark on the mail which is being spooled Notes User s Manual U19108EE1VOUMOO API Specifications Chapter 4 Return values 1 The mail with the delete mark is actually deleted in the POP3 server based on the issu
36. s 40 Parameters I O Parameters Functions int id ID assigned to User defined function const char msg Pointer to the content area int msglen Data size assigned by msg in byte Requirement of copy unsigned char copy O if volatile content 1 If fixed content Functions Destination is the Web client specified by msg Note This API is valid in user defined function Return values Value Meanings 0 No error 1 Not enough work space 8 Illegal parameter User s Manual U19108EE1VOUMOO
37. ssignment has been completed the network information can be read by issuing cnet_getipaddr cnet_getnetmask or cnet_getgwadar 4 netif_set_default has to be precedent to this API User s Manual U19108EE1VOUMOO API Specifications Chapter 4 4 2 18 4 2 19 4 2 20 Return values Value Meanings 0 No error 1 Not enough memory 8 Illegal parameter 9 DHCP server response timeout cnet_dhcpstop Scope Clear the assigned network information Format in C void cnet_dhcpstop struct netif netif Parameters I O Parameters Functions struct netif netif Pointer to network information netif Functions Return values cnet_httpdinit Scope Format in C Parameters Functions Return values cnet_httpdsend Scope Format in C User s Manual U19108EE1VOUMOO Clear the assigned network information Notes 1 The network information shall match the information assigned by cnet_dhcpstart 2 cnet_dhcpstart has to be precedent to this API None Initialize transfer function of Hyper text void cnet_httpdinit void None Initialize transfer function of Hyper text Initialization is executed Note netif_set_default and cnet_dhcpstart have to be precedent to this API None Send data to Web client int cnet_httpdsend int id const char msg int msglen unsigned char copy 39 Chapter 4 API Specification
38. t_dhcpstart User s Manual U19108EE1VOUMOO 27 Chapter 4 API Specifications 28 Return values Macro Value Meanings SMTP_ERROR_NORMAL 0x0 No error SMTP_ERROR_NOBUF Oxffffff80 Not enough working buffer SMTP_ERROR_CONNECT Oxfffffff8 Failed to network connection SMTP_ERROR_STATE Oxfffffffe Wrong sequence of API SMTP_ERROR_PARAMETER Oxffffffff lllegal parameter 4 2 2 cnet_smtpend Scope Format in C Parameters Terminate session with SMTP server int cnet_smtpend unsigned char mode I O Parameters Functions unsigned char mode Mode 0 Normal termination Mode 1 Forced termination Functions Return values Terminate session with SMTP mail server which is specified by cnet_smtpinit There are two modes to terminate Mode 0 Terminate session after receiving response by SMTP server to QUIT command Mode 1 Terminate session immediately without receiving response by SMTP server to QUIT command Note Prior to this API session with the SMTP server has to be initiated with cnet_smtpinit Macro Value Meanings SMTP_ERROR_NORMAL 0x0 No error SMTP_ERROR_READ oxffffffeo Timeout to wait for a response by SMTP server SMTP_ERROR_DISCONNECT OxfffffffO Disconnected with SMTP server SMTP_ERROR_REPLY oxtftffffe Response error by SMTP server to QUIT command SMTP_ERROR_STATE Oxfffffffe Wrong sequence of API 4 2 3 cn
39. ted by SMTP server Response error by SMTP server to SMTP_ERROR_REPLY Oxfffffffc MAIL RCPT or DATA commands SMTP_ERROR_STATE Oxfffffffe Wrong sequence of API SMTP_ERROR_PARAMETER Oxffffffff Parameter error cnet_smtpdatanext Scope Transmission of mail text Format in C int cnet_smtpdatanext const char databuf unsigned short datalen Parameters I O Parameters Functions Const char databuf Pointer to the mail text unsigned short datalen Size of the mail text specified in databuf in bytes Functions Transmit the mail text which is specified in databuf and datalen This API follows cnet_smtpdatafirst User s Manual U19108EE1VOUMOO 29 Chapter 4 API Specifications 30 Return values Macro Value Meanings SMTP_ERROR_NORMAL 0x0 No error SMTP_ERROR_READ OxffffffeO Timeout of SMTP server response SMTP_ERROR_DISCONNECT _ OxfffffffO oe hetworkiby SMTE SMTP_ERROR_STATE Oxfffffffe Wrong API sequence SMTP_ERROR_PARAMETER Oxffffffff Illegal parameter 4 2 5 cnet_smtpdataend Scope Format in C Functions lt CR gt and lt LF gt cnet_smtpdatafirst is mandatory prior to this API Return values Terminate transmission of mail data int cnet_smtpdataend void Parameters None Terminate transmission of mail data by sending out Macro Value Meanings SMTP_ERROR_NORMAL 0x0 No error SMTP_ERROR_READ Oxff
40. tml files to fsdata c using GMakefsdata Build the application Figure 3 3 Creating web applications Files created by users HTML Web contents CGI Web contents Browser Browser can GMakefsdata access via Httpd User Program Figure 3 4 File structure of Web application 16 User s Manual U19108EE1VOUMOO How to create your application Chapter 3 3 4 2 Note for CGI 3 4 3 3 4 4 CGI format One line for one execution unit The first character specifies an action i Output contents in the file specified after i t Output data specified after t c Execute the function ID or parameters of which is specified after c f Send out 204 No Contents Comment Period End of HTML description lt BODY gt lt HTML gt r n Others Nothing happens Definition of method 1 GET Method Function Request display of HTML CGI or image Rule If only is specified it displays index html If the specified html or cgi is not found it displays 404 html If the file under cgi is specified it assumes the specified file to be CGI Example GET index html HTTP 1 0 GET test html func1 param1 HTTP 1 0 2 POST Method Function It passes parameters to CGI Rule If the file under cgi is not specified it returns error 405 If the specified cgi is not found it displays 404 html How to define user functions If you like to create your own function
Download Pdf Manuals
Related Search
Related Contents
Panasonic 26PEF1U6 Service Manual Bedienungsanleitung - oeko 2014 - Ressources & Territoires Copyright © All rights reserved.
Failed to retrieve file