How to exchange data between embedded chip and java background?

encountered a project, there is a SpringBoot background, the terminal is an embedded chip, the data exchange between the two is required to be binary. Contact with this requirement for the first time, unlike the previous interaction with the mobile phone APP, do not know how to interact with the embedded chip data, such as the traditional controller return json data? Or do you want to use the socket protocol? In addition, how to subpackage the data? I hope you can give us some guidance. Thank you!


look at the resources of your embedded chip. If the memory is only more than ten k bytes or a few k bytes of single-chip microcomputer, it should not be possible to use json, a single json parser will take up a large part of the chip resources. One of the feasible solutions is to define the protocol by yourself, including the message format, the function of each field, and the corresponding type of each message. In embedded c code, you usually use struct structure to represent a message, and in your background program, you should define the data structure in the same way as in embedded programs. TLV is usually used to define the data structure, which is convenient for both parties to parse and consider future upgrades. Another solution is to use google protobuf (or ASN.1) as a serialization tool (library), which allows you to describe your protocol in a specific language (that is, all kinds of messages to be communicated between background programs and terminals), and automatically generate serialization and deserialization code on different platforms according to this protocol, so as to achieve the goal of communicating in programs of different programming languages.

Menu