什么是蓝牙Mesh设备扩展协议

发布时间:2024-11-24 06:58

蓝牙设备配对步骤1: 打开设备搜索模式,通常是长按设备的蓝牙按钮。 #生活技巧# #数码产品使用技巧# #蓝牙设备配对教程#

本文为介绍为智能家居设备制定的蓝牙Mesh扩展消息定义,便于更多的智能家居设备通过蓝牙Mesh技术来接入生活物联网平台。自有品牌项目与天猫精灵生态项目均遵循本协议。

背景信息

蓝牙技术联盟(Bluetooth SIG)定义的SIG Mesh的模型目前尚未覆盖所有的智能家居设备,我们采用厂商自定义模型(Vendor Model)来实现智能家居设备的控制和状态上报。在天猫精灵生态项目中,Mesh网关包括天猫精灵音箱与天猫精灵App。在自有品牌项目中,Mesh网关包括自有品牌项目Mesh网关产品与云智能App。注意以下部分消息仅在天猫精灵生态项目中支持。

Vendor Model

SIG定义Vendor Model格式为4字节(其中2字节的Company ID和2字节的Vendor-assigned Model ID),其中Alibaba的Company ID为0x01A8,如下表所示。

字段字节数说明 字段 字节数 说明 16-bit Company Identifier 2 0x01A8 16-bit vendor-assigned model Identifier 2 -

下表为两个VendorModel ID,用于消息扩展用。

Model NameSIG Model ID Model Name SIG Model ID Vendor Model Server 0x01A80000 Vendor Model Client 0x01A80001

说明

Mesh设备作为Vendor Model Server,Mesh网关作为Vendor Model Client。

扩展消息操作码

在蓝牙Mesh协议中规定,操作码分为3种:1字节Opcode、2字节Opcode、3字节Opcode。

1字节Opcode的最高位为0,所以1字节Opcode的取值范围从0x00-0x7e(其中0x7f用于将来扩展用)。 2字节Opcode第一字节的最高位为1,第2位为0,所以2字节OpCode的取值范围从0x8000到0xbfff,都为SIG分配。 3字节Opcode第一字节的最高两位均为1,后两字节z是由SIG分配的Company ID,Company ID使用小端优先的方式传输,阿里巴巴使用的Company ID为0x01a8。6 bit的x可由厂商定义64个Opcodes。 Opcode Format说明 Opcode Format 说明 0b0xxxxxxx(排除0b01111111) 1字节Opcode。 0b01111111 保留,用于将来扩展。 0b10xxxxxx xxxxxxxx 2字节Opcode。 0b11xxxxxx zzzzzzzz zzzzzzzz 3字节Opcode。

操作码定义

智能生活平台蓝牙Mesh扩展消息Opcode定义如下表所示。

Vendor Message NameOpcode Vendor Message Name Opcode Vendor Message Attribute Get 0xD001A8 Vendor Message Attribute Set 0xD101A8 Vendor Message Attribute Set Unacknowledged 0xD201A8 Vendor Message Attribute Status 0xD301A8 Vendor Message Attribute Indication 0xD401A8 Vendor Message Attribute Confirmation 0xD501A8 Vendor Message Attribute Indication To Tmall Genie 0xDE01A8 Vendor Message Attribute Confirmation From Tmall Genie 0xDF01A8 Vendor Message Transparent msg 0xCF01A8 Vendor Message Transparent Indication 0xCE01A8 Vendor Message Transparent ACK 0xCD01A8

Vendor Model属性消息结构

Vendor message里的数据都使用小端优先方式传输。

Vendor Message Attribute Get

该消息用于Vendor Model Client获取Vendor Model Server的一个或多个属性值,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xD001A8 TID 1 Transaction Identifier,每条新消息递增 Attribute Type 2 读取的Attribute类型

Attribute Type最多可有15个。当Vendor Model Server收到Attribute Get消息后,必须向Vendor Model Client回复Attribute Status。如Vendor Model Client在下发该命令之后未收到Vendor Model Server返回的Attribute Status,可以再次下发该指令。

Vendor Message Attribute Set

该消息用于Vendor Model Client设置Vendor Model Server的一个或多个属性值,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xD101A8 TID 1 Transaction Identifier,每条新消息递增 Attribute Type 2 设置的Attribute类型 Attribute Parameter N 设置的Attribute参数

Attribute Type和Attribute Parameter最多可有15个。当Vendor Model Server收到Attribute Set消息后,必须向Vendor Model Client回复Attribute Status。如Vendor Model Client在下发该命令之后未收到Vendor Model Server返回的Attribute Status,可以再次下发该指令。

