# BabyOS_Protocol **Repository Path**: duking/BabyOS_Protocol ## Basic Information - **Project Name**: BabyOS_Protocol - **Description**: 使用QTCreate编写的上位机,配合BabyOS的通用协议b_protocol使用 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: https://gitee.com/notrynohigh/BabyOS - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 12 - **Created**: 2024-09-02 - **Last Updated**: 2024-09-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BabyOS_Protocol ## 介绍 使用QTCreate编写的上位机,配合BabyOS的通用协议b_mod_protocol使用。上位机协议格式配置如下: | 头部 | ID | 长度 | 指令 | 参数 | 校验 | | ----- | ------ | ------ | ----- | -------- | ----- | | 1Byte | 4Bytes | 2Bytes | 1Byte | 0~nBytes | 1Byte | `上位机的设备ID为 0x1314` --- ### 测试指令 | 指令 | 参数(7Bytes) | | ---- | ------------ | | 0x1 | "BabyOS" | --- ### 设置时间指令 | 指令 | 参数(4Bytes) | | ---- | ------------ | | 0x2 | UTC | --- ### 通知新固件信息 (触发OTA) `(上位机==>设备)` | 指令 | 参数(72Bytes) | | ---- | ------------ | | 0x3 | 文件大小(4Bytes) CRC32校验值(4Bytes) 固件名(64Bytes)| `固件名长度不足64字节时,补0` ```c typedef struct { uint32_t size; uint32_t crc32; char filename[64]; }fwinfo_t; ``` ### 回复OTA通知 `(设备==>上位机)` | 指令 | 参数(0) | | ---- | ------------ | | 0x3 | 无参数 | --- ### 请求分包数据指令 `(设备==>上位机)` | 指令 | 参数(2Bytes) | | ---- | ------------ | | 0x4 | 分包序号(2Bytes)| `分包序号从0开始` ### 回复分包数据指令 `(上位机==>设备)` | 指令 | 参数(514Bytes) | | ---- | ------------ | | 0x4 | 分包序号(2Bytes) 数据长度(512Bytes)| `剩余长度不足512字节时,补0` --- ### 上报升级/传输文件结果指令 `(设备==>上位机)` | 指令 | 参数(1Bytes) | | ---- | ------------ | | 0x5 | 升级结果(1Bytes)| `校验成功:0` `校验失败:1` `固件名不匹配:2` `文件长度不合理:3` `超时:4` ### 确认升级结果指令 `(上位机==>设备)` | 指令 | 参数(0Bytes) | | ---- | ------------ | | 0x5 | 无参数| --- ### 传输文件至FLASH `(上位机==>设备)` | 指令 | 参数(16Bytes) | | ---- | ------------------------------------------------------------ | | 0x6 | 文件大小(4Bytes) CRC32校验值(4Bytes) 设备号(4Bytes)偏移地址(4Bytes) | ```c typedef struct { uint32_t size; uint32_t crc32; uint32_t dev_no; uint32_t offset; }file_trans_t; ``` 通过指令4获取文件数据。