Files
banban/ql-application/threadx/interface/custom_app/inc/app_inc.h
T

252 lines
6.3 KiB
C

#ifndef _HAL_APP_INC_FILE_H
#define _HAL_APP_INC_FILE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdint.h>
#include "ql_rtos.h"
#define APP_VER "1.0.0"
#define ROM_VER "1.0.0"
#define RLOGV printf
#define RLOGD printf
#define RLOGI printf
#define RLOGW printf
#define RLOGE printf
#define LOG_W printf
#define LOG_I printf
#define LOG_E printf
#define LOG_D printf
#define VOLUME_10 106
#define VOLUME_20 110
#define VOLUME_30 114
#define VOLUME_40 118
#define VOLUME_50 122
#define VOLUME_60 126
#define VOLUME_70 130
#define VOLUME_80 134
#define VOLUME_90 138
#define VOLUME_100 142
#define ES8311_I2C 0
#define NFC_I2C 1
#define GNSS_FAST_MODE_HOLD_TIME 300000 //300s
#define GNSS_SLOW_MODE_SLEEP_TIME 300000 //300s
#define GNSS_FAST_MODE_HEART_REPORT_TIME 10000 //10s
#define GNSS_SLOW_MODE_HEART_REPORT_TIME 6 * 60 * 1000 //360s
#define APP_VOLUME_SAVE_TIME 30*1000 //30s
int app_net_mgt_init();
int app_ws_talkingq_init();
int app_http_aofei_init();
void app_http_aofei_net_ready();
void app_ws_talkingq_net_ready();
void app_aofei_key_init(void);
void app_audio_init(void);
void aofei_mp3_player(char *file_name);
void aofei_4g_mp3_player_stop(void);
void start_aofei_audio_key_func(void);
void xiaoice_wss_audio_in_task_del(void);
int app_get_data_call_net_status(void);
void app_data_recall(void);
void app_codec_pa_close(void);
void app_codec_pa_open(void);
//#define USING_MIC_8K
#define USING_MIC_16K
//#define USING_MIC_TEST
#define USING_MIC
void hal_led_init(void);
void hal_led_b_on(void);
void hal_led_b_off(void);
int app_uartsh_init();
typedef struct
{
int type;
int arg1;
int arg2;
int datalen;
uint8_t *data;
}app_work_item;
/* ÏûÏ¢ÀàÐÍö¾Ù */
typedef enum {
MSG_HEARTBEAT = 0, // ¶¨Ê±Éϱ¨
MSG_GPS_QUERY = 1, // GPSλÖòéѯ
MSG_VOLUME_SET = 2, // ÒôÁ¿µ÷½Ú
MSG_OTA_UPGRADE = 3, // OTAÉý¼¶
MSG_NFC_NOTICE = 4, // NFCÁôÑÔÏ·¢Ìáʾ
MSG_NFC_TRIGGER = 5, // NFC´¥·¢ÊÕÌýÁôÑÔ
MSG_NFC_BIND = 6, // NFC绑定
MSG_DEVICE_STATUS = 7, //设备开关状�
MSG_DEVICE_SLEEP = 8, //设置设备休眠时间段
MSG_DEVICE_WAKE = 9, //主动唤醒设备
MSG_DEVICE_ALARM = 10, //设备上报告警
MSG_KEY_LEAVE = 11, //给家长留言
MSG_GET_AUTH = 12, //获�SN和设备ID
} msg_type_t;
/* GPSÊý¾Ý½á¹¹ */
typedef struct {
double latitude;
double longitude;
} gps_data_t;
/* É豸ÐÅÏ¢½á¹¹Ìå */
typedef struct {
char device_id[32];
int power; // µçÁ¿ 10-100, ¼ä¸ô10
int signal; // ÐźŠ1-5
int voice; // ÒôÁ¿ 40-100, ¼ä¸ô20
char imei[32];
char version[64];
gps_data_t real_gps;
} device_info_t;
/* OTA²ÎÊý½á¹¹ */
typedef struct {
char url[256];
char version[16];
} ota_params_t;
/* NFCÁôÑÔ²ÎÊý */
typedef struct {
char url[256];
} nfc_notice_t;
typedef struct {
char url[256];
} nfc_bind_t;
/* NFC´¥·¢²ÎÊý */
typedef struct {
char uuid[64];
} nfc_trigger_t;
// 在 command_t 的 params ��中添加
typedef struct {
char start[6]; // "22:00"
char end[6]; // "07:00"
} sleep_params_t;
typedef struct {
char switch_state[4]; // "on" 或 "off"
} wake_params_t;
typedef struct {
char msg_id[8];
msg_type_t type;
int sub_type;
// 改为字符串存储UTC时间戳(16�数字 + '\0')
char time[20]; // 足够存16�数字 + 终止符
union {
int volume_level;
ota_params_t ota;
nfc_notice_t nfc;
nfc_bind_t bind;
sleep_params_t sleep;
wake_params_t wake;
} params;
} command_t;
typedef struct {
char msg_id[8];
char status[16]; // "success", "accepted", "error"
// 新增:011/012 通用�数解�
char url[256]; // 通用URL字段
char uuid[64]; // 设备UUID
char device_id[32]; // 012: DeviceID
char device_sn[32]; // 012: SN
char server_url[128]; // 012: �务器地�
union {
device_info_t device; // 心跳上报
gps_data_t gps; // GPS�应
int current_volume; // 音��应
struct {
char current_ver[16];
char target_ver[16];
char new_ver[16];
} version; // OTA版本信�
nfc_notice_t nfc; // NFC通知URL列表
} data;
int type; // NFC事件类型: 0普通, 1留言
} response_t;
// ========== 在代�头部添加 ==========
// 休眠�置结构体
typedef struct {
uint8_t start_hour; // 休眠开始�时 (0-23)
uint8_t start_min; // 休眠开始分钟 (0-59)
uint8_t end_hour; // 休眠结��时 (0-23)
uint8_t end_min; // 休眠结�分钟 (0-59)
uint8_t enable; // 0=�用 1=�用
} sleep_config_t;
typedef enum {
BAT_LEVEL_0 = 0, // 0% (关机)
BAT_LEVEL_10 = 10, // 20%
BAT_LEVEL_20 = 20, // 40%
BAT_LEVEL_30 = 30, // 60%
BAT_LEVEL_40 = 40, // 80%
BAT_LEVEL_50 = 50, // 100%
BAT_LEVEL_60 = 60, // 0% (关机)
BAT_LEVEL_70 = 70, // 20%
BAT_LEVEL_80 = 80, // 40%
BAT_LEVEL_90 = 90, // 60%
BAT_LEVEL_100 = 100, // 100%
} bat_level_t;
/*============================================================================
* Positioning mode enum and global structure definition
*===========================================================================*/
typedef enum {
GNSS_MODE_FAST = 0, // Fast positioning mode:30secondsInterval
GNSS_MODE_SLOW = 1 // Slow positioning mode:5minutesInterval
} gnss_mode_t;
// GPSPosition info global structure
typedef struct {
double latitude; // Latitude (degree format,e.g. 23.1171298)
double longitude; // Longitude (degree format,e.g. 113.2863118)
int is_valid; // Data validity (1=valid, 0=invalid)
char raw_nmea[256]; // Raw NMEA sentence
} gps_location_info_t;
#ifdef __cplusplus
}
#endif
#endif