Network Functions and Variables

From openPicus Wiki
Jump to: navigation, search

What you are going to learn

This tutorial describes the main functionalities and variables to manage network advanced parameters.


The system variable AppConfig is a structure containing many network parameters. Following is a description of available fields:

  • IP_ADDR MyIPAddr; // IP address
  • IP_ADDR MyMask; // Subnet mask
  • IP_ADDR MyGateway; // Default Gateway
  • IP_ADDR PrimaryDNSServer; // Primary DNS Server
  • IP_ADDR SecondaryDNSServer; // Secondary DNS Server
  • IP_ADDR DefaultIPAddr; // Default IP address
  • IP_ADDR DefaultMask; // Default subnet mask
  • BYTE NetBIOSName[16]; // NetBIOS name
  • BOOL Flags.bIsDHCPEnabled // DHCP is currently enabled is value != 0
  • MAC_ADDR MyMACAddr; // Application MAC address

In case of Flyport Wi-Fi (or Flyport Wi-Fi PRO) there are additional parameters:

  • BYTE MySSID[32]; // Wireless SSID
  • BYTE SsidLength; // number of bytes in SSID
  • BYTE SecurityMode; // WF_SECURITY_OPEN or one of the other security modes
  • BYTE SecurityKey[64]; // WiFi Security key, or passphrase.
  • BYTE SecurityKeyLength; // number of bytes in security key (can be 0)
  • BYTE WepKeyIndex; // WEP key index (only valid for WEP)
  • BYTE networkType;
  • BYTE channelList[11]; // Channel list
  • BYTE channelListSize; // Size of channel list
  • BYTE myBSSID[6]; // BSSID

Helpers functions

OpenPicus framework provides some easy to use helper functions and variables, to speed up code development. Here is a list of few related to handle network parameters:

  • BOOL DHCPAssigned - this variable is TRUE if DHCP Server assigned a new IP to Flyport. If DHCP Client service is not enabled in current connection profile, this variable cannot be used, and its value is not affidable.
  • BOOL StringToIPAddress( BYTE* str, IP_ADDR* IPAddress) - this function returns TRUE if the string provided were converted to IP Address, or FALSE if the process was concluded unsuccessfully.
  • void IPAddressToString(IP_ADDR* IPAddress, char* ipString) - Convert provided IP_ADDR type value to a string. Can be useful to print IP_ADDR values of AppConfig structure.

NOTE: Flyport Ethernet only

  • BOOL MACLinked - this value is TRUE if the Ethernet Cable is connected (at a access point or at a PC or other device in a point-to-point connection), instead it is FALSE if Ethernet Cable is unconnected, or the connection is not working (for example the other device is not responding or turned off)
Personal tools