ZUNO_SETUP_SYSEVENT_HANDLER()

Set up a handler for Z-Uno system events such as: inclusion start/stop, firmware update start, Z-Uno boot and go into sleep as well as system faults like stack overflow or blocked packets due to the policy to debug. ZUNO_SETUP_SYSEVENT_HANDLER(handler) handler function that handles events void sys_event(byte event, byte param) { ... } event event type from the list ZUNO_LOGGING_EVENT_* param additional parameter for the event
            ZUNO_SETUP_SYSEVENT_HANDLER(sys_event);
            void sys_event(byte event, byte param) {
                switch(event) {
                case ZUNO_LOGGING_EVENT_LEARNSTART:
                    // some action
                    break;
                case ZUNO_LOGGING_EVENT_LEARNCOMPLETE:
                    // some action
                    break;
                case ZUNO_LOGGING_EVENT_FWAUTH:
                    // some action
                    break;
                case ZUNO_LOGGING_EVENT_STACKOVERFLOW:
                    // OOOPS! Error handling
                    break;
                } 
            }
            
       
Full list of events is available in ZUNO_Definitions.h (search for ZUNO_LOGGING_EVENT_).
void sys_event(ZUNOSysEvent_t * ev) { ... }
ev pointer to type ZUNOSysEvent_t nothing
            
    typedef struct ZUNOSysEvent_s{
        uint8_t event;
        uint32_t params[2];
    }ZUNOSysEvent_t;
            
        
event One of following values:
  • ZUNO_SYS_EVENT_QUICKWAKEUP
  • Z-Uno wakes up from EM2 energy mode
  • ZUNO_SYS_EVENT_LEARNCOMPLETED
  • Z-Uno was added to network or exluded from the network. Learn process has been finished.
  • ZUNO_SYS_EVENT_LEARNSTARTED
  • Process of network inclusion/exclusion has started.
  • ZUNO_SYS_EVENT_SETDEFAULT
  • Configuration of device was cleaned up.
  • ZUNO_SYS_EVENT_SLEEP_MODEEXC
  • Warning, user tries to go to sleep listening device. Don't call zunoSendDeviceToSleep() for listening devices.
  • ZUNO_SYS_EVENT_STACK_OVERFLOW
  • Firmware detected user stack overflow. Be careful with recursion and large amounts of local data inside nested functions.
  • ZUNO_SYS_EVENT_QUEUE_OVERLOAD
  • IRQ queue is full. System can miss some interrupts.
  • ZUNO_SYS_EVENT_INVALID_TX_REQUEST
  • Z-Uno tries to send an invalid message.
  • ZUNO_SYS_EVENT_INVALID_COMMAND
  • User calls unknowm system call number. param[0] is invalid system call vector.
  • ZUNO_SYS_EVENT_INVALID_CLOCK
  • Unknown peripheral clock source. param[0] is invalid translated clock index.
  • ZUNO_SYS_EVENT_INVALID_MEMORYAREA_IN_SYSCALL
  • User translates illegal memory pointer to syscall. param[0] is a system call vector number, param[1] is system call parameter number.
  • ZUNO_SYS_EVENT_INVALID_PARAMNUM_IN_SYSCALL
  • Syscall parameter number doesn't match to reference. param[0] is a system call vector number.
  • ZUNO_SYS_EVENT_INVALID_SYSCALL_PARAM_VALUE
  • Syscall parameter is invalid. param[0] is a system call vector number, param[1] is system call parameter number.
params Depends on event field. Represents aditional event data. See above.
            ZUNO_SETUP_SYSEVENT_HANDLER(sys_event);
            void sys_event(ZUNOSysEvent_t * e) {
                switch(e->event) {
                case ZUNO_LOGGING_EVENT_LEARNSTART:
                    // some action
                    break;
                case ZUNO_LOGGING_EVENT_LEARNCOMPLETE:
                    // some action
                    break;
                case ZUNO_LOGGING_EVENT_STACKOVERFLOW:
                    // OOOPS! Error handling
                    break;
                } 
            }
            
       
If you need to setup handler "on the run" see zunoAttachSysHandler