Vendor Message Attribute Set Unacknowledged

该消息用于Vendor model Client设置Vendor Model Server的一个或多个属性值,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xD201A8 TID 1 Transaction Identifier,每条新消息递增 Attribute Type 2 设置的Attribute类型 Attribute Parameter N 设置的Attribute参数

Attribute Type和Attribute Parameter最多可有15个。当Vendor Model Server收到Attribute Set Unacknowledged消息后,不需要向Vendor Model Client发送Attribute Status消息。

Vendor Message Attribute Status

该消息用于Vendor Model Server回复Attribute Get和Attribute Set命令或上报设备状态信息给Vendor Model Client,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xD301A8 TID 1 Transaction Identifier,每条新消息递增 Attribute Type 2 上报的Attribute类型 Attribute Parameter N 上报的Attribute参数

Vendor Model Client收到Attribute Status后,不需要回复消息给Vendor Model Server。

Vendor Message Attribute Indication

该消息用于Vendor Model Server发送属性给Vendor Model Client,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xD401A8 TID 1 Transaction Identifier,每条新消息递增,回复控制命令的TID为下发消息的TID;设备状态主动改变上报的TID从128到191循环。 Attribute Type 2 上报的Attribute类型 Attribute Parameter N 上报的Attribute参数

Attribute Type和Attribute Parameter最多可有15个。当Vendor Model Client收到Attribute Indication消息后,必须向Vendor Model Server回复Attribute Confirmation。如Vendor Model Server在发出该命令之后未收到Vendor Model Client回复的confirmation,可以再次发送该指令。

Vendor Message Attribute Confirmation

该消息用于Vendor Model Client回复给Vendor Model Server,用于表示已收到Vendor Model Server发出的Indication,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xD501A8 TID 1 Transaction Identifier,收到的Indication消息的TID

Vendor Model Server收到Attribute Confirmation后,不需要回复消息给Vendor Model Client。

Vendor Message Attribute Indication To TmallGenie

该消息用于天猫精灵生态项目Vendor Model Server发送属性给Vendor Model Client,该消息由天猫精灵音箱直接处理,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xDE01A8 TID 1 Transaction Identifier,每条新消息递增 Attribute Type 2 上报的Attribute类型 Attribute Parameter N 上报的Attribute参数

Attribute Type和Attribute Parameter最多可有15个。当Vendor Model Client收到Attribute Indication消息后,必须向Vendor Model Server回复Attribute Confirmation。如Vendor Model Server在发出该命令之后未收到Vendor Model Client回复的Confirmation,可以再次发送该指令。

Vendor Message Attribute Confirmation From TmallGenie

该消息用于天猫精灵生态项目Vendor Model Client回复给Vendor Model Server,用于表示天猫精灵音箱已收到Vendor Model Server发出的Indication,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xDF01A8 TID 1 Transaction Identifier,每条新消息递增 Attribute Type 2 设置的Attribute类型 Attribute Parameter N 设置的Attribute参数

Attribute Type和Attribute Parameter的个数从0到15。Vendor Model Server收到Attribute Confirmation后,不需要回复消息给Vendor Model Client。

说明

TID:对于TID相同的消息,需按照协议回复对应的消息,但应用层是否处理则由产品自身特性决定。

Vendor Model透传消息结构

Vendor message里的数据都使用小端优先方式传输。

Vendor Message Transparent Message

该消息用于Mesh设备与天猫精灵音箱与天猫精灵App之间透传数据,Payload数据格式由各厂家自己实现。

字段字节数说明 字段 字节数 说明 Opcode 3 0xCF01A8 TID 1 Transaction Identifier,每条新消息递增,回复控制命令的TID为下发消息的TID;设备状态主动改变上报的TID从0到255循环。 Payload N 由厂商自定义 Vendor Message Transparent Indication

该消息用于天猫精灵生态项目中Vendor Model Server发送属性给Vendor Model Client,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xCE01A8 TID 1 Transaction Identifier,每条新消息递增,回复控制命令的TID为下发消息的TID;设备状态主动改变上报的TID从128到191循环。 Payload N 由厂商自定义 Vendor Message Transparent ACK

该消息用于天猫精灵生态项目中Vendor Model Client回复给Vendor Model Server,用于表示已收到Vendor Model Server发出的Transparent Indication,消息格式如下。

字段字节数说明 字段 字节数 说明 Opcode 3 0xCD01A8 TID 1 Transaction Identifier,收到的Indication消息的TID。

说明

TID:对于TID相同的消息,需按照协议回复对应的消息,但应用层是否处理则由产品自身特性决定。

Vendor Message 示例数据

