Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
QJ_500-7c
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
时昊
QJ_500-7c
Commits
cf5e59f2
Commit
cf5e59f2
authored
Jul 11, 2024
by
wangxuhui
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'xxh' into 'develop'
时间同步改为5次;同步秒 See merge request
!4
parents
62d8090d
2c953dd1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
53 deletions
+81
-53
Protocol_User.c
qianjiang/main/Protocol_User.c
+22
-5
Protocol_User.h
qianjiang/main/Protocol_User.h
+3
-0
app_Ble_User.c
qianjiang/main/app_Ble_User.c
+50
-42
app_Ble_User.h
qianjiang/main/app_Ble_User.h
+6
-6
No files found.
qianjiang/main/Protocol_User.c
View file @
cf5e59f2
...
...
@@ -299,6 +299,8 @@ void UART_Put(Protocol_uint16_t Data)
#define PROTOCOL_ID_12_DATA_LEN 18
/**
* @brief Protocol协议应用层数据赋值和发送
*/
...
...
@@ -318,7 +320,7 @@ void Uart_Send_Id10_Pro(void )
void
Uart_Send_Id12_Pro
(
void
)
{
uint8_t
ID12
[
17
]
=
{
0
};
uint8_t
ID12
[
PROTOCOL_ID_12_DATA_LEN
]
=
{
0
};
ID12
[
0
]
|=
(
uint8_t
)(
BT_User
.
BT_Sts
<<
4
);
ID12
[
0
]
|=
Ble_User
.
Ble_Sts
;
unsigned
int
i
=
0
;
...
...
@@ -327,11 +329,26 @@ void Uart_Send_Id12_Pro(void )
ID12
[
i
+
1
]
=
BT_Device_Name
[
i
];
}
ID12
[
15
]
=
Get_Ble_Time_Hour
();
ID12
[
16
]
=
Get_Ble_Time_Minute
();
app_Ble_Time_Info_Struct
*
time
=
Get_Ble_TimeInfo
();
if
(
time
==
NULL
)
{
ID12
[
15
]
=
0xff
;
ID12
[
16
]
=
0xff
;
ID12
[
17
]
=
0xff
;
}
else
{
ID12
[
15
]
=
time
->
u8Hour
;
ID12
[
16
]
=
time
->
u8Minute
;
ID12
[
17
]
=
time
->
u8Sec
;
}
if
(
ID12
[
15
]
!=
0xff
)
{
// printf("hour = %d, minute = %d, SEC = %d\n", ID12[15], ID12[16], ID12[17]);
}
// printf("hour = %d, minute = %d\n", ID12[15], ID12[16]);
Protocol_Send
(
0x12
,
ID12
,
17
);
Protocol_Send
(
0x12
,
ID12
,
PROTOCOL_ID_12_DATA_LEN
);
}
void
Uart_Send_Id01_Pro
(
void
)
...
...
qianjiang/main/Protocol_User.h
View file @
cf5e59f2
...
...
@@ -36,4 +36,7 @@ void Protocol_User_Ctrl_Init(void );
void
Prot_Send_Msg_Process
(
void
);
void
Uart_Send_Id12_Pro
(
void
);
#endif
qianjiang/main/app_Ble_User.c
View file @
cf5e59f2
...
...
@@ -12,6 +12,7 @@
#include "Protocol_User.h"
#include "main_user.h"
#include "esp_log.h"
#include "Protocol_User.h"
#define TAG "APP_BLE_USER"
...
...
@@ -335,7 +336,6 @@ void Ble_MsgRec_Authr_Result_Analysis(void )
{
Ble_User
.
Ble_Sts
=
Ble_Authr
;
Ble_User
.
Request_Navi
=
1
;
Ble_User
.
u8Time_Req_Sw
=
1
;
ESP_LOGE
(
"BLE USER"
,
"Authr suc
\n
"
);
}
...
...
@@ -415,7 +415,7 @@ void Ble_Msg_RequestTime(void )
uint8_t
total_frame
=
0
;
uint8_t
trans_len
=
0
;
if
(
Ble_User
.
u8Time_Req_Sw
==
1
&&
Ble_User
.
Ble_Sts
>=
Ble_Authr
)
if
(
(
Ble_User
.
Ble_Sts
>=
Ble_Authr
)
&&
(
BleTime
.
TimeReqCnt
>
0
)
)
{
BleTransData
.
Msg
.
FrameHeader
=
0x24
;
BleTransData
.
Msg
.
Cmd
=
0x55
;
...
...
@@ -488,9 +488,10 @@ void Ble_MsgRec_Navi_Analysis(void )
//11 12 hour
//14 15 min
//17 18 sec
void
Ble_MsgRec_Time_Analysis
(
void
)
{
uint8_t
wtemp
[
4
]
=
{
0
};
uint8_t
wtemp
[
6
]
=
{
0
};
Char_To_Dec
(
BleRecData
.
Msg
.
Param
[
11
],
&
wtemp
[
0
]);
Char_To_Dec
(
BleRecData
.
Msg
.
Param
[
12
],
&
wtemp
[
1
]);
...
...
@@ -502,39 +503,63 @@ void Ble_MsgRec_Time_Analysis(void )
BleTime
.
u8Minute
=
wtemp
[
2
]
*
10
+
wtemp
[
3
];
Ble_User
.
u8Time_Updat
=
1
;
Ble_User
.
u8Time_T
=
0
;
Char_To_Dec
(
BleRecData
.
Msg
.
Param
[
17
],
&
wtemp
[
4
])
;
Char_To_Dec
(
BleRecData
.
Msg
.
Param
[
18
],
&
wtemp
[
5
])
;
// printf("hour = %d, minute = %d\n", BleTime.u8Hour, BleTime.u8Minute);
}
BleTime
.
u8Sec
=
wtemp
[
4
]
*
10
+
wtemp
[
5
];
if
(
BleTime
.
u8Sec
<
59
)
{
BleTime
.
u8Sec
+=
1
;
}
else
{
BleTime
.
u8Sec
=
0
;
if
(
BleTime
.
u8Minute
<
59
)
{
BleTime
.
u8Minute
+=
1
;
}
else
{
BleTime
.
u8Minute
=
0
;
if
(
BleTime
.
u8Hour
<
23
)
{
BleTime
.
u8Hour
++
;
}
else
{
BleTime
.
u8Hour
=
0
;
}
}
}
uint8_t
Get_Ble_Time_Hour
(
void
)
{
uint8_t
ret
=
0xff
;
if
(
Ble_User
.
u8Time_Updat
==
1
)
if
(
BleTime
.
u8Hour
<
24
&&
BleTime
.
u8Minute
<
60
&&
BleTime
.
u8Sec
<
60
)
{
if
(
BleTime
.
u8Hour
<
24
)
if
(
BleTime
.
TimeReqCnt
>
0
)
{
ret
=
BleTime
.
u8Hour
;
BleTime
.
TimeReqCnt
--
;
BleTime
.
TimeUpdate
=
1
;
// Uart_Send_Id12_Pro();
}
}
return
ret
;
}
uint8_t
Get_Ble_Time_Minute
(
void
)
app_Ble_Time_Info_Struct
*
Get_Ble_TimeInfo
(
void
)
{
uint8_t
ret
=
0xff
;
if
(
Ble
_User
.
u8Time_Updat
==
1
)
app_Ble_Time_Info_Struct
*
ret
=
NULL
;
if
(
Ble
Time
.
TimeUpdate
)
{
if
(
BleTime
.
u8Minute
<
60
)
{
ret
=
BleTime
.
u8Minute
;
}
BleTime
.
TimeUpdate
=
0
;
ret
=
(
app_Ble_Time_Info_Struct
*
)
&
BleTime
;
}
return
ret
;
}
void
Ble_MsgRec_Navi_Timeout
(
void
)
{
if
(
Ble_User
.
Navi_Updat
)
...
...
@@ -553,20 +578,6 @@ void Ble_MsgRec_Navi_Timeout(void )
if
(
Ble_User
.
u8Time_Updat
)
{
Ble_User
.
u8Time_T
++
;
if
(
Ble_User
.
u8Time_T
>=
50
)
{
Ble_User
.
u8Time_Updat
=
0
;
Ble_User
.
u8Time_T
=
0
;
ESP_LOGE
(
"BLE USER"
,
"time update timeout"
);
}
}
else
{
Ble_User
.
u8Time_T
=
0
;
}
}
...
...
@@ -578,13 +589,12 @@ void Ble_Connect_Event_Pro(void )
Ble_User
.
Request_Navi
=
0
;
Ble_User
.
Navi_Updat
=
0
;
Ble_User
.
Navi_T
=
0
;
Ble_User
.
u8Time_Updat
=
0
;
Ble_User
.
u8Time_T
=
0
;
Ble_User
.
u8Time_Req_Sw
=
0
;
Ble_Clear_Tx_Buffer
();
Ble_Clear_Rx_Buffer
();
BleTime
.
TimeReqCnt
=
5
;
}
...
...
@@ -594,8 +604,6 @@ void Ble_DisConnect_Event_Pro(void )
Ble_User
.
Request_Navi
=
0
;
Ble_User
.
Navi_Updat
=
0
;
Ble_User
.
Navi_T
=
0
;
Ble_User
.
u8Time_Updat
=
0
;
Ble_User
.
u8Time_T
=
0
;
RecCtrl
.
RecLen
=
0
;
RecCtrl
.
TotalLen
=
0
;
...
...
@@ -611,8 +619,8 @@ void Ble_DisConnect_Event_Pro(void )
Ble_Clear_Tx_Buffer
();
Ble_Clear_Rx_Buffer
();
Ble_User
.
u8Time_Req_Sw
=
0
;
BleTime
.
TimeReqCnt
=
0
;
}
...
...
@@ -657,7 +665,7 @@ void Ble_User_Task_Cyc(void *pvParameter)
while
(
1
)
{
Ble_Msg_RequestTime
();
vTaskDelay
(
8
00
);
vTaskDelay
(
10
00
);
}
vTaskDelete
(
NULL
);
}
...
...
qianjiang/main/app_Ble_User.h
View file @
cf5e59f2
...
...
@@ -29,10 +29,6 @@ typedef struct
uint8_t
Navi_Updat
;
uint8_t
Navi_T
;
uint8_t
UseridUpdate
;
uint8_t
u8Time_Req_Sw
;
uint8_t
u8Time_Updat
;
uint8_t
u8Time_T
;
}
Ble_User_Control_Struct
;
...
...
@@ -50,6 +46,10 @@ typedef struct
{
uint8_t
u8Hour
;
uint8_t
u8Minute
;
uint8_t
u8Sec
;
uint8_t
TimeReqCnt
;
uint8_t
TimeUpdate
;
}
app_Ble_Time_Info_Struct
;
...
...
@@ -241,8 +241,8 @@ void Ble_Msg_RequestNavi_RLY(void );
void
Ble_MsgRec_Navi_Timeout
(
void
);
uint8_t
Get_Ble_Time_Hour
(
void
);
uint8_t
Get_Ble_Time_Minute
(
void
);
void
Ble_Msg_RequestTime
(
void
);
app_Ble_Time_Info_Struct
*
Get_Ble_TimeInfo
(
void
);
#endif
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment