Application network and initialization module


Detailed Description

The module brings up the Netzer and the TCP/IP stack as configured by the user.

The module therefore loads the persistent stored EEPROM data for the network stack. After configuring the network it starts the network stack and checks for occuring errors. If the start fails, the user and the application are informed. If no error occurs, the application can start with the usage of a configured network.


Files

file  bootup.c
 Implementation of the boot process of the Netzer application.
file  bootup.h
 Prototypes for calling the Netzer application boot up and network routines.

Data Structures

struct  _IP_CONFIG
 This typedef defines the local structure for TCP/IP stack parameters. More...
struct  CommonConfig_t
 This typedef defines the peristent structure for common settings and TCP/IP stack parameters. More...

Defines

#define MAX_NETWORKNAME_LENGTH   8
 The maximum allowed length for network names (currently used in the MDNS).

Enumerations

enum  IPSelectionModes_t {
  IPS_DHCP_ENABLED = 0, IPS_DHCP_AUTOIP, IPS_DHCP_MANUALIP, IPS_AUTO_IP,
  IPS_MANUAL_IP, IPS_MODE_COUNT
}
 This typedef defines the various modes how the Netzer gets its IP address. More...
enum  IPObtainedFrom_t { IPO_DHCP = 0, IPO_AUTO, IPO_MANUAL }
 This enumerator states from which instance the current device IP was obtained from. More...
enum  NetzerProjects_t
 Enumerates the different targets a Netzer can be used for. More...
enum  IPField_t {
  VAR_IP_ADDRESS = 0, VAR_GATEWAY_ADDRESS, VAR_SUBNET_MASK, VAR_MAN_IP_ADDRESS,
  VAR_MAN_SUBNET_MASK, VAR_MAN_GATEWAY_ADDRESS, VAR_IP_ADDRESS_EEPROM, VAR_SUBNET_MASK_EEPROM,
  VAR_GATEWAY_ADDRESS_EEPROM
}
 Use this enumerator for the function BootupPrintIPAddress to get a well formated IP address. More...

Functions

void BootupInit (void)
 This function initializes the application network module.
BOOL BootupMain (void)
 This function must be called periodically by the application.
void BootupResetToFactory (void)
 Sometimes the reset of the persistent data in the EEPROM to a well known state is needed.
void BootupEnterBootloader (void)
 Calling this function prepares the bootloader entry.
void BootupBlink (void)
 This function blinks the network LED with a second period.
void BootupGetNetworkName (BOOL Persistent, BYTE *pNameBuffer, BYTE SizeOfBuffer)
 Delivers the network name of the device.
void BootupPrintIPAddress (IPField_t Position, BYTE *pBuffer)
 Use this function to generate a string from a IP address of this device.
void BootupPrintFormatedIPAddress (BYTE *pIPAddress, BYTE *pBuffer)
 Use this function to print a formated IP address to a given RAM buffer.
BOOL BootupSetIPAddress (IPField_t Position, BYTE *pIPString)
 Use this function to change the given IP address with an IP address string.
void BootupSetNetworkName (BYTE *pName)
 Use this function to change the network name of the device.
IPSelectionModes_t BootupGetIPMode (BOOL LoadFromPersistent)
 Delivers the current selected Netzer IP mode.
void BootupSetHTTPPort (WORD NewPort)
 Set a new port for the HTTP service for the next session (after reboot).
WORD BootupGetHTTPPort (BOOL LoadFromPersistent)
 Delivers the currently set or persistently written port value for the HTTP service.
void BootupGetIPAddress (IPField_t Position, BYTE *pBuffer)
 Use this function to obtain any of the device IP addresses.
void BootupInvalidateIPSettings (void)
 Reset the current IP settings to invalid.

Variables

static SM_BOOTUP _sm
 The local state machine.
static BYTE _au8NetworkDataForBootloader [12]
 Stores the network related data like MAC address and IP address for reboot.
static DWORD _timer
 The timer state for measuring times.
static WORD _persistentHTTPPort
 The HTTP port - staying consistent with EEPROM.
IPConfig_t sIPConfig
 This field stores the local TCP/IP parameters.
CommonConfig_t sPCommonConfig
 The persitent data field.


Enumeration Type Documentation

enum IPField_t

Use this enumerator for the function BootupPrintIPAddress to get a well formated IP address.

Enumerator:
VAR_IP_ADDRESS  Prints out the current device IP address.
VAR_GATEWAY_ADDRESS  Prints out the current device gateway address.
VAR_SUBNET_MASK  Prints out the current device subnet mask.
VAR_MAN_IP_ADDRESS  Prints out the manual set IP address.
VAR_MAN_SUBNET_MASK  Prints out the manual set subnet mask.
VAR_MAN_GATEWAY_ADDRESS  Prints out the manual set gateway IP address.
VAR_IP_ADDRESS_EEPROM  Prints out the device IP address from EEPROM.
VAR_SUBNET_MASK_EEPROM  Prints out the device IP address from EEPROM.
VAR_GATEWAY_ADDRESS_EEPROM  Prints out the device gateway address from EEPROM.

This enumerator states from which instance the current device IP was obtained from.

Enumerator:
IPO_DHCP  The IP address is obtained via DHCP.

IPO_AUTO  The IP address is obtained via auto IP (in range 169.254).

IPO_MANUAL  The IP address is set manually.

This typedef defines the various modes how the Netzer gets its IP address.

Enumerator:
IPS_DHCP_ENABLED  The IP address is obtained via DHCP.

The device remains in boot up without a valid IP address as long as no DHCP server has responded.

