Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67fa393296 | ||
|
|
430a3e3381 | ||
|
|
9694b7586f | ||
|
|
e49bb9888f | ||
|
|
91e9b2e66b | ||
|
|
53d480c1fd | ||
|
|
0422d754a1 |
+1
-3
@@ -1,8 +1,6 @@
|
||||
@echo off
|
||||
set CURDIR=%~dp0
|
||||
set time0=%time: =0%
|
||||
set hour=%time0:~0,2%
|
||||
set appbuildtime=%date:~0,4%%date:~5,2%%date:~8,2%%hour%%time:~3,2%%time:~6,2%
|
||||
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyyMMddHHmmss"') do set appbuildtime=%%i
|
||||
set appbuildrev=NULL
|
||||
set appbuildmodel=EG800AKCN_11LG
|
||||
set appbuildver=beta1
|
||||
|
||||
@@ -29,6 +29,7 @@ extern int fota_start;
|
||||
#define KEY_LONG_PRESS_1S 1000/5
|
||||
#define KEY_LONG_PRESS_1_5S 1500/5
|
||||
#define KEY_LONG_PRESS_3S 3000/5
|
||||
#define PWRKEY_SOFT_SHUTDOWN_TEST 8000/5
|
||||
#define KEY_LONG_PRESS_5S 5000/5
|
||||
#define KEY_LONG_PRESS_10S 10000/5
|
||||
|
||||
@@ -114,7 +115,7 @@ static void key_thread_entry(void *parameter)
|
||||
if(level!=0){ //up
|
||||
key_press_mic_status = 0;
|
||||
|
||||
if(ql_rtos_get_systicks() - key_press_mic_time > KEY_LONG_PRESS_3S){
|
||||
if(ql_rtos_get_systicks() - key_press_mic_time > PWRKEY_SOFT_SHUTDOWN_TEST){
|
||||
//app_play_tips_file(10);
|
||||
// power_down_status = 1;
|
||||
ql_rtos_task_sleep_s(3);
|
||||
@@ -148,7 +149,7 @@ static void key_thread_entry(void *parameter)
|
||||
key_press_mic_status = 1;//表示已经按下了
|
||||
}
|
||||
|
||||
if(ql_rtos_get_systicks() - key_press_mic_time > KEY_LONG_PRESS_3S && power_down_status==0){
|
||||
if(ql_rtos_get_systicks() - key_press_mic_time > PWRKEY_SOFT_SHUTDOWN_TEST && power_down_status==0){
|
||||
power_down_status = 1;
|
||||
app_play_tips_file(10);
|
||||
power_down_status = 2;
|
||||
|
||||
@@ -36,7 +36,7 @@ const char *mp3_file[] ={
|
||||
"ai_active_zh.mp3",//18
|
||||
};
|
||||
|
||||
//http://175.24.73.253/assets/roles/zhuli/zh/tts_error.mp3
|
||||
//http://banban.api.talkingq.com:8080/assets/roles/banban/tts_error.mp3
|
||||
|
||||
//#define PCM_FILE "http://47.113.99.138:7050/output_16k.pcm"
|
||||
|
||||
@@ -194,7 +194,7 @@ void app_file_check_download(void)
|
||||
if(ql_access(filename_buff, 0)!=0){
|
||||
printf("downing mp3 file %d,%s\r\n", index,filename_buff);
|
||||
down_loop:
|
||||
sprintf(url_buff, "http://101.35.224.118:8080/assets/roles/banban/%s", mp3_file[index]);
|
||||
sprintf(url_buff, "http://banban.api.talkingq.com:8080/assets/roles/banban/%s", mp3_file[index]);
|
||||
|
||||
ret = http_file_download(url_buff);
|
||||
if(ret!=0&&cnt++<3) goto down_loop;
|
||||
|
||||
@@ -368,7 +368,7 @@ int parse_event_response(const char *json_str, response_t *resp)
|
||||
}
|
||||
else {
|
||||
// ===== 原有逻辑: NFC事件 - 动态查找 url_x 字段 =====
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
char key[16];
|
||||
snprintf(key, sizeof(key), "url_%d", i);
|
||||
cJSON *url = cJSON_GetObjectItem(params, key);
|
||||
@@ -391,11 +391,12 @@ int parse_event_response(const char *json_str, response_t *resp)
|
||||
|
||||
|
||||
/* [FIX] 安全处理 topic 名称,避免越界访问 */
|
||||
static void messageArrived(MessageData* data)
|
||||
{
|
||||
int ret;
|
||||
uint32 queue_count = 0;
|
||||
app_work_item *work_item;
|
||||
static void messageArrived(MessageData* data)
|
||||
{
|
||||
int ret;
|
||||
int payload_log_len;
|
||||
uint32 queue_count = 0;
|
||||
app_work_item *work_item;
|
||||
|
||||
// 安全获取 topic 字符串(复制到本地缓冲区)
|
||||
char topic_buf[128] = {0};
|
||||
@@ -403,10 +404,16 @@ static void messageArrived(MessageData* data)
|
||||
if (topic_len >= sizeof(topic_buf)) {
|
||||
topic_len = sizeof(topic_buf) - 1;
|
||||
}
|
||||
memcpy(topic_buf, data->topicName->lenstring.data, topic_len);
|
||||
topic_buf[topic_len] = '\0';
|
||||
|
||||
// 比较 topic 类型
|
||||
memcpy(topic_buf, data->topicName->lenstring.data, topic_len);
|
||||
topic_buf[topic_len] = '\0';
|
||||
|
||||
payload_log_len = data->message->payloadlen > 512 ? 512 : (int)data->message->payloadlen;
|
||||
printf("[MQTT-RX] topic=%s len=%d payload=%.*s%s\r\n",
|
||||
topic_buf, (int)data->message->payloadlen, payload_log_len,
|
||||
(const char *)data->message->payload,
|
||||
data->message->payloadlen > (unsigned int)payload_log_len ? "..." : "");
|
||||
|
||||
// 比较 topic 类型
|
||||
int is_command = (strstr(topic_buf, "command") != NULL);
|
||||
int is_event_resp = (strstr(topic_buf, "event_resp") != NULL) || (strstr(topic_buf, imei_buf) != NULL);
|
||||
|
||||
@@ -618,15 +625,33 @@ sub_exit:
|
||||
//0:代表respone command
|
||||
//1:代表send event
|
||||
/* [FIX] 将连接状态检查和发送放在同一锁保护区内,避免竞争 */
|
||||
int app_mqtt_publish(char *buf, int len, int type)
|
||||
{
|
||||
static uint32_t mqtt_pub_cnt_err=0;
|
||||
int rc = -1;
|
||||
MQTTMessage message;
|
||||
int cnt = 0;
|
||||
static uint8_t publish_error = 0;
|
||||
|
||||
// 锁保护:检查连接状态并发送
|
||||
int app_mqtt_publish(char *buf, int len, int type)
|
||||
{
|
||||
static uint32_t mqtt_pub_cnt_err=0;
|
||||
int rc = -1;
|
||||
int payload_log_len;
|
||||
MQTTMessage message;
|
||||
int cnt = 0;
|
||||
static uint8_t publish_error = 0;
|
||||
const char *publish_topic = NULL;
|
||||
|
||||
if (type == 0) {
|
||||
publish_topic = respone_topicName;
|
||||
} else if (type == 1) {
|
||||
publish_topic = event_topicName;
|
||||
} else if (type == 2) {
|
||||
publish_topic = event_register;
|
||||
} else {
|
||||
RLOGE("invalid MQTT publish type=%d", type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
payload_log_len = len > 512 ? 512 : len;
|
||||
printf("[MQTT-TX] topic=%s len=%d payload=%.*s%s\r\n",
|
||||
publish_topic, len, payload_log_len, buf,
|
||||
len > payload_log_len ? "..." : "");
|
||||
|
||||
// 锁保护:检查连接状态并发送
|
||||
int lock_ret = ql_rtos_mutex_lock(g_mqtt_public_mutex, 5000);
|
||||
if (lock_ret != 0) {
|
||||
RLOGE("MQTT mutex lock timeout");
|
||||
@@ -643,18 +668,13 @@ int app_mqtt_publish(char *buf, int len, int type)
|
||||
message.payload = buf;
|
||||
message.payloadlen = len;
|
||||
|
||||
while (cnt++ < 3) {
|
||||
u32 start = ql_rtos_get_systicks();
|
||||
if (type == 0) {
|
||||
rc = MQTTPublish(&client, respone_topicName, &message);
|
||||
} else if (type == 1) {
|
||||
rc = MQTTPublish(&client, event_topicName, &message);
|
||||
} else if (type == 2) {
|
||||
rc = MQTTPublish(&client, event_register, &message);
|
||||
}
|
||||
|
||||
RLOGD("Pulish time:%d len: %d\n", (ql_rtos_get_systicks()-start)*5, len);
|
||||
if (rc != 0) {
|
||||
while (cnt++ < 3) {
|
||||
u32 start = ql_rtos_get_systicks();
|
||||
rc = MQTTPublish(&client, publish_topic, &message);
|
||||
|
||||
RLOGD("Pulish time:%d len: %d\n", (ql_rtos_get_systicks()-start)*5, len);
|
||||
printf("[MQTT-TX] topic=%s attempt=%d rc=%d\r\n", publish_topic, cnt, rc);
|
||||
if (rc != 0) {
|
||||
mqtt_pub_cnt_err++;
|
||||
mqtt_public_error = 1;
|
||||
RLOGE("ERROR Return code from MQTT publish is %d, cnt %d", rc, mqtt_pub_cnt_err);
|
||||
@@ -1250,23 +1270,34 @@ void handle_nfc_trigger(const char *uuid)
|
||||
free(json_str);
|
||||
}
|
||||
|
||||
void handle_nfc_bind(const char *uuid)
|
||||
{
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
cJSON *data = cJSON_CreateObject();
|
||||
|
||||
cJSON_AddStringToObject(root, "msg_id", "006");
|
||||
cJSON_AddStringToObject(root, "status", "success");
|
||||
|
||||
cJSON_AddStringToObject(data, "uuid", uuid);
|
||||
cJSON_AddItemToObject(root, "data", data);
|
||||
|
||||
char *json_str = cJSON_PrintUnformatted(root);
|
||||
cJSON_Delete(root);
|
||||
|
||||
app_mqtt_publish(json_str, strlen(json_str), 0);
|
||||
free(json_str);
|
||||
}
|
||||
void handle_nfc_bind(const char *uuid)
|
||||
{
|
||||
char iccid[QL_SIM_ICCID_LEN * 2 + 1] = {0};
|
||||
QL_SIM_ERROR_CODE sim_ret;
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
cJSON *data = cJSON_CreateObject();
|
||||
|
||||
cJSON_AddStringToObject(root, "msg_id", "006");
|
||||
cJSON_AddStringToObject(root, "status", "success");
|
||||
|
||||
cJSON_AddStringToObject(data, "uuid", uuid);
|
||||
|
||||
sim_ret = ql_sim_get_iccid(iccid, sizeof(iccid));
|
||||
if (sim_ret == QL_SIM_SUCCESS && iccid[0] != '\0') {
|
||||
printf("NFC bind ICCID:%s\r\n", iccid);
|
||||
cJSON_AddStringToObject(data, "iccid", iccid);
|
||||
} else {
|
||||
printf("NFC bind get ICCID failed, ret:%d\r\n", sim_ret);
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(root, "data", data);
|
||||
|
||||
char *json_str = cJSON_PrintUnformatted(root);
|
||||
cJSON_Delete(root);
|
||||
|
||||
app_mqtt_publish(json_str, strlen(json_str), 0);
|
||||
free(json_str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3741,6 +3741,10 @@ extern void chargeManagePhase2Init(void);
|
||||
void PMIC_Phase2Init(void)
|
||||
{
|
||||
INTC_ReturnCode intcStatus;
|
||||
#if !defined(NOT_SUPPORT_PM807)
|
||||
UINT8 longkey_e3;
|
||||
UINT8 longkey_e4;
|
||||
#endif
|
||||
|
||||
PMIC_UART_DEBUG("PMIC_Phase2Init");
|
||||
|
||||
@@ -3780,6 +3784,30 @@ void PMIC_Phase2Init(void)
|
||||
#if !defined(NOT_SUPPORT_PM807)
|
||||
case PMIC_807:
|
||||
GuilinLite3ClkInit();
|
||||
longkey_e3 = PMIC_READ_REG_BASE(GUILIN_LITE3_RTC_MISC_3_REG);
|
||||
longkey_e4 = PMIC_READ_REG_BASE(GUILIN_LITE3_CLK_32K_SEL_REG);
|
||||
RTI_LOG("PM807 LONGKEY before: E3=0x%x time=%ds E4=0x%x en1=%d en2=%d",
|
||||
longkey_e3, (((longkey_e3 >> 4) & 0x0f) + 1), longkey_e4,
|
||||
!!(longkey_e4 & GUILIN_LITE3_LONGKEY_EN1),
|
||||
!!(longkey_e4 & GUILIN_LITE3_LONGKEY_EN2));
|
||||
|
||||
PM812_SET_LONKEY_PRESS_TIME(2);
|
||||
PM812_LONKEY_ENABLE_SET(GUILIN_LITE3_LONGKEY_1, TRUE);
|
||||
PM812_LONKEY_ENABLE_SET(GUILIN_LITE3_LONGKEY_2, TRUE);
|
||||
|
||||
longkey_e3 = PMIC_READ_REG_BASE(GUILIN_LITE3_RTC_MISC_3_REG);
|
||||
longkey_e4 = PMIC_READ_REG_BASE(GUILIN_LITE3_CLK_32K_SEL_REG);
|
||||
RTI_LOG("PM807 LONGKEY after: E3=0x%x time=%ds E4=0x%x en1=%d en2=%d",
|
||||
longkey_e3, (((longkey_e3 >> 4) & 0x0f) + 1), longkey_e4,
|
||||
!!(longkey_e4 & GUILIN_LITE3_LONGKEY_EN1),
|
||||
!!(longkey_e4 & GUILIN_LITE3_LONGKEY_EN2));
|
||||
if ((((longkey_e3 >> 4) & 0x0f) != 1) ||
|
||||
((longkey_e4 & (GUILIN_LITE3_LONGKEY_EN1 | GUILIN_LITE3_LONGKEY_EN2)) !=
|
||||
(GUILIN_LITE3_LONGKEY_EN1 | GUILIN_LITE3_LONGKEY_EN2)))
|
||||
{
|
||||
RTI_LOG("PM807 LONGKEY configure failed: E3=0x%x E4=0x%x",
|
||||
longkey_e3, longkey_e4);
|
||||
}
|
||||
// GuilinLite3_VBUCK1_Set_FPWM();
|
||||
break;
|
||||
#endif
|
||||
@@ -4231,6 +4259,13 @@ UINT8 PM812_GET_LONKEY_PRESS_TIME(void)
|
||||
return (((tmp >> 4) & 0x0f) + 1);
|
||||
}
|
||||
#endif
|
||||
#if !defined(NOT_SUPPORT_PM807)
|
||||
else if(PMIC_IS_PM807())
|
||||
{
|
||||
tmp = PMIC_READ_REG_BASE(GUILIN_LITE3_RTC_MISC_3_REG);
|
||||
return (((tmp >> 4) & 0x0f) + 1);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
return tmp;
|
||||
@@ -4241,6 +4276,10 @@ UINT8 PM812_GET_LONKEY_PRESS_TIME(void)
|
||||
void PM812_SET_LONKEY_PRESS_TIME(UINT8 sec)
|
||||
{
|
||||
UINT8 tmp;
|
||||
#if !defined(NOT_SUPPORT_PM807)
|
||||
UINT8 target;
|
||||
UINT8 bit;
|
||||
#endif
|
||||
|
||||
#if !defined(NOT_SUPPORT_PM802)
|
||||
if (PMIC_IS_PM802()||PMIC_IS_PM802S())
|
||||
@@ -4268,6 +4307,30 @@ void PM812_SET_LONKEY_PRESS_TIME(UINT8 sec)
|
||||
PMIC_WRITE_REG_BASE(NINGBO_RTC_MISC_3_REG,(tmp|sec));
|
||||
}
|
||||
#endif
|
||||
#if !defined(NOT_SUPPORT_PM807)
|
||||
else if(PMIC_IS_PM807())
|
||||
{
|
||||
if ((sec < 1) || (sec > 16))
|
||||
{
|
||||
RTI_LOG("PM807 invalid LONGKEY time: %d", sec);
|
||||
return;
|
||||
}
|
||||
|
||||
tmp = PMIC_READ_REG_BASE(GUILIN_LITE3_RTC_MISC_3_REG);
|
||||
target = (tmp & 0x0f) | ((sec - 1) << 4);
|
||||
|
||||
/* RTC_MISC_3 may only accept one changed bit per write. */
|
||||
for (bit = 4; bit < 8; bit++)
|
||||
{
|
||||
if ((tmp ^ target) & (1 << bit))
|
||||
{
|
||||
tmp = (tmp & ~(1 << bit)) | (target & (1 << bit));
|
||||
PMIC_WRITE_REG_BASE(GUILIN_LITE3_RTC_MISC_3_REG, tmp);
|
||||
tmp = PMIC_READ_REG_BASE(GUILIN_LITE3_RTC_MISC_3_REG);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void PM812_LONKEY_ENABLE_SET(UINT8 LONGKEY_NUM,BOOL enable)
|
||||
@@ -4324,6 +4387,22 @@ void PM812_LONKEY_ENABLE_SET(UINT8 LONGKEY_NUM,BOOL enable)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if !defined(NOT_SUPPORT_PM807)
|
||||
else if(PMIC_IS_PM807())
|
||||
{
|
||||
tmp = PMIC_READ_REG_BASE(GUILIN_LITE3_CLK_32K_SEL_REG);
|
||||
if(LONGKEY_NUM == GUILIN_LITE3_LONGKEY_1)
|
||||
{
|
||||
enable ? (tmp |= GUILIN_LITE3_LONGKEY_EN1) : (tmp &= (~GUILIN_LITE3_LONGKEY_EN1));
|
||||
PMIC_WRITE_REG_BASE(GUILIN_LITE3_CLK_32K_SEL_REG, tmp);
|
||||
}
|
||||
else if(LONGKEY_NUM == GUILIN_LITE3_LONGKEY_2)
|
||||
{
|
||||
enable ? (tmp |= GUILIN_LITE3_LONGKEY_EN2) : (tmp &= (~GUILIN_LITE3_LONGKEY_EN2));
|
||||
PMIC_WRITE_REG_BASE(GUILIN_LITE3_CLK_32K_SEL_REG, tmp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//LONGKEY_NUM: 1/2
|
||||
@@ -4352,6 +4431,13 @@ BOOL PM812_LONKEY_ENABLE_GET(UINT8 LONGKEY_NUM)
|
||||
((LONGKEY_NUM==NINGBO_LONGKEY_1)?NINGBO_LONGKEY_EN1:NINGBO_LONGKEY_EN2));
|
||||
}
|
||||
#endif
|
||||
#if !defined(NOT_SUPPORT_PM807)
|
||||
else if(PMIC_IS_PM807())
|
||||
{
|
||||
return (PMIC_READ_REG_BASE(GUILIN_LITE3_CLK_32K_SEL_REG) &
|
||||
((LONGKEY_NUM == GUILIN_LITE3_LONGKEY_1) ? GUILIN_LITE3_LONGKEY_EN1 : GUILIN_LITE3_LONGKEY_EN2));
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
PMIC_UART_DEBUG("PM812_LONKEY_ENABLE_GET: it shouldn't reach here, NUM=%d",LONGKEY_NUM);
|
||||
|
||||
Reference in New Issue
Block a user