m2session* otapi_task_advertise(advert_tmpl* adv_tmpl, session_tmpl* s_tmpl, ot_app applet) { /// This is a more complicated process than the others, because it actually /// creates two sessions: one for the flood and one for the request. # define _FLOOD_NETSTATE (M2_NETFLAG_FLOOD | M2_NETSTATE_INIT | M2_NETSTATE_REQTX) ot_u8 scratch; m2session* session; /// 1. Clear any sessions between now and the request, and push the /// request session onto the stack. If the push failed, exit. If the /// advertising is 0, also exit and do this session without flood. session_crop(adv_tmpl->duration); session = sub_newtask(s_tmpl, applet, adv_tmpl->duration); if ((session == NULL) || (adv_tmpl->duration == 0)) return NULL; /// 2. Flood duty cycling is not supported at this time. All floods /// are implemented as 100% duty cycle. /// 3. Push the Advertising session onto the stack, for immediate running. /// <LI> Use the same subnet for the advertising as for the request. </LI> /// <LI> For basic flooding, the applet can be empty </LI> scratch = session->subnet; session = session_new(&otutils_applet_null, 0, _FLOOD_NETSTATE, adv_tmpl->channel); if (session == NULL) { session_pop(); //pop the request session from above return NULL; } session->subnet = scratch; return session; }
m2session* otapi_task_immediate(session_tmpl* s_tmpl, ot_app applet) { /// Make sure the radio is stopped, flush any interfering sessions, /// and create the new session to occur immediately (offset = 0). if (radio.state != RADIO_Idle) { rm2_kill(); } session_flush(); return sub_newtask(s_tmpl, applet, 0); }
m2session* m2task_schedule(session_tmpl* s_tmpl, ot_app applet, ot_u16 offset) { return sub_newtask(s_tmpl, applet, offset); }
m2session* m2task_immediate(session_tmpl* s_tmpl, ot_app applet) { /// This call doesn't actually cause the session to occur immediately, /// but it will happen immediately following any sessions happenning /// at this very moment. return sub_newtask(s_tmpl, applet, 0); }