void app_invoke(ot_u8 channel) { /// The "External Task" is the place where the kernel runs the main user app. /// Our app has 4 functions (call types). /// <LI> The task event state is set to 1. Event 0 is always Task-off, but /// otherwise each task manages its own event numbers </LI> /// <LI> We store the channel in the cursor, which is not being used otherwise. /// The Task "cursor" can be used for additional state control, beyond the /// event number. </LI> /// <LI> We give it a runtime reservation of 1 tick (it runs pretty fast). /// This is also short enough to pre-empt RX listening, but not RX data. /// Try changing to a higher number, and observing how the kernel /// manages this task. </LI> /// <LI> We give it a latency of 255. Latency is unimportant for run-once /// tasks, so giving it the max latency will prevent it from blocking /// any other tasks. </LI> /// <LI> We tell it to start ASAP (preemption delay parameter = 0) </LI> /// /// @note The latency parameter is mostly useful for protocol management, /// for which you probably want to enforce a request-response turnaround time. /// for processing and for iterative tasks it is not important: set to 255. /// sys_task_setevent(APP_TASK, 1); sys_task_setcursor(APP_TASK, channel); sys_task_setreserve(APP_TASK, 1); sys_task_setlatency(APP_TASK, 255); sys_preempt(APP_TASK, 0); }
void network_sig_route(void* route, void* session) { /// network_sig_route() will have route >= 0 on successful request processing. /// "route" will always be set to -1, which will cause the Data Link Layer to /// ignore the rest of the session and keep listening (sniffing). static const ot_u8 unknown_rx[10] = "UNKNOWN_RX"; static const ot_u8 opentag_rx[10] = "OPENTAG_RX"; ot_u8* label; // A valid packet has been received. // You can look at the response in the TX Queue (and log it if you want). // We just log the request and mark it as known or unknown. if (*(ot_int*)route >= 0) { label = (ot_u8*)opentag_rx; } else { label = (ot_u8*)unknown_rx; } // Log the received packet data (with 10 character label) otapi_log_msg(MSG_raw, 10, rxq.length, label, rxq.front); // Turn on Green LED to indicate received packet // Activate the app task, which will turn off the LED in 30 ticks otapi_led1_on(); sys_task_setevent(APP_TASK, 1); sys_preempt(APP_TASK, 30); // Tell DLL to disregard session, no matter what. *(ot_int*)route = -1; }
void ext_systask(ot_task task) { switch (task->event) { case 0: break; case 1: // break and deactivate task if switch is *not* being held-down if (PALFI_WAKE_PORT->DIN & BOARD_SW2_PIN) { sys_task_setevent(task, 0); break; } case 2: { // Add new DASH7 comm task to kernel, using most defaults. session_tmpl s_tmpl; sys_task_setevent(task, 1); sys_task_setnext(task, 512); s_tmpl.channel = 7; s_tmpl.subnetmask = 0; s_tmpl.flagmask = 0; m2task_immediate(&s_tmpl, &applet_adcpacket); } break; } }
void PALFI_WAKE_ISR(void) { /// In this demo the PALFI LF interface is not initialized. However, there are /// some switches (buttons) that are attached to the PaLFI core, and they use /// the same interrupt. Those buttons are attached. if (PALFI_WAKE_PORT->IFG & BOARD_SW2_PIN) { sys_task_setevent(PALFI_TASK, 2); sys_task_setreserve(PALFI_TASK, 64); sys_task_setlatency(PALFI_TASK, 255); sys_preempt(PALFI_TASK, 0); } //if (PALFI_WAKE_PORT->IFG & PALFI_WAKE_PIN) { // sys_task_setevent(PALFI_TASK, 1); //} PALFI_WAKE_PORT->IFG = 0; }
void app_invoke(ot_u8 call_type) { /// The "External Task" is the place where the kernel runs the main user app. /// Our app has 4 functions (call types). /// <LI> We give it a runtime reservation of 1 tick (it runs pretty fast). /// This is also short enough to pre-empt RX listening, but not RX data. /// Try changing to a higher number, and observing how the kernel /// manages this task. </LI> /// <LI> We give it a latency of 255. Latency is unimportant for run-once /// tasks, so giving it the max latency will prevent it from blocking /// any other tasks. </LI> /// <LI> We tell it to start ASAP (next = 0) </LI> /// /// @note The latency parameter is mostly useful for protocol management, /// for which you probably want to enforce a request-response turnaround time. /// for processing and basic, iterative tasks it is not important: set to 255. /// sys_task_setevent(OPMODE_TASK, call_type); sys_task_setreserve(OPMODE_TASK, 1); sys_task_setlatency(OPMODE_TASK, 255); sys_preempt(OPMODE_TASK, 0); }