Пример #1
0
void ext_systask(ot_task task) {
    session_tmpl    s_tmpl;

    if (task->event == 1) {
        task->event = 0;
        
        // this is the same as the length of the response window,
        // which is set in applet_send_query()
        task->nextevent = 512;  
    
        // Generate a pseudo random 16 bit number to be used as a ping check value
        app.pingval = platform_prand_u16();
    
        // Log a message.  It is scheduled, and the RF task has higher priority,
        // so if you are sending a DASH7 dialog this log message will usually
        // come-out after the dialog finishes.
#       if (OT_FEATURE(MPIPE))
        otapi_log_msg(MSG_raw, 5, 2, (ot_u8*)"PING:", (ot_u8*)&app.pingval);
#       endif
    
        // Load the session template: Only used for communication tasks
        s_tmpl.channel      = task->cursor;
        s_tmpl.flagmask     = 0;
        s_tmpl.subnetmask   = 0;
        otapi_task_immediate(&s_tmpl, &applet_send_query);
    }
    
    // Turn off the task after 512 ticks (what is set above)
    // Note that this task will not be activated by the button press or ALP
    // when event != 0, because those routines have conditionals in them.
    //else {
    //    task->event = 0;
    //}
}
Пример #2
0
void ext_systask(ot_task task) {
    advert_tmpl     adv_tmpl;
    session_tmpl    s_tmpl;

    if (task->event == 1) {
        task->event++;
        
        // this is the same as the length of the response window,
        // which is set in applet_send_query()
        task->nextevent = 512;  
    
        // Generate a pseudo random 16 bit number to be used as a ping check value
        app.pingval = platform_prand_u16();
    
#       if defined(BOARD_eZ430Chronos)

#       else
        // Log a message.  It is scheduled, and the RF task has higher priority,
        // so if you are sending a DASH7 dialog this log message will usually
        // come-out after the dialog finishes.
        otapi_log_msg(MSG_raw, 5, 8, (ot_u8*)"PING:", (ot_u8*)&app.pingval);
#       endif
        
        // Advert Tmpl: most of the parameters are for special purposes only
        adv_tmpl.channel    = 7;
        adv_tmpl.duration   = 1024;
        
        // Load the session template: Only used for communication tasks
        s_tmpl.channel      = task->cursor;
        s_tmpl.flagmask     = 0;
        s_tmpl.subnetmask   = 0;
        
        otapi_task_advertise(&adv_tmpl, &s_tmpl, &applet_send_query);
    }
    
    // Turn off the task after 512 ticks (what is set above)
    // Note that this task will not be activated by the button press or ALP
    // when event != 0, because those routines have conditionals in them.
    else {
        task->event = 0;
    }
}