|
@@ -23,8 +23,8 @@ uint8_t bt_lock_machinesta=0; //bt
|
|
uint8_t bt_lock_ropesta=0; //bt锁(锁绳)状态(0x00插入;0x01拔出)
|
|
uint8_t bt_lock_ropesta=0; //bt锁(锁绳)状态(0x00插入;0x01拔出)
|
|
uint16_t bt_hwver=0; //bt硬件版本号
|
|
uint16_t bt_hwver=0; //bt硬件版本号
|
|
uint16_t bt_sfver=0; //bt软件版本号
|
|
uint16_t bt_sfver=0; //bt软件版本号
|
|
-uint8_t g_MBA32A_8buf[2048]={0}; //蓝牙接收数组
|
|
|
|
-uint8_t g_MBA32A_8buf_Down[2048]={0} ; //蓝牙搬移数组
|
|
|
|
|
|
+uint8_t g_MBA32A_8buf[500]={0}; //蓝牙接收数组
|
|
|
|
+uint8_t g_MBA32A_8buf_Down[500]={0} ; //蓝牙搬移数组
|
|
|
|
|
|
void MBA32AReset(void);
|
|
void MBA32AReset(void);
|
|
uint8_t sendCmd_BT(char *pCmd,char *pRes, uint32_t timeOut, uint8_t sendNum);
|
|
uint8_t sendCmd_BT(char *pCmd,char *pRes, uint32_t timeOut, uint8_t sendNum);
|
|
@@ -37,6 +37,8 @@ uint8_t iv[16] = {0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x
|
|
*/
|
|
*/
|
|
void Start_Read_resetFlag16(void)
|
|
void Start_Read_resetFlag16(void)
|
|
{
|
|
{
|
|
|
|
+ uploadtime = HAL_GetTick();
|
|
|
|
+
|
|
resetFlag16 = read_flash_16(resetDevAddr);
|
|
resetFlag16 = read_flash_16(resetDevAddr);
|
|
if(resetFlag16==0xFFFF)//开机检测(首次启动)
|
|
if(resetFlag16==0xFFFF)//开机检测(首次启动)
|
|
{
|
|
{
|
|
@@ -50,7 +52,9 @@ void Start_Read_resetFlag16(void)
|
|
else if(resetFlag16==0xAAAA)//开机检测(大于1次启动)
|
|
else if(resetFlag16==0xAAAA)//开机检测(大于1次启动)
|
|
{
|
|
{
|
|
printf("###蓝牙模块非首次启动\r\n");
|
|
printf("###蓝牙模块非首次启动\r\n");
|
|
- HAL_Delay(50);
|
|
|
|
|
|
+ while (HAL_GetTick() - uploadtime < 50) {
|
|
|
|
+ // 空等待
|
|
|
|
+ }
|
|
if (!sendCmd_BT("AT+UUIDS?\r\n","+UUIDS:0002",1,1))
|
|
if (!sendCmd_BT("AT+UUIDS?\r\n","+UUIDS:0002",1,1))
|
|
{
|
|
{
|
|
PRINT_NUUID("UUIDS");//UUID项不符合
|
|
PRINT_NUUID("UUIDS");//UUID项不符合
|
|
@@ -166,6 +170,7 @@ void MBA32A_Init(void)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //关闭4G后需要取消注释
|
|
// menu.current=0;//回到初始
|
|
// menu.current=0;//回到初始
|
|
// refresh=true;
|
|
// refresh=true;
|
|
|
|
|
|
@@ -240,7 +245,7 @@ void lock_searchInfo(void) //
|
|
uint8_t header[2] = {0x66, 0x01};//Jl_lock帧头
|
|
uint8_t header[2] = {0x66, 0x01};//Jl_lock帧头
|
|
uint8_t serchInfo_CMD[] = {0x01, 0x00};//查询信息命令帧
|
|
uint8_t serchInfo_CMD[] = {0x01, 0x00};//查询信息命令帧
|
|
sendCombinedArray(header,sizeof(header),serchInfo_CMD,sizeof(serchInfo_CMD),0);
|
|
sendCombinedArray(header,sizeof(header),serchInfo_CMD,sizeof(serchInfo_CMD),0);
|
|
- Echo_BT(20);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -289,7 +294,7 @@ void open_lock(BtFrame btframe) //
|
|
open_CMD[14] = btframe.Autoseal;//自动施封时间
|
|
open_CMD[14] = btframe.Autoseal;//自动施封时间
|
|
|
|
|
|
sendCombinedArray(header,sizeof(header),open_CMD,sizeof(open_CMD),1);//加密
|
|
sendCombinedArray(header,sizeof(header),open_CMD,sizeof(open_CMD),1);//加密
|
|
- Echo_BT(20);
|
|
|
|
|
|
+ //Echo_BT(20);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -337,7 +342,7 @@ void close_lock(BtFrame btframe) //
|
|
close_CMD[13]= ntime & 0xff;
|
|
close_CMD[13]= ntime & 0xff;
|
|
|
|
|
|
sendCombinedArray(header,sizeof(header),close_CMD,sizeof(close_CMD),1);
|
|
sendCombinedArray(header,sizeof(header),close_CMD,sizeof(close_CMD),1);
|
|
- Echo_BT(20);
|
|
|
|
|
|
+ //Echo_BT(20);
|
|
}
|
|
}
|
|
|
|
|
|
void workinfo_W(void)
|
|
void workinfo_W(void)
|
|
@@ -454,10 +459,11 @@ void workinfo_W(void)
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+bool SdjfEmergency = false;
|
|
extern TT808 tt808;
|
|
extern TT808 tt808;
|
|
void open_close_lock(void)
|
|
void open_close_lock(void)
|
|
{
|
|
{
|
|
|
|
+
|
|
if(menu.enter == 4 && (menu.current == 4 || menu.current == 5 || menu.current == 6 || menu.current == 7))
|
|
if(menu.enter == 4 && (menu.current == 4 || menu.current == 5 || menu.current == 6 || menu.current == 7))
|
|
{
|
|
{
|
|
if(menu.current==4)
|
|
if(menu.current==4)
|
|
@@ -472,6 +478,7 @@ void open_close_lock(void)
|
|
Write_Information(Sn1StatusAddr, 0x2222);
|
|
Write_Information(Sn1StatusAddr, 0x2222);
|
|
tt808.L1Lockstatus = LockStatusClose;
|
|
tt808.L1Lockstatus = LockStatusClose;
|
|
HAL_Delay(50);
|
|
HAL_Delay(50);
|
|
|
|
+ SdjfEmergency=true;
|
|
}
|
|
}
|
|
else if(menu.up == 0)
|
|
else if(menu.up == 0)
|
|
{
|
|
{
|
|
@@ -480,6 +487,8 @@ void open_close_lock(void)
|
|
Write_Information(Sn1StatusAddr, 0x1111);
|
|
Write_Information(Sn1StatusAddr, 0x1111);
|
|
tt808.L1Lockstatus = LockStatusOpen;
|
|
tt808.L1Lockstatus = LockStatusOpen;
|
|
HAL_Delay(50);
|
|
HAL_Delay(50);
|
|
|
|
+
|
|
|
|
+ SdjfEmergency=true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(menu.current==5)
|
|
if(menu.current==5)
|
|
@@ -494,6 +503,8 @@ void open_close_lock(void)
|
|
Write_Information(Sn2StatusAddr, 0x2222);
|
|
Write_Information(Sn2StatusAddr, 0x2222);
|
|
tt808.L2Lockstatus = LockStatusClose;
|
|
tt808.L2Lockstatus = LockStatusClose;
|
|
HAL_Delay(50);
|
|
HAL_Delay(50);
|
|
|
|
+
|
|
|
|
+ SdjfEmergency=true;
|
|
}
|
|
}
|
|
else if(menu.up == 0)
|
|
else if(menu.up == 0)
|
|
{
|
|
{
|
|
@@ -502,6 +513,8 @@ void open_close_lock(void)
|
|
Write_Information(Sn2StatusAddr, 0x1111);
|
|
Write_Information(Sn2StatusAddr, 0x1111);
|
|
tt808.L2Lockstatus = LockStatusOpen;
|
|
tt808.L2Lockstatus = LockStatusOpen;
|
|
HAL_Delay(50);
|
|
HAL_Delay(50);
|
|
|
|
+
|
|
|
|
+ SdjfEmergency=true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(menu.current==6)
|
|
if(menu.current==6)
|
|
@@ -516,6 +529,8 @@ void open_close_lock(void)
|
|
Write_Information(Sn3StatusAddr, 0x2222);
|
|
Write_Information(Sn3StatusAddr, 0x2222);
|
|
tt808.L3Lockstatus = LockStatusClose;
|
|
tt808.L3Lockstatus = LockStatusClose;
|
|
HAL_Delay(50);
|
|
HAL_Delay(50);
|
|
|
|
+
|
|
|
|
+ SdjfEmergency=true;
|
|
}
|
|
}
|
|
else if(menu.up == 0)
|
|
else if(menu.up == 0)
|
|
{
|
|
{
|
|
@@ -524,6 +539,8 @@ void open_close_lock(void)
|
|
Write_Information(Sn3StatusAddr, 0x1111);
|
|
Write_Information(Sn3StatusAddr, 0x1111);
|
|
tt808.L3Lockstatus = LockStatusOpen;
|
|
tt808.L3Lockstatus = LockStatusOpen;
|
|
HAL_Delay(50);
|
|
HAL_Delay(50);
|
|
|
|
+
|
|
|
|
+ SdjfEmergency=true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(menu.current==7)
|
|
if(menu.current==7)
|
|
@@ -538,6 +555,8 @@ void open_close_lock(void)
|
|
Write_Information(Sn4StatusAddr, 0x2222);
|
|
Write_Information(Sn4StatusAddr, 0x2222);
|
|
tt808.L4Lockstatus = LockStatusClose;
|
|
tt808.L4Lockstatus = LockStatusClose;
|
|
HAL_Delay(50);
|
|
HAL_Delay(50);
|
|
|
|
+
|
|
|
|
+ SdjfEmergency=true;
|
|
}
|
|
}
|
|
else if(menu.up == 0)
|
|
else if(menu.up == 0)
|
|
{
|
|
{
|
|
@@ -546,6 +565,8 @@ void open_close_lock(void)
|
|
Write_Information(Sn4StatusAddr, 0x1111);
|
|
Write_Information(Sn4StatusAddr, 0x1111);
|
|
tt808.L4Lockstatus = LockStatusOpen;
|
|
tt808.L4Lockstatus = LockStatusOpen;
|
|
HAL_Delay(50);
|
|
HAL_Delay(50);
|
|
|
|
+
|
|
|
|
+ SdjfEmergency=true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -553,7 +574,7 @@ void open_close_lock(void)
|
|
S2 = read_flash_16(Sn2StatusAddr);
|
|
S2 = read_flash_16(Sn2StatusAddr);
|
|
S3 = read_flash_16(Sn3StatusAddr);
|
|
S3 = read_flash_16(Sn3StatusAddr);
|
|
S4 = read_flash_16(Sn4StatusAddr);
|
|
S4 = read_flash_16(Sn4StatusAddr);
|
|
- HAL_Delay(50);
|
|
|
|
|
|
+ HAL_Delay(30);
|
|
menu.enter=3;
|
|
menu.enter=3;
|
|
refresh = true;
|
|
refresh = true;
|
|
}
|
|
}
|