MODULE_CALLTYPE static u16 cflie_callback() { switch (phase) { case CFLIE_INIT_SEARCH: send_search_packet(); phase = CFLIE_SEARCH; break; case CFLIE_INIT_CRTP_LOG: if (crtp_log_setup_state_machine()) { phase = CFLIE_INIT_DATA; } break; case CFLIE_INIT_DATA: send_cmd_packet(); phase = CFLIE_DATA; break; case CFLIE_SEARCH: switch (packet_ack()) { case PKT_PENDING: return PACKET_CHKTIME; // packet send not yet complete case PKT_ACKED: phase = CFLIE_DATA; PROTOCOL_SetBindState(0); MUSIC_Play(MUSIC_DONE_BINDING); break; case PKT_TIMEOUT: send_search_packet(); counter = BIND_COUNT; } break; case CFLIE_DATA: if (Model.proto_opts[PROTOOPTS_TELEMETRY] == TELEM_ON_CRTPLOG) { update_telemetry_crtplog(); } else if (Model.proto_opts[PROTOOPTS_TELEMETRY] == TELEM_ON_ACKPKT) { update_telemetry_ackpkt(); } if (packet_ack() == PKT_PENDING) return PACKET_CHKTIME; // packet send not yet complete send_cmd_packet(); break; } return PACKET_PERIOD; // Packet at standard protocol interval }
MODULE_CALLTYPE static u16 cflie_callback() { switch (phase) { case CFLIE_INIT_SEARCH: send_search_packet(); phase = CFLIE_SEARCH; break; case CFLIE_INIT_TELEMETRY: if (telemetry_setup_state_machine()) { phase = CFLIE_INIT_DATA; } break; case CFLIE_INIT_DATA: send_cmd_packet(); phase = CFLIE_DATA; break; case CFLIE_SEARCH: switch (packet_ack()) { case PKT_PENDING: return PACKET_CHKTIME; // packet send not yet complete case PKT_ACKED: phase = CFLIE_DATA; PROTOCOL_SetBindState(0); MUSIC_Play(MUSIC_DONE_BINDING); break; case PKT_TIMEOUT: send_search_packet(); counter = BIND_COUNT; } break; case CFLIE_DATA: update_telemetry(); if (packet_ack() == PKT_PENDING) return PACKET_CHKTIME; // packet send not yet complete send_cmd_packet(); break; } return PACKET_PERIOD; // Packet at standard protocol interval }