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
a5107afe
Commit
a5107afe
authored
Apr 30, 2024
by
王金亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:完善串口协议
parent
cfedf395
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
38 deletions
+102
-38
settings.json
.vscode/settings.json
+2
-1
MCU_Core_Protocol.c
qianjiang/main/MCU_Core_Protocol.c
+62
-21
MCU_Core_Protocol.h
qianjiang/main/MCU_Core_Protocol.h
+5
-3
Protocol_User.c
qianjiang/main/Protocol_User.c
+31
-11
gatts_table_creat_demo.c
qianjiang/main/gatts_table_creat_demo.c
+2
-2
No files found.
.vscode/settings.json
View file @
a5107afe
...
...
@@ -5,6 +5,7 @@
"protocol_crc16.h"
:
"c"
,
"gatts_table_creat_demo.h"
:
"c"
,
"app_ble_user.h"
:
"c"
,
"main_user.h"
:
"c"
"main_user.h"
:
"c"
,
"mcu_core_protocol.h"
:
"c"
}
}
\ No newline at end of file
qianjiang/main/MCU_Core_Protocol.c
View file @
a5107afe
#include "Protocol_Lib.h"
#include "MCU_Core_Protocol.h"
#include <string.h>
#include <stdlib.h>
...
...
@@ -9,15 +10,15 @@
void
Uart_ID10_process
(
void
)
{
if
(
1
)
uint8_t
ID10
[
1
]
=
{
0x00
};
if
(
1
)
//蓝牙模组启动状态
{
uint8_t
ID10
[
2
]
=
{
0x00
,
0x01
}
;
Protocol_Send
(
0x
21
,
ID10
,
2
);
ID10
[
0
]
=
0x01
;
Protocol_Send
(
0x
10
,
ID10
,
1
);
}
else
{
uint8_t
ID10
[
2
]
=
{
0x00
,
0x01
};
Protocol_Send
(
0x10
,
ID10
,
2
);
Protocol_Send
(
0x10
,
ID10
,
1
);
}
}
...
...
@@ -43,41 +44,81 @@ void Uart_ID01_process(void)
void
Uart_ID12_process
(
void
)
{
uint8_t
ID12
[
2
]
=
{
0x00
,
0x00
};
ID12
[
1
]
=
Ble_User
.
Ble_Sts
;
Protocol_Send
(
0x12
,
ID12
,
2
);
uint8_t
ID12
[
1
]
=
{
0x00
};
ID12
[
0
]
=
Ble_User
.
Ble_Sts
;
Protocol_Send
(
0x12
,
ID12
,
1
);
}
void
Uart_ID20_process
(
void
)
void
Uart_ID20_process
(
const
Protocol_Data_t
*
pData
)
{
//开始正式通信
}
unsigned
char
ID21_num
=
0
;
void
Uart_ID21_process
(
void
)
//底板给ESP32发
void
Uart_ID02_process
(
void
)
{
uint8_t
ID02
[
1
]
=
{
0x00
};
ID02
[
0
]
=
0
;
//蓝牙电话状态
Protocol_Send
(
0x02
,
ID02
,
1
);
}
uint8_t
ID03
[
33
]
=
{
0x00
};
void
Uart_ID03_process
(
const
Protocol_Data_t
*
pData
)
{
if
(
1
)
if
(
pData
->
Data
[
0
]
==
1
/*接到值为1*/
)
{
ID21_num
++
;
//来电
}
printf
(
"ID21 IS %d!!!
\r\n
"
,
ID21_num
);
else
if
(
pData
->
Data
[
0
]
==
2
/*接到值为2*/
)
{
//去电
}
else
if
(
pData
->
Data
[
0
]
==
3
/*接到值为3*/
)
{
//通话中
}
else
/*默认值*/
{
//无动作
}
/*接到UUID,给蓝牙*/
unsigned
int
i
=
1
;
for
(
i
=
1
;
i
<
33
;
i
++
)
{
ID03
[
i
]
=
pData
->
Data
[
i
+
1
];
//接到串口传来的UUID值
}
}
// unsigned char ID21_num = 0;
// void Uart_ID21_process(const Protocol_Data_t *pData)//底板给ESP32发
// {
// if (1)
// {
// ID21_num++;
// }
// printf("ID21 IS %d!!!\r\n",ID21_num);
// }
void
MCU_T_32
(
void
)
{
// printf("MCU_T_32!!\r\n");
Protocol_Service
();
if
(
ID21_num
>=
5
)
{
ID21_num
=
0
;
//ESP32需要升级
//
if(ID21_num >= 5)
//
{
//
ID21_num = 0;
//
//ESP32需要升级
}
// }
}
...
...
qianjiang/main/MCU_Core_Protocol.h
View file @
a5107afe
#ifndef _MCU_CORE_PROTOCOL_H_
#define _MCU_CORE_PROTOCOL_H_
#include "Protocol_Lib.h"
extern
void
Uart_ID10_process
(
void
);
extern
void
Uart_ID01_process
(
void
);
extern
void
Uart_ID12_process
(
void
);
extern
void
Uart_ID21_process
(
void
);
extern
void
Uart_ID20_process
(
void
);
//extern void Uart_ID21_process(const Protocol_Data_t *pData);
extern
void
Uart_ID20_process
(
const
Protocol_Data_t
*
pData
);
extern
void
Uart_ID02_process
(
void
);
extern
void
Uart_ID03_process
(
const
Protocol_Data_t
*
pData
);
extern
void
MCU_T_32
(
void
);
#endif
qianjiang/main/Protocol_User.c
View file @
a5107afe
...
...
@@ -83,6 +83,12 @@ void Send_UartID(Protocol_uint8_t ID)
case
BLE_NAVIGATION
:
Uart_ID01_process
();
break
;
case
BLE_WEATHER
:
Uart_ID02_process
();
break
;
// case BLE_LOCATION:
// Uart_ID03_process();
// break;
case
BLE_STA
:
Uart_ID12_process
();
break
;
...
...
@@ -93,10 +99,24 @@ void Send_UartID(Protocol_uint8_t ID)
}
void
Protocol_Send_Service
(
void
)
void
Ble_to_MCU
(
void
)
{
Protocol_uint8_t
ID
=
BLE_START_STA
;
Protocol_uint8_t
ID
=
0
;
if
(
1
)
{
ID
=
0
;
}
else
{
}
//判断应该发送哪个ID的串口数据
Send_UartID
(
ID
);
}
void
Protocol_Send_Service
(
void
)
{
Ble_to_MCU
();
Protocol_uint32_t
i
=
0u
;
Protocol_uint32_t
DataLen
=
0u
;
Protocol_uint32_t
SendLen
=
0u
;
...
...
@@ -229,33 +249,33 @@ static Protocol_uint32_t Protocol_UartSend(const Protocol_uint8_t *pData, Protoc
uint8_t
Ble_connect_flag
=
0
;
static
void
Protocol_UartHandle
(
const
Protocol_Data_t
*
pData
)
{
printf
(
"ProcParse success22222222222!!
\r\n
"
);
//
printf("ProcParse success22222222222!!\r\n");
Ble_connect_flag
=
0
;
if
(
pData
->
CmdID
==
BLE_START_STA
)
{
Uart_ID10_process
();
//TX
//
Uart_ID10_process();//TX
}
else
if
(
pData
->
CmdID
==
MCU_REPLY
)
{
Uart_ID20_process
();
Uart_ID20_process
(
pData
);
Ble_connect_flag
=
1
;
}
else
if
(
pData
->
CmdID
==
BLE_NAVIGATION
)
{
Uart_ID01_process
();
//TX
//
Uart_ID01_process();//TX
}
else
if
(
pData
->
CmdID
==
BLE_WEATHER
)
{
//Uart_ID02_process();
}
else
if
(
pData
->
CmdID
==
BLE_LOCATION
)
{
//Uart_ID03_process();
}
else
if
(
pData
->
CmdID
==
BLE_STA
)
{
Uart_ID12_process
();
//TX
//
Uart_ID12_process();//TX
}
else
if
((
pData
->
CmdID
&
0x3f
)
==
MCU_TO_BLE_INFO
)
{
...
...
@@ -267,7 +287,7 @@ static void Protocol_UartHandle(const Protocol_Data_t *pData)
Wifi_OTA_Request
=
1
;
}
}
printf
(
"ID21 IS in!!!
\r\n
"
);
//
printf("ID21 IS in!!!\r\n");
// Uart_ID21_process();//RX
}
else
...
...
@@ -291,6 +311,6 @@ void UART_Put(Protocol_uint16_t Data)
UARTRxBuf
.
Rx_Buffer
[
UARTRxBuf
.
write_pos
]
=
Data
;
UARTRxBuf
.
write_pos
=
(
UARTRxBuf
.
write_pos
+
1
)
%
UART_RX_MAX_DEPTH
;
}
printf
(
"into UARTRxBuf!!!!
\r\n
"
);
//
printf("into UARTRxBuf!!!!\r\n");
return
;
}
qianjiang/main/gatts_table_creat_demo.c
View file @
a5107afe
...
...
@@ -109,8 +109,8 @@ static void rx_task(void *arg)
}
if
(
rxBytes
>
0
)
{
data
[
rxBytes
]
=
0
;
ESP_LOGI
(
RX_TASK_TAG
,
"Read %d bytes: '%s'"
,
rxBytes
,
data
);
ESP_LOG_BUFFER_HEXDUMP
(
RX_TASK_TAG
,
data
,
rxBytes
,
ESP_LOG_INFO
);
//
ESP_LOGI(RX_TASK_TAG, "Read %d bytes: '%s'", rxBytes, data);
//
ESP_LOG_BUFFER_HEXDUMP(RX_TASK_TAG, data, rxBytes, ESP_LOG_INFO);
}
MCU_T_32
();
}
...
...
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