void applet_send_beacon(m2session* session) { { //open request for broadcast otapi_open_request(ADDR_broadcast, NULL); } { //use a command template for collection of single file from single file search ot_u8 status; command_tmpl command; command.opcode = (ot_u8)CMD_announce_file; command.type = (ot_u8)CMDTYPE_na2p_request; command.extension = (ot_u8)CMDEXT_no_response; otapi_put_command_tmpl(&status, &command); } { //write the dialog information (timeout, channels to use) ot_u8 status; dialog_tmpl dialog; dialog.channels = 0; //use same channel as request for response dialog.timeout = 0; //0 tick response timeout (1 tick = 0,977 ms) otapi_put_dialog_tmpl(&status, &dialog); } { //write the ISF return data (note: use isfcall template) ot_u8 status; isfcall_tmpl isfcall; isfcall.is_series = False; isfcall.isf_id = ISF_ID(network_settings); isfcall.max_return = ISF_LEN(network_settings); isfcall.offset = 0; otapi_put_isf_return(&status, &isfcall); } //Done building command, close the request and send the dialog otapi_close_request(); }
ot_bool applet_beacon_discovery() { { //create a new session (it will get copied to session stack) session_tmpl session; session.channel = 0x00; session.flagmask = 0; session.flags = 0; session.subnet = 0; session.subnetmask = 0; session.timeout = 16; otapi_new_session(&session, NULL); } { //open request for broadcast otapi_open_request(ADDR_broadcast, NULL); } { //use a command template for collection of single file from single file search ot_u8 status; command_tmpl command; command.opcode = (ot_u8)CMD_announce_file; command.type = (ot_u8)CMDTYPE_na2p_request; command.extension = (ot_u8)CMDEXT_no_response; otapi_put_command_tmpl(&status, &command); } { //write the dialog information (timeout, channels to use) ot_u8 status; dialog_tmpl dialog; dialog.channels = 0; //use same channel as request for response dialog.timeout = 0; //0 tick response timeout (1 tick = 0,977 ms) otapi_put_dialog_tmpl(&status, &dialog); } { //write the ISF return data (note: use isfcall template) ot_u8 status; isfcall_tmpl isfcall; isfcall.is_series = False; isfcall.isf_id = ISF_ID(network_settings); isfcall.max_return = ISF_LEN(network_settings); isfcall.offset = 0; otapi_put_isf_return(&status, &isfcall); } //Done building command, close the request and send the dialog otapi_close_request(); //otapi_start_dialog(); return True; }