Vendor Model Client设置目标温度

本示例为Vendor Model Client设置目标温度为22摄氏度。

Vendor Model Client下发设置目标温度的Attribute Set命令。 0xD1 0xA8 0x01 0x01 0x0C 0x01 0x4B 0x73 Opcode TID Attribute Type Attribute Value 0xD101A8 01 目标温度(0x010C) 目标温度值:22摄氏度(0x734B = 295.15K) Vendor Model Server设置目标温度成功时返回的Attribute Status如下。 0xD3 0xA8 0x01 0x01 0x0C 0x01 0x4B 0x73 Opcode TID Attribute Type Attribute Value 0xD301A8 01 目标温度(0x010C) 目标温度值:22摄氏度(0x734B = 295.15K) Vendor Model Server设置目标温度失败时返回的Attribute Status如下。 0xD3 0xA8 0x01 0x01 0x00 0x00 0x0C 0x01 0x80 Opcode TID Error Code Type Attribute Type Error Code 0xD301A8 01 0x0000 目标温度(0x010C) 状态码:设备未准备好(0x80) Vendor Model Client读取数据

本示例为Vendor Model Client读取前后位置,当前温度,当前湿度。

Vendor Model Client发送Attribute Get读取前后位置、当前温度、当前湿度属性的值如下。 0xD0 0xA8 0x01 0x01 0x10 0x01 0x0D 0x01 0x0F 0x01 Opcode TID Attribute Type Attribute Type Attribute Type 0xD001A8 01 前后位置(0x0110) 当前温度(0x010D) 当前湿度(0x010F) Vendor Model Server读取三个属性成功时返回的Attribute Status如下。 D3 A8 01 01 10 01 32 0D 01 4B 73 0F 01 2D 00 Opcode TID Attribute Type Attribute Value Attribute Type Attribute Value Attribute Type Attribute Value 0xD301A8 01 前后位置(0x0110) 前后位置:50(0x32) 当前温度(0x010D) 当前温度:22摄氏度(0x734B=295.15K) 当前湿度(0x010F) 当前湿度:45%(0x002D) Vendor Model Server读取温度失败时返回的Attribute Status如下。 D3 A8 01 01 10 01 32 00 00 0D 01 81 0F 01 2D 00 Opcode TID Attribute Type Attr. Value Error Code Type Attribute Type Error Code Attribute Type Attribute Value 0xD301A8 01 前后位置 前后位置:50(0x32) 0x0000 当前温度(0x010D) 错误码:不支持的属性(0x81) 当前湿度 当前湿度值:45%(0x002D) Vendor Model Server上报温度

本示例为Vendor Model Server发送温度给Vendor Model Client。

Vendor Model Server发送Attribute Indication上报温度如下。 0xD4 0xA8 0x01 0x80 0x0D 0x01 0x4B 0x73 Opcode TID Attribute Type Attribute Value 0xD401A8 80 当前温度(0x010D) 当前温度值:22摄氏度(0x734B = 295.15K) Vendor Model Client收到Attribute Indication后发送Confirmation如下。 0xD5 0xA8 0x01 0x80 Opcode TID 0xD501A8 80 Vendor Model Server上报漏水故障

本示例为Vendor Model Server上报漏水故障给Vendor Model Client。

Vendor Model Server发送Attribute Indication上报漏水故障如下。 0xD4 0xA8 0x01 0x80 0x09 0xF0 0x00 0x00 0x00 0xAA Opcode TID Attribute Type Attribute Value Error Code Type Error Code Value 0xD401A8 80 事件 (0xF009) 故障事件(0x00) 错误码属性(0x0000) 错误码:漏水故障(0xAA) Vendor Model Client收到Attribute Indication后发送Confirmation如下。 0xD5 0xA8 0x01 0x80 Opcode TID 0xD501A8 80

网址:什么是蓝牙Mesh设备扩展协议 https://www.yuejiaxmz.com/news/view/229497

相关内容

如何开发蓝牙Mesh智能灯设备固件
企一照明U7系列(蓝牙mesh)灯带全新上市,别墅照明设计新选择
蓝牙智能门锁现状分析
WiFi+BLE蓝牙模块在物联网设备的应用案例
十款多功能智能蓝牙音箱排行榜 wifi智能蓝牙音箱品牌产品推荐→买购网
如何使用蓝牙设备端SDK用户编程接口
无线or有线,智能家居互联互通如何破解?
什么是智能家居?有哪些好用的功能?
3款巨好用的跨平台协作软件,实现设备间文件同步与屏幕扩展
小米智能多模网关2智能设备优惠来袭,让智能家居更便捷高效

随便看看