当前位置:网站首页>[Internet of vehicles prototype system II] database + application layer protocol design
[Internet of vehicles prototype system II] database + application layer protocol design
2022-07-23 10:24:00 【Cheney822】
IOT prototype system navigation
【 Prototype system of Internet of vehicles | One 】 Project introduction + Demand analysis + Outline design https://blog.csdn.net/weixin_46291251/article/details/125807297
【 Prototype system of Internet of vehicles | Two 】 database + Application layer protocol design https://blog.csdn.net/weixin_46291251/article/details/125808107
【 Prototype system of Internet of vehicles | 3、 ... and 】 Raspberry pie design + Simulate the base station program https://blog.csdn.net/weixin_46291251/article/details/125808229
【 Prototype system of Internet of vehicles | Four 】adhoc networking +frp Intranet through https://blog.csdn.net/weixin_46291251/article/details/125808621
【 Prototype system of Internet of vehicles | 5、 ... and 】 Fore and aft end separation https://blog.csdn.net/weixin_46291251/article/details/125808674
【 Prototype system of Internet of vehicles | 6、 ... and 】 Effect display https://blog.csdn.net/weixin_46291251/article/details/125808845
【 Source download 】https://download.csdn.net/download/weixin_46291251/86227197
List of articles
【 Prototype system of Internet of vehicles | Two 】 database + Application layer protocol design
Application layer protocol design
The communication between the back end and the car raspberry pie is through socket On going , Therefore, we need to define a private agreement , Distinguish different types of data messages . Data message adoption json Format for transmission .
Overall speaking , Messages can be divided into two categories , One is control message , One is data message . The control message is used for the user to control the car , Data message is used to transmit data information .
Field overall design
The specific fields and corresponding descriptions are shown in the following table :
| Data field | Content description |
|---|---|
| pac_type | Packet type |
| control_type | Distinguish between different message function types |
| src_id | The sender id |
| dst_id | The receiving party id |
| piece | Message fragment mark |
| time | Sender timestamp |
| ack | identification ack |
| length | The length of the message |
| state | Status code |
| alternate | Keep field |
Specific fields
pac_type
The first is the data message type field , This field mainly identifies the flow direction of the message , There are three main directions :
- Raspberry pie To The base station
- The base station To Raspberry pie
- Raspberry pie To Raspberry pie ( Corresponding forwarding to the situation )
| Packet type (pac_type) | Data flow | code |
|---|---|---|
| pi -> pc | 01 | |
| pc -> pi | 10 | |
| pi -> pi | 11 | |
| Retention type | 00 |
control_type
The control type field is used to identify the specific corresponding function of the message , This part should be based on pac_type To make a comprehensive judgment , Different pac_type Will correspond to different meanings :
- For raspberries sent to the base station to the type , It is raspberry that sends feedback data to the base station to the message , It is divided into trajectory data 、 Sensor data 、 And raspberry pie have three kinds of low power .
- For the message type from base station to raspberry , It is mainly the control command issued by the base station , There is a beginning / Stop moving 、 open / Turn off the sensor 、 One click return and forwarding ( Forward the command to the car that is not within the range of the base station ).
- For raspberry pie to raspberry pie type , Similar to the second , Without the forwarding function .
| Field | Instruction meaning | code | |
|---|---|---|---|
| control_type | pac_type == pi -> pc | Trajectory data | 000 |
| Sensor data | 001 | ||
| Low power | 010 | ||
| Unable to avoid obstacles | 011 | ||
| Reserved instructions | 100 | ||
| Reserved instructions | 101 | ||
| Reserved instructions | 110 | ||
| Reserved instructions | 111 | ||
| pac_type == pc -> pi | motion | 000 | |
| stop it | 001 | ||
| Turn back | 010 | ||
| Turn on the sensor | 011 | ||
| Turn off the sensor | 100 | ||
| forward | 101 | ||
| Reserved instructions | 110 | ||
| Reserved instructions | 111 | ||
| pac_type == pi -> pi | motion | 000 | |
| stop it | 001 | ||
| Turn back | 010 | ||
| Turn on the sensor | 011 | ||
| Turn off the sensor | 100 | ||
| Reserved instructions | 101 | ||
| Reserved instructions | 110 | ||
| Reserved instructions | 111 |
state Field
state Fields are mainly used to feed back the data of instruction execution , Success 、 Failure 、 Timeout etc. , Some code is also reserved to pass custom state .
| Status code (state) | meaning | code |
|---|---|---|
| success | 000 | |
| Failure ( Overtime ) | 001 | |
| Failure ( The instruction is illegal ) | 010 | |
| Failure ( reason 3) | 011 | |
| Failure ( reason 4) | 100 | |
| Reserved state | 101 | |
| Reserved state | 110 | |
| Reserved state | 111 |
Other fields
ack Field :
After the system receives a message , You can reply to a ack message , Indicates that you have received the message ( It can be combined with digital signature to realize two-way undeniability )
- Receive one message at a time , After receiving according to the above logic , Just send one ack Send the message to the sender , Indicates that the message has been received .
- One message at a time , After sending according to the above logic , Just charge one ack message , Verifying this message means the end of this transmission .
piece Field :
This field is mainly used to process large messages Fragmentation problem .
Adopt the method of slicing , Head pieces Field to specify whether the current message is the last fragment , Send a completed header and partial message each time ( Depending on MTU).
The receiver receives one at a time MTU The size of the message , Analyze the head pieces Field , Judge the ending condition , After receiving, combine all the data fields to get the completed big message
Data structure design
This part is mainly about the structure of the content field of the message transmitted between the car and the base station
Instructions
| Field | meaning | give an example |
|---|---|---|
| direction(list) | The state of the four buttons | [False,False,False,False] |
| speed | Speed | 50 |
| diff_speed | Steering differential | 20 |
data
| Field | meaning | give an example |
|---|---|---|
| sensor_list | Sensor list | |
| data_list | Data list | |
| trace_stack | Path stack |
Database design
conceptual model
Table structure design
The following table is designed :
- user surface : Store the user's account 、 password 、 The user types ( Grade )、 Landing time
- sensor_info surface : Store the type number of the sensor 、 name 、 grouping 、 Description information
- pi surface : All raspberry pie numbers in the storage system 、 Authority level 、 Describe information, etc
- sensors surface : List of all sensors in the storage system , Include the number of the sensor 、 Number of raspberry pie 、 Sensor type 、SN code ( If there is )、 Authority level
- data_instruction surface : The system issues / All instructions executed , Include instructions id、 user id、 Raspberry pie id、 Time 、 Execution status 、 Instruction type 、 Specific data of the instruction
- data_sensor: surface : Sensor data sheet of raspberry pie feedback , Including data id、 sensor id、 user id、 Time 、 Specific sensor data
- data_trace surface : Raspberry pie feedback track data sheet , Including data id、 user id、 Raspberry pie id、 Time 、 Specific trajectory data .
There are the following fields
data_instruction : [‘id’, ‘user_id’, ‘pi_id’, ‘time’, ‘state’, ‘type’, ‘data’]
data_sensor : [‘id’, ‘sensor_id’, ‘user_id’, ‘data’, ‘time’]
data_trace : [‘id’, ‘user_id’, ‘pi_id’, ‘time’, ‘data’]
pi : [‘id’, ‘level’, ‘description’]
sensor_info : [‘id’, ‘name’, ‘group’, ‘description’]
sensors : [‘id’, ‘pi_id’, ‘sensor_type’, ‘SN’, ‘level’]
user : [‘id’, ‘passwd’, ‘level’, ‘reg_time’]
ER chart
Sensor table section

Instruction storage section

Path storage section

Sensor data section

total

The physical model :
A little , see sql In the file
Crow‘foot chart

边栏推荐
- 缓存穿透、缓存击穿、缓存雪崩
- Error msb4181: the "qtrunwork" task returned false, but no error was recorded
- 金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(二))
- Normal form and anti normal form
- moment 获取周、月、季、年
- C语言——几道C语言经典习题
- 你离个人信息泄漏的安全距离,或许一台笔记本电脑就可以决定!
- 目标检测xml文件实现mixup数据增强(修改文件路径直接能用,非常方便)
- Arcgis 计算两个栅格图层相关性
- GNN-第三方库:PyG(Pytorch Geometric)【基于Pytorch构建的库,可以帮助用户快速构建和训练自己的图神经网络模型】【DeepWalk、LINE、GCN、GAT等】
猜你喜欢
随机推荐
【Azure 事件中心】Azure Event Hub 新功能尝试 -- 异地灾难恢复 (Geo-Disaster Recovery)
1. Assignment statement
信息安全危机四伏,企业数据资产泄露管控刻不容缓
三数之和:(排序+双指针+剪枝)
QT error: error c2039 "value": not a member of "`global namespace"
C language file operation
在线问题反馈模块实战(十一):实现图片下载功能
GNN third party Library: pyg (pytorch geometric) [the library based on pytorch can help users quickly build and train their own graph neural network model] [deepwalk, line, GCN, gat, etc.]
禅道的甘特图功能是什么
金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(八))
Illustration and text demonstrate the movable range of the applet movable view
Error msb4181: the "qtrunwork" task returned false, but no error was recorded
31-spark的算子使用及调度流程
Scala对象object
你离个人信息泄漏的安全距离,或许一台笔记本电脑就可以决定!
Qt报错:错误 C2039 “Value“: 不是 “`global namespace‘“ 的成员
Self organization is the two-way rush of managers and members
Redis安装
How to build and use redis fragment cluster
金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(六))

![[MySQL] cursor](/img/60/19236cee3adafe27c431582ec053f8.png)







