refactor(extern_interface): rename and restructure telemetry data handling
- Rename ET_TYPE_TELEMETRY_REQUEST to ET_SYS_STATUS_WAKE - Rename get_telemetry_request_data to get_telemetry_data - Rename extern_interface_handle to handle_pack - Move telemetry data preparation from host_com.cpp to extern_interface - Simplify volume grade, system version, and application version handling
This commit is contained in:
parent
a2f04fb3cb
commit
c9ef0edda6
|
@ -0,0 +1,27 @@
|
|||
#ifndef _INCLUDE_EXTERN_INTERFACE_DETAIL_H_
|
||||
#define _INCLUDE_EXTERN_INTERFACE_DETAIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "extern_interface.h"
|
||||
|
||||
#define PrintFilePos()
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void handle_pack(uint32_t type, size_t len, union PacketData data);
|
||||
void get_telemetry_data(struct TelemetryRequestData* data);
|
||||
|
||||
void* telemetry_host_com_thread(void* args);
|
||||
void* upper_host_com_thread(void* arg);
|
||||
|
||||
extern int g_iHostCom_tty_id;
|
||||
extern int g_iEnableAlarmCode;
|
||||
extern uint8_t g_iAlarmCode[4];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -12,6 +12,8 @@
|
|||
#define ET_TYPE_ALARM 4
|
||||
#define ET_TYPE_TELEMETRY_REQUEST 5
|
||||
|
||||
#define ET_SYS_STATUS_WAKE 1
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define EXTERN_INTERFACE_PUBLIC __declspec(dllexport)
|
||||
#elif defined(__GNUC__)
|
||||
|
@ -28,7 +30,7 @@ struct TelemetryRequestData {
|
|||
int sys_state;
|
||||
bool volume_key_pressed;
|
||||
bool wakeup_key_pressed;
|
||||
int volume_grade;
|
||||
int volume_grade; // 0, 1, 2
|
||||
int sys_ver_high;
|
||||
int sys_ver_low;
|
||||
int app_ver_high;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <pthread.h>
|
||||
#include "extern_interface.h"
|
||||
#include "etif_detail.h"
|
||||
#include "event.h"
|
||||
#include "inicpp.hpp"
|
||||
|
||||
|
@ -13,6 +13,8 @@ int extern_interface_init(const char* config_path, et_callback_t cb) {
|
|||
et_callback = cb;
|
||||
|
||||
pthread_create(&event_thread, NULL, sys_event_thread, NULL);
|
||||
pthread_create(&upperhost_thread, NULL, upper_host_com_thread, NULL);
|
||||
pthread_create(&telemetry_thread, NULL, telemetry_host_com_thread, NULL);
|
||||
}
|
||||
|
||||
void extern_interface_send(uint32_t type, size_t len, union PacketData data) {
|
||||
|
@ -28,10 +30,10 @@ void extern_interface_send(uint32_t type, size_t len, union PacketData data) {
|
|||
}
|
||||
}
|
||||
|
||||
void extern_interface_handle(uint32_t type, size_t len, union PacketData data) {
|
||||
void handle_pack(uint32_t type, size_t len, union PacketData data) {
|
||||
et_callback(type, len, data);
|
||||
}
|
||||
|
||||
void get_telemetry_request_data(TelemetryRequestData* data) {
|
||||
extern_interface_handle(ET_TYPE_TELEMETRY_REQUEST, sizeof(TelemetryRequestData), { .pd_pointer = data });
|
||||
void get_telemetry_data(TelemetryRequestData* data) {
|
||||
handle_pack(ET_TYPE_TELEMETRY_REQUEST, sizeof(TelemetryRequestData), { .pd_pointer = data });
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "telemetry.h"
|
||||
#include "dataqueue.hpp"
|
||||
#include "command.h"
|
||||
#include "etif_detail.h"
|
||||
|
||||
#define PrintFilePos()
|
||||
|
||||
|
@ -25,22 +26,24 @@ volatile int32_t g_iMS2Reboot = 1000;
|
|||
|
||||
/* create a msg data for upper host telemetry*/
|
||||
void set_telemetry_host_data(TelemetryData4UpperHost* pTelemetryData) {
|
||||
TelemetryRequestData data;
|
||||
get_telemetry_data(&data);
|
||||
pTelemetryData->work_status = 0xAA;
|
||||
pTelemetryData->com_status = 0xAA;
|
||||
pTelemetryData->coprocessor1_status = 0xAA;
|
||||
pTelemetryData->coprocessor2_status = 0xAA;
|
||||
pTelemetryData->voice_circuit_status = 0xAA;
|
||||
pTelemetryData->telemetry_count = g_iUpperHostTelemetryCount++;
|
||||
if (g_bCloseASR) {
|
||||
if (data.close_asr) {
|
||||
pTelemetryData->voice_mode = 0xAA;
|
||||
}
|
||||
else if (g_iSysState == SYS_STATUS_WAKE) {
|
||||
else if (data.sys_state == ET_SYS_STATUS_WAKE) {
|
||||
pTelemetryData->voice_mode = 0x55;
|
||||
}
|
||||
else {
|
||||
pTelemetryData->voice_mode = 0xA5;
|
||||
}
|
||||
if (g_iSysState == SYS_STATUS_WAKE) {
|
||||
if (data.sys_state == ET_SYS_STATUS_WAKE) {
|
||||
pTelemetryData->recognition_status = 0x55;
|
||||
}
|
||||
else {
|
||||
|
@ -75,25 +78,15 @@ void set_telemetry_host_data(TelemetryData4UpperHost* pTelemetryData) {
|
|||
//}
|
||||
//pTelemetryData->volume_key_status = g_bVolumeKeyState ? 0xAA : 0x55;
|
||||
//pTelemetryData->wake_key_status = g_bWakeupKeyState ? 0xAA : 0x55;
|
||||
pTelemetryData->volume_key_status = g_bVolumeKeyPressed ? 0xAA : 0x55;
|
||||
pTelemetryData->wake_key_status = g_bWakeupKeyPressed ? 0xAA : 0x55;
|
||||
g_bVolumeKeyPressed = false;
|
||||
g_bWakeupKeyPressed = false;
|
||||
pTelemetryData->volume_key_status = data.volume_key_pressed ? 0xAA : 0x55;
|
||||
pTelemetryData->wake_key_status = data.wakeup_key_pressed ? 0xAA : 0x55;
|
||||
|
||||
pTelemetryData->key_status_backup = 0x55;
|
||||
if ( g_iCurVolumeGrade == g_iVolumeGradeCnt-1 ) {//large
|
||||
pTelemetryData->current_volume = 0x3;
|
||||
}
|
||||
else if ( g_iCurVolumeGrade == 0 ) {//small
|
||||
pTelemetryData->current_volume = 0x1;
|
||||
}
|
||||
else {//midium
|
||||
pTelemetryData->current_volume = 0x2;
|
||||
}
|
||||
pTelemetryData->system_version_high = g_iSysVerHigh;
|
||||
pTelemetryData->system_version_low = g_iSysVerLow;
|
||||
pTelemetryData->application_version_high = g_iAppVerHigh;
|
||||
pTelemetryData->application_version_low = g_iAppVerLow;
|
||||
pTelemetryData->current_volume = data.volume_grade;
|
||||
pTelemetryData->system_version_high = data.sys_ver_high;
|
||||
pTelemetryData->system_version_low = data.sys_ver_low;
|
||||
pTelemetryData->application_version_high = data.app_ver_high;
|
||||
pTelemetryData->application_version_low = data.app_ver_low;
|
||||
// 2024.10.10
|
||||
if (g_iEnableAlarmCode == 0) {
|
||||
pTelemetryData->alarm_code[0] = 0xAA;
|
||||
|
|
Loading…
Reference in New Issue