static bool send_window(SimplyMsg *self, Command type, uint32_t id) { if (!s_broadcast_window) { return false; } WindowEventPacket packet = { .packet.type = type, .packet.length = sizeof(packet), .id = id, }; return simply_msg_send_packet(&packet.packet); } static bool send_window_show(SimplyMsg *self, uint32_t id) { return send_window(self, CommandWindowShowEvent, id); } static bool send_window_hide(SimplyMsg *self, uint32_t id) { return send_window(self, CommandWindowHideEvent, id); } bool simply_window_stack_set_broadcast(bool broadcast) { bool was_broadcast = s_broadcast_window; s_broadcast_window = broadcast; return was_broadcast; }
static bool send_voice_data(int status, char *transcription) { size_t transcription_length = strlen(transcription) + 1; size_t packet_length = sizeof(VoiceDataPacket) + transcription_length; uint8_t buffer[packet_length]; VoiceDataPacket *packet = (VoiceDataPacket *)buffer; *packet = (VoiceDataPacket) { .packet.type = CommandVoiceData, .packet.length = packet_length, .status = (uint8_t) status, }; strncpy(packet->result, transcription, transcription_length); return simply_msg_send_packet(&packet->packet); } #ifndef PBL_SDK_2 // Define a callback for the dictation session static void dictation_session_callback(DictationSession *session, DictationSessionStatus status, char *transcription, void *context) { s_voice->in_progress = false; // Send the result send_voice_data(status, transcription); }