IPS_DHCP_AUTOIP  The IP address is obtained via DHCP.

If DHCP fails, the device selects an auto IP address from the 169.254 range.

IPS_DHCP_MANUALIP  The IP address is obtained via DHCP.

If DHCP fails, the device uses the manual configured IP address.

IPS_AUTO_IP  A so called auto IP address from the 169.254 range is selected on bootup.

IPS_MANUAL_IP  The manual IP address is used from bootup.

IPS_MODE_COUNT  Placeholder to determine the count of different supported IP set modes.

Enumerates the different targets a Netzer can be used for.


Function Documentation

void BootupBlink ( void   ) 

This function blinks the network LED with a second period.

This can be used by the application to identifiy the device in the field.

void BootupEnterBootloader ( void   ) 

Calling this function prepares the bootloader entry.

After restarting the device the bootloader remains active and uses the prepared MAC and IP address.

WORD BootupGetHTTPPort ( BOOL  LoadFromPersistent  ) 

Delivers the currently set or persistently written port value for the HTTP service.

Parameters:
LoadFromPersistent TRUE means, load the HTTP port from EEPROM. FALSE means, load the HTTP port from local RAM storage.
Note:
Currently the value is not loaded from EEPROM, a static placeholder is used to prevent EEPROM usage here.

void BootupGetIPAddress ( IPField_t  Position,
BYTE *  pBuffer 
)

Use this function to obtain any of the device IP addresses.

Parameters:
Position Specifies which IP address should be returned.
pBuffer Buffer for the IPv4 address with at least 4 bytes space.

IPSelectionModes_t BootupGetIPMode ( BOOL  LoadFromPersistent  ) 

Delivers the current selected Netzer IP mode.

Parameters:
LoadFromPersistent TRUE means, load the IP mode from EEPROM. FALSE means, load the IP mode from local RAM storage.
Returns:
One of the IP modes, see IPSelectionModes_t for more details.

void BootupGetNetworkName ( BOOL  Persistent,
BYTE *  pNameBuffer,
BYTE  SizeOfBuffer 
)

Delivers the network name of the device.

Parameters:
Persistent If TRUE, the name is read from the EEPROM, if FALSE the name is read from the current state.
pNameBuffer Pointer to a buffer the name is copied to.
SizeOfBuffer Size of the given buffer.

void BootupInit ( void   ) 

This function initializes the application network module.

The network data persitant stored in EEPROM is loaded and the TCP/IP Stack is configured with this settings. If the function detects an empty EEPROM it loads the factory settings to ensure proper operation of the Netzer device.

Returns:
None
Remarks:
None

void BootupInvalidateIPSettings ( void   ) 

Reset the current IP settings to invalid.

Restarts the internal bootup state machine.

BOOL BootupMain ( void   ) 

This function must be called periodically by the application.

First of all the function tries to configure and to start the network due directly accessing the TCP/IP stack and its parameters. Several reasons in the network or on the local device can lead to a non working network. The function is able to detect this and report it to the calling application.

Possible reasons for network failures:

  • The network cable is unplugged or disconnected somewhere.
  • An address conflict is detected on the network.

Precondition:
The application network module must be initialized by a call of BootupInit.
Return values:
TRUE The network module is ready, the application can start using the network.
FALSE The network is not ready due several reasons (see above).
Remarks:
None

void BootupPrintFormatedIPAddress ( BYTE *  pIPAddress,
BYTE *  pBuffer 
)

Use this function to print a formated IP address to a given RAM buffer.

Parameters:
pIPAddress Pointer to the 32 bit IP address.
pBuffer Pointer to the output buffer (must have a size of at least 13 bytes).

void BootupPrintIPAddress ( IPField_t  Position,
BYTE *  pBuffer 
)

Use this function to generate a string from a IP address of this device.

Parameters:
Position Specifies which IP address should be formated.
pBuffer Pointer to the output buffer (must have a size of at least 13 bytes).

void BootupResetToFactory ( void   ) 

Sometimes the reset of the persistent data in the EEPROM to a well known state is needed.

The call of this function resets Netzer to the following parameters:

Manual settings: IP: 192.168.0.10 Subnet: 255.255.255.0 (/24) Gateway: 192.168.0.1 Language: English

The network address is accquired automatically (by DHCP or AutoIP), the first AutoIP address is generated and saved in EEPROM.

void BootupSetHTTPPort ( WORD  NewPort  ) 

Set a new port for the HTTP service for the next session (after reboot).

Parameters:
NewPort The port is written to EEPROM.

BOOL BootupSetIPAddress ( IPField_t  Position,
BYTE *  pIPString 
)

Use this function to change the given IP address with an IP address string.

Parameters:
Position Specifies which IP address should be set.
pIPString Pointer to the input buffer with the stored IP string.
Return values:
TRUE Set was succesful.
FALSE Set has failed.

void BootupSetNetworkName ( BYTE *  pName  ) 

Use this function to change the network name of the device.

Parameters:
pName Pointer to the new name string.


Variable Documentation

This field stores the local TCP/IP parameters.

Some of them will be loaded from the persistent data fields. Other fields are updated dynamically if the TCP/IP stack configuration change.

The persitent data field.

The field stores common settings of the Netzer and for the network. At the beginning the application must call BootupInit. This function loads the data which is stored in the data EEPROM into this SRAM field. The IP Menu or the function BootupResetToFactory can change this fields and store it back to the EEPROM.


Generated on Fri Mar 29 10:34:28 2013 for Netzer by  doxygen 1.5.5