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. |
enum IPField_t |
Use this enumerator for the function BootupPrintIPAddress to get a well formated IP address.
enum IPObtainedFrom_t |
enum IPSelectionModes_t |
This typedef defines the various modes how the Netzer gets its IP address.
enum NetzerProjects_t |
Enumerates the different targets a Netzer can be used for.
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.
LoadFromPersistent | TRUE means, load the HTTP port from EEPROM. FALSE means, load the HTTP port from local RAM storage. |
void BootupGetIPAddress | ( | IPField_t | Position, | |
BYTE * | pBuffer | |||
) |
Use this function to obtain any of the device IP addresses.
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.
LoadFromPersistent | TRUE means, load the IP mode from EEPROM. FALSE means, load the IP mode from local RAM storage. |
void BootupGetNetworkName | ( | BOOL | Persistent, | |
BYTE * | pNameBuffer, | |||
BYTE | SizeOfBuffer | |||
) |
Delivers the network name of the device.
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.
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:
TRUE | The network module is ready, the application can start using the network. | |
FALSE | The network is not ready due several reasons (see above). |
void BootupPrintFormatedIPAddress | ( | BYTE * | pIPAddress, | |
BYTE * | pBuffer | |||
) |
Use this function to print a formated IP address to a given RAM buffer.
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.
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).
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.
Position | Specifies which IP address should be set. | |
pIPString | Pointer to the input buffer with the stored IP string. |
TRUE | Set was succesful. | |
FALSE | Set has failed. |
void BootupSetNetworkName | ( | BYTE * | pName | ) |
Use this function to change the network name of the device.
pName | Pointer to the new name string. |
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.