[En-Nut-Discussion] Configuration of IP adress and reboot

Harald Kipp harald.kipp at egnite.de
Tue Aug 23 17:19:26 CEST 2011


On 8/23/2011 2:36 PM, Wiegelmann, Jörg wrote:
> it isn't possible to call the default handler because it is static.

If you look more carefully to the example, you'll notice this line

 default_handler = NutRegisterDiscoveryCallback(MyHandler);

The function returns the currently installed handler (before the call),
which is the default handler after initialization.

Within your handler you call the default handler with

  (*default_handler)(ip, port, dist, len);

and then do a hardware reset.

The reason for implementing it this way is, that more than one handler
may be registered without knowing about each other.

 handler1 = NutRegisterDiscoveryCallback(MyHandlerA);
 ...
 int MyHandlerA()
 {
  /* Do stuff */
  (*handler1)();
  /* Do stuff */
 }
 ...
 handler2 = NutRegisterDiscoveryCallback(MyHandlerB);
 ...
 int MyHandlerB()
 {
  /* Do stuff */
  (*handler2)();
  /* Do stuff */
 }

If MyHandlerA is registered first, it will replace the default handler
and call the default handler. The registration of MyHandlerB will
replace MyHandlerA and call MyHandlerA, which in turn calls the default
handler.

Regards,

Harald



More information about the En-Nut-Discussion mailing list