This commit is contained in:
haped 2025-07-24 14:32:42 +08:00
commit bace157a54
17 changed files with 23198 additions and 20752 deletions

View File

@ -112,6 +112,12 @@
"force_ps_pub.h": "c",
"generic.h": "c",
"rtc_reg.h": "c",
"rtc_reg_pub.h": "c"
"rtc_reg_pub.h": "c",
"sockets.h": "c",
"utils_timer.h": "c",
"utils_net.h": "c",
"lite-log.h": "c",
"netdb.h": "c",
"rtc.h": "c"
}
}

View File

@ -17,6 +17,7 @@
#include "app_voice_player.h"
#include "BkDriverFlash.h"
#include "manual_ps_pub.h"
#ifdef PKG_USING_EASYFLASH
#include "easyflash.h"
@ -381,6 +382,7 @@ UINT32 usb_power_is_pluged(void)
return (reg & (1 << 21));
}
void box_poweroff_timeout_callback(void *arg);
int first_poweron = 0;
void timer_check_device_run_callback(void *arg){
uint16_t reg_charge = CHARGE_REG0X2_CHARGE_X_STA_GET(0);
@ -390,18 +392,19 @@ void timer_check_device_run_callback(void *arg){
box_info.charge_state = 0;
}else{
box_info.charge_state = 1;
for(int i = 0; i < 5; i++){ //1秒内处于合盖状态就关机
if(hall){
rt_kprintf("usb_power_is_pluged reg:%d state:%d hall:%d\r\n", reg_charge, box_info.charge_state, box_info.hall_state);
return;
}
rt_thread_mdelay(200);
}
box_poweroff_timeout_callback(NULL);
}
// box_info.charge_state = 0;
rt_kprintf("usb_power_is_pluged reg:%d state:%d hall:%d\r\n", reg_charge, box_info.charge_state, box_info.hall_state);
for(int i = 0; i < 5; i++){ //1秒内处于合盖状态就关机
if(hall || !first_poweron){
first_poweron = 1;
return;
}
rt_thread_mdelay(600);
}
//rtos_start_timer(&timer_poweroff);
box_poweroff_timeout_callback(NULL);
//合盖状态接入充电 ---> 关机
// if (box_info.hall_state == 0)
// {
@ -813,13 +816,9 @@ void app_enter_ui(app_ui_mode mode){
{
case UI_BOX_BATTERY:
app_show_box_battery();
//static int battery_timer_inited = 0;
if(box_info.charge_state)
{
rtos_init_timer(&timer_battery_refresh, 10000, timer_battery_refresh_callback, NULL);
rtos_start_timer(&timer_battery_refresh);
// battery_timer_inited = 1;
}
break;
case UI_SHOW_DEVICE_INFO:
@ -901,14 +900,22 @@ void charge_sleep_on(int on) {
if (oled_is_on != on) {
oled_is_on = on;
if (on){
bk_reboot();
//bk_reboot();
OLED_DisPlay_On();//屏幕
voice_player_mute(1); //声音
// OLED_DisPlay_On();//屏幕
// voice_player_mute(1); //声音
// rtos_start_timer(&timer_detect);
// bk_wlan_start_sta(BK_STATION); //WIFI
// belon_ble_scan_start(); //蓝牙扫描
// belon_ble_start_adv(); //蓝牙广播
}else{
OLED_DisPlay_Off();//屏幕
voice_player_mute(0); //声音
rtos_stop_timer(&timer_detect);
bk_wlan_stop(BK_STATION); //WIFI
belon_ble_scan_stop(); //蓝牙扫描
belon_ble_deinit_adv(); //蓝牙广播
// rtos_stop_timer(&timer_detect);
// //bk_wlan_stop(BK_STATION); //WIFI
// belon_ble_scan_stop(); //蓝牙扫描
// belon_ble_deinit_adv(); //蓝牙广播
}
}
}
@ -939,7 +946,7 @@ void box_poweroff_timeout_callback(void *arg){
if (box_info.charge_state) {
oled_is_on = 1;
charge_sleep_on(0);
//return;
return;
}
bk_gpio_config_output(BLE_TEMPERATURE_BOX_POWER_CTR);
bk_gpio_output(BLE_TEMPERATURE_BOX_POWER_CTR,0);
@ -1041,6 +1048,7 @@ void timer_hall_detect_callback(void *arg){
rtos_stop_timer(&timer_poweroff);
}
if(!oled_is_on){ //充电时开盖复位设备
rt_kprintf("charge_sleep_on(1) !!!\r\n");
charge_sleep_on(1);
}
// 只有在5秒内且开关盖次数达到5才进入绑定
@ -1324,8 +1332,6 @@ void poka_client_password(){
rt_kprintf("password=%s\r\n", mqtt_password);
}
void temperature_init(void){
extern long list_memheap(void);
@ -1352,6 +1358,9 @@ void temperature_init(void){
rtos_init_timer(&timer_poweroff, BLE_TEMPERATURE_POWEROFF_TIMEOUT, box_poweroff_timeout_callback, NULL);
rtos_init_timer(&timer_bind, BLE_TEMPERATURE_BIND_MODE_TIMEOUT, box_bind_timeout_callback, NULL);
rtos_init_timer(&timer_idle, BLE_TEMPERATURE_IDLE_MODE_TIMEOUT, timer_app_idle_callback, NULL);
//初始化电量
box_init_power();
// user_app_start();

View File

@ -9,6 +9,7 @@
#include "rw_pub.h"
#include "belon_ble.h"
#include "app_temperature.h"
#include "utils_httpc.h"
#include "ntp.h"
#if (CFG_BLE_VERSION == BLE_VERSION_5_2)
#include "app_ble.h"
@ -54,6 +55,7 @@ extern int hostapd_scan_started; //扫描wifi全局变量
static beken_timer_t ble_idle;
rt_thread_t tid_ntp; //ntp时间戳
rt_thread_t tid_register; //register时间戳
enum
{
TEST_IDX_SVC,
@ -280,7 +282,54 @@ void connect_mqtt(){//创建线程
tid_ntp = rt_thread_create("ntp_get", ntp_get_time_thread, RT_NULL, 2048, 20, 10);
if (tid_ntp) rt_thread_startup(tid_ntp);
}
static void send_json_register(void *parameter){
httpclient_t client;
httpclient_data_t client_data;
char *url = "https://dev.xa-poka.com/register";
char json_body[512];
char response[512];
os_memset(&client, 0, sizeof(httpclient_t));
os_memset(&client_data, 0, sizeof(httpclient_data_t));
os_memset(&json_body, 0, sizeof(512));
bk_wifi_get_station_mac_address(g_sta_mac);
bk_printf("Device MAC: %02X%02X%02X%02X%02X%02X\r\n",
g_sta_mac[0], g_sta_mac[1], g_sta_mac[2], g_sta_mac[3], g_sta_mac[4], g_sta_mac[5]);
snprintf(json_body, sizeof(json_body),
"{"
"\"device_id\":\"%s_%02X%02X%02X%02X%02X%02X\","
"\"device_name\":\"%02X%02X%02X%02X%02X%02X\","
"\"product_id\":\"%s\","
"\"secure_id,ontimempty\":\"poka\","
"\"secure_key,ontimempty\":\"Poka&Lock12345\","
"\"product_name\":\"腋温计网关\""
"}",PRODUCTID,g_sta_mac[0],g_sta_mac[1],g_sta_mac[2],g_sta_mac[3],g_sta_mac[4],g_sta_mac[5],
g_sta_mac[0],g_sta_mac[1],g_sta_mac[2],g_sta_mac[3],g_sta_mac[4],g_sta_mac[5],PRODUCTID);
client_data.post_buf = json_body;
client_data.post_buf_len = strlen(json_body);
client_data.post_content_type = "application/json";
client_data.response_buf = response;
client_data.response_buf_len = sizeof(response);
int ret = httpclient_common(&client, url, 443, NULL, HTTPCLIENT_POST, 10000, &client_data);
if (ret == 0) {
bk_printf("HTTP response: %s\r\n", response);
} else {
bk_printf("HTTP POST failed: %d\r\n", ret);
}
}
void json_register(){//创建线程
if(tid_register){
rt_thread_detach(tid_register);
tid_register = NULL;
}
tid_register = rt_thread_create("register", send_json_register, RT_NULL, 2048, 20, 10);
if (tid_register) rt_thread_startup(tid_register);
}
void wifi_status_cb(void *param){
LinkStatusTypeDef status;
bk_wlan_get_link_status(&status);
@ -295,10 +344,10 @@ void wifi_status_cb(void *param){
bk_printf("SSID=%s, PASSWORD=%s\r\n", last_ssid, last_password);
wifi_save_ssid_pass(last_ssid, last_password, status.bssid, status.channel, status.security);
bk_wifi_get_station_mac_address(g_sta_mac);
bk_printf("Device MAC: %02X%02X%02X%02X%02X%02X\r\n",
g_sta_mac[0], g_sta_mac[1], g_sta_mac[2], g_sta_mac[3], g_sta_mac[4], g_sta_mac[5]);
json_register();
// bk_wifi_get_station_mac_address(g_sta_mac);
// bk_printf("Device MAC: %02X%02X%02X%02X%02X%02X\r\n",
// g_sta_mac[0], g_sta_mac[1], g_sta_mac[2], g_sta_mac[3], g_sta_mac[4], g_sta_mac[5]);
ble_report_state(3);//连接成功
connect_mqtt();
}

View File

@ -323,7 +323,7 @@
/*section 21 ----- support ota*/
#if( ( CFG_SUPPORT_ALIOS ) || ( CFG_SUPPORT_RTT ) || (CFG_SUPPORT_MATTER == 1))
#define CFG_SUPPORT_OTA_HTTP 0
#define CFG_SUPPORT_OTA_HTTP 1
#else
#define CFG_SUPPORT_OTA_HTTP 1
#endif

View File

@ -5,6 +5,7 @@
#include "errno.h"
#include "lwip/sockets.h"
#include "lwip/netdb.h"
#include <netdb.h>
#include "utils_timer.h"
#include "str_pub.h"
#include "mem_pub.h"
@ -28,7 +29,7 @@ uintptr_t HAL_TCP_Establish(const char *host, uint16_t port)
hints.ai_protocol = IPPROTO_TCP;
sprintf(service, "%u", port);
if ((rc = getaddrinfo(host, service, &hints, &addrInfoList)) != 0) {
if ((rc = lwip_getaddrinfo(host, service, &hints, &addrInfoList)) != 0) {
log_err("getaddrinfo error");
return 0;
}
@ -41,14 +42,15 @@ ES_RETRY:
continue;
}
fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
fd = lwip_socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
if (fd < 0) {
log_err("create socket error");
rc = 0;
continue;
}
if (connect(fd, cur->ai_addr, cur->ai_addrlen) == 0) {
if (lwip_connect(fd, cur->ai_addr, cur->ai_addrlen) == 0) {
rc = fd;
break;
}
@ -67,7 +69,7 @@ ES_RETRY:
} else {
log_err("success to establish tcp, fd=%d", rc);
}
freeaddrinfo(addrInfoList);
lwip_freeaddrinfo(addrInfoList);
return (uintptr_t)rc;
}
@ -141,7 +143,7 @@ int32_t HAL_TCP_Write(uintptr_t fd, const char *buf, uint32_t len, uint32_t time
}
if (ret > 0) {
ret = send(fd, buf + len_sent, len - len_sent, 0);
ret =lwip_send(fd, buf + len_sent, len - len_sent, 0);
if (ret > 0) {
len_sent += ret;
} else if (0 == ret) {
@ -191,7 +193,7 @@ int32_t HAL_TCP_Read(uintptr_t fd, char *buf, uint32_t len, uint32_t timeout_ms)
if ( FD_ISSET( fd, &sets ) )
{
if (ret > 0) {
ret = recv(fd, buf, len, 0);
ret = lwip_recv(fd, buf, len, 0);
if (ret > 0) {
if(ret < len)
{

View File

@ -323,7 +323,7 @@
/*section 21 ----- support ota*/
#if( ( CFG_SUPPORT_ALIOS ) || ( CFG_SUPPORT_RTT ) || (CFG_SUPPORT_MATTER == 1))
#define CFG_SUPPORT_OTA_HTTP 0
#define CFG_SUPPORT_OTA_HTTP 1
#else
#define CFG_SUPPORT_OTA_HTTP 1
#endif

File diff suppressed because it is too large Load Diff

View File

@ -169,6 +169,52 @@
=====================================================================
cmdline: |C:/Users/hjf/Desktop/temperature_iT18/tool/BEKEN_BKFIL_V2.1.11.15_20241119/BEKEN_BKFIL_V2.1.11.15_20241119/bk_loader.exe download -p 6 -b 2000000 --uart-type OTHER --mainBin-multi C:/Users/hjf/Desktop/temperature_iT18/beken_rtt_sdk_release-SDK_3.0.76/out/all_2M.1220.bin@0x0-0x132000 --reboot 0 --fast-link 1 |
bk_loader version 2.1.11.15: build @Nov 14 2024 19:17:41
=====================================================================
cmdline: |C:/Users/hjf/Desktop/temperature_iT18/tool/BEKEN_BKFIL_V2.1.11.15_20241119/BEKEN_BKFIL_V2.1.11.15_20241119/bk_loader.exe download -p 6 -b 2000000 --uart-type OTHER --mainBin-multi C:/Users/hjf/Desktop/temperature_iT18/beken_rtt_sdk_release-SDK_3.0.76/out/all_2M.1220.bin@0x0-0x132000 --reboot 0 --fast-link 1 |
bk_loader version 2.1.11.15: build @Nov 14 2024 19:17:41
=====================================================================
cmdline: |C:/Users/hjf/Desktop/temperature_iT18/tool/BEKEN_BKFIL_V2.1.11.15_20241119/BEKEN_BKFIL_V2.1.11.15_20241119/bk_loader.exe download -p 6 -b 2000000 --uart-type OTHER --mainBin-multi C:/Users/hjf/Desktop/temperature_iT18/beken_rtt_sdk_release-SDK_3.0.76/out/all_2M.1220.bin@0x0-0x132000 --reboot 0 --fast-link 1 |
bk_loader version 2.1.11.15: build @Nov 14 2024 19:17:41
2025-07-21 10:01:29.176 Current port : COM6 + BaudRate : 115200 connect failed
2025-07-21 10:01:29.177 Connect device fail!
2025-07-21 10:01:29.188 Total Test Time : 0.000 s
2025-07-21 10:01:29.188 Writing Flash Failed, code 0
2025-07-21 10:01:29.188
==============================================================
(warning)
(_)
__ ____ _ _ __ _ __ _ _ __ __ _
\ \ /\ / / _` | '__| '_ \| | '_ \ / _` |
\ V V / (_| | | | | | | | | | | (_| |
\_/\_/ \__,_|_| |_| |_|_|_| |_|\__, |
__/ |
|___/
=====================================================================
cmdline: |C:/Users/hjf/Desktop/temperature_iT18/tool/BEKEN_BKFIL_V2.1.11.15_20241119/BEKEN_BKFIL_V2.1.11.15_20241119/bk_loader.exe download -p 6 -b 2000000 --uart-type OTHER --mainBin-multi C:/Users/hjf/Desktop/temperature_iT18/beken_rtt_sdk_release-SDK_3.0.76/out/all_2M.1220.bin@0x0-0x132000 --reboot 0 --fast-link 1 |
bk_loader version 2.1.11.15: build @Nov 14 2024 19:17:41
=====================================================================
cmdline: |C:/Users/hjf/Desktop/temperature_iT18/tool/BEKEN_BKFIL_V2.1.11.15_20241119/BEKEN_BKFIL_V2.1.11.15_20241119/bk_loader.exe download -p 6 -b 2000000 --uart-type OTHER --mainBin-multi C:/Users/hjf/Desktop/temperature_iT18/beken_rtt_sdk_release-SDK_3.0.76/out/all_2M.1220.bin@0x0-0x132000 --reboot 0 --fast-link 1 |
bk_loader version 2.1.11.15: build @Nov 14 2024 19:17:41
=====================================================================
cmdline: |C:/Users/hjf/Desktop/temperature_iT18/tool/BEKEN_BKFIL_V2.1.11.15_20241119/BEKEN_BKFIL_V2.1.11.15_20241119/bk_loader.exe download -p 6 -b 2000000 --uart-type OTHER --mainBin-multi C:/Users/hjf/Desktop/temperature_iT18/beken_rtt_sdk_release-SDK_3.0.76/out/all_2M.1220.bin@0x0-0x132000 --reboot 0 --fast-link 1 |
bk_loader version 2.1.11.15: build @Nov 14 2024 19:17:41

View File

@ -2,25 +2,25 @@
Theme=蓝色扁平
latest_version=
Language=0
UartPort=3
UartPort=10
UartPort_selected=true
Baudrate=2000000
Origin_EXE=
[FileInfo]
BinFileCheckState="true;"
BinFilePath="D:/WORK/temperature_iT18/beken_rtt_sdk_release-SDK_3.0.76/out/all_2M.1220.bin;"
BinFilePath="C:/Users/hjf/Desktop/temperature_iT18/beken_rtt_sdk_release-SDK_3.0.76/out/all_2M.1220.bin;"
BinFileStartAddress="0;"
BinFileLength="0x132000;"
BinFileCRC="0x89a01713;"
BinFileCRC="0x7cc09418;"
[Common]
Device_ID_0=c8
Device_ID_1=47
Device_ID_2=8c
Device_ID_3=cb
Device_ID_0=11
Device_ID_1=22
Device_ID_2=33
Device_ID_3=44
Device_ID_4=0a
Device_ID_5=de
Device_ID_5=69
Device_ID_address=0x001e0024
Device_ID_length=6
Device_ID_auto_rolling=true
@ -31,15 +31,15 @@ Device_name_length=
EfuseFilePath=
SecureFilePath=
BinFileBufferSize=8388608
RunAfterDownload=true
RunAfterDownload=false
Enable_Download_Main_Bin=true
Enable_Download_Efuse=false
Enable_Erase_All=true
Enable_Erase_All=false
Enable_Secure_Boot=false
Enable_OTP=false
Enable_Device_ID=true
Enable_Device_ID=false
Enable_Device_Name=false
Enable_EnableBigEndian=true
Enable_EnableBigEndian=false
Enable_Debug=false
Enable_GenericChip=false