当前位置:网站首页>[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


【 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 -> pc01
pc -> pi10
pi -> pi11
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_typepac_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

image-20220714151252012

Instruction storage section

image-20220714151313408

Path storage section

image-20220714151326221

Sensor data section

image-20220714151348806

total

image-20220714151403831

The physical model :

A little , see sql In the file

Crow‘foot chart

image-20220714151516002

原网站

版权声明
本文为[Cheney822]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207230336071702.html