NetBurner 3.5.0
PDF Version
 
NB Approve Shutdown

The NBApproveShutdown callback function can be used by an application to put the system in a safe state before an application update, configuration update, or reboot event occurs. For example, closing active TCP sockets, ensuring Flash and/or file system write operations are complete, and putting critical peripherals in a safe state. The NBApproveShutdown() function as a weak reference to a system function that always returns true by default. If an application creates it's own function using the same signature, that function will be used instead.

A reason for the reboot request is passed to the function. The system will automatically call NBapproveShutdown() for the following reasons:

#define SHUTDOWN_CODEUPDATE (1) // A code update is requested
#define SHUTDOWN_CONFIGURE_REBOOT (2) // Configuration values have been modified with a requested reboot

An application can choose to ignore the parameters or add it's own. For custom reasons, the application should call NBApproveShutdown() with the appropriate reason:

// Custom reboot reason. System reasons start at 1, so pick something much larger
#define SHUTDOWN_CUSTOM_REBOOT 100
if( NBApproveShutdown(SHUTDOWN_CUSTOM_REBOOT))
{
}
#define TICKS_PER_SECOND
System clock ticks per second.
Definition nbrtos/include/constants.h:41
void ForceReboot(bool bFromException=false)
Forces the system hardware to perform a soft reset.
void OSTimeDly(uint32_t to_count)
Delay the task until the specified value of the system timer ticks. The number of system ticks per se...
Definition nbrtos.h:1732
bool NBApproveShutdown(int reason)
Approve action that will result in a reboot.
Definition NBApproveShutdown/src/main.cpp:25

This example provides a serial port menu with options enable or disable a reboot for application or settings updates. For testing purposes you can select reboot from the serial menu, or attempt an application code update.