MicroPython 1.17+ 的 Google Protobuf 实现
主要特点:
- KISS 和 ideomatic 代码库
- 嵌入式代码(包括自动生成的)应尽可能小且快
- 纯python代码
- 应该在尽可能多的设备上工作
支持的功能
- Protobuf 2 syntax
- Scalar types encoding and decoding with implicit and explicit defaults
- Nested messages
- Message type fields
- Enums without implicit default value
- Repeated fields (partly implemented)
TODO
- Protobuf 3 syntax
- Repeated fields complete and test (including packed)
- Test message fields
- OneOf fields
- Maps
Groups won't be implemented since they are considered depricated. Required fields check is not implemented for now in favour of efficiency.
已测试的硬件
- PC (Mac)
- ESP32-wroom
- ESP8266 (LoLin V3)
import animal_upb2
animal = animal_upb2.Animal()
animal.name = "Dog"
encoded_message = animal.encode()
animal1 = Animal.decode(encoded_message)