简体   繁体   English

带C的Z波协议:关于Z波帧结构和编程的一般问题

[英]Z-wave protocol with C: Questions about Z-wave frame structure & programming in general

(Before I ask my question; I don't really know if anyone is allowed to answer my question since the Z-wave protocol is supposed to be confidential information, but if it does indeed violate against any kind of regulation then feel free to delete this post.) (在我提出问题之前;我不知道是否允许任何人回答我的问题,因为Z波协议应该是机密信息,但如果它确实违反了任何类型的规则,那么随意删除这个帖子。)

I am currently trying to write a C program that simply constructs a Z-wave message consisting of raw binary data and then sends that message to a USB interface where a Z-wave controller is connected (I am using the AEOTEC Z-Stick USB dongle by Aeon Labs). 我目前正在尝试编写一个C程序,它只是构造一个由原始二进制数据组成的Z波消息,然后将该消息发送到连接Z波控制器的USB接口(我正在使用AEOTEC Z-Stick USB加密狗由Aeon Labs提供)。 I am also using this guide as a reference and trying to re-write the sample code in plain C. However, if you take a look at the guide, specifically the message he is trying to send to the USB controller: 我也使用指南作为参考,并试图在简单C中重写示例代码。但是,如果你看一下指南,特别是他试图发送给USB控制器的消息:

/*
0x01, 0x09, 0x00, 0x13, nodeId, 0x03, 0x20, 0x01, state, 0x05, checksum
*/

... maybe it's just me but it seems like some information from the usual Z-wave frame is missing. ...也许只是我,但似乎缺少来自通常的Z波框架的一些信息。 My guess is that the first 4 bytes represent the Home ID followed by the node ID, but I can't make out what the '0x03' means after that, supposing that the rest after that byte represent the "Basic" command class ('0x20', 1 byte) and the corresponding "Set" application command ('0x01', 1 byte). 我的猜测是前4个字节代表Home ID后跟节点ID,但是我无法弄清楚'0x03'之后的含义,假设该字节后的其余部分代表“Basic”命令类(' 0x20',1字节)和相应的“设置”应用程序命令('0x01',1字节)。 And what does the '0x05' stand for before the checksum bit? 在校验和位之前'0x05'代表什么? And what about the transport header information, why isn't it included? 那传输头信息呢,为什么不包含它? It seems like he didn't need to include it... or maybe I'm just interpreting the packet completely wrong. 看起来他不需要包含它......或者我只是在解释数据包完全错误。 Can someone enlighten me please? 有人可以开导我吗?

Also, is it correct that you can only retrieve application-layer information fom the USB port if you read from it (f.ex. with a open() & read() command in C)? 另外,如果您从USB端口读取应用程序层信息(f.ex.中带有open()&read()命令,那么它是否正确无法检索应用程序层信息?)

Thank you in advance! 先感谢您!

I think you'd save considerable time and effort by studying OpenZWave's source code . 我认为通过研究OpenZWave的源代码可以节省大量的时间和精力。 This is an open source C++ library for working with ZWave which is quite mature and feature-complete. 这是一个用于处理ZWave的开源C ++库,它非常成熟且功能齐全。 You could easily use it from plain C. 你可以从平原C轻松使用它。

Part of what you're asking can be seen in the Msg class constructor which constructs the start of frame (0x01), followed by message length (0x09 == 9 bytes), message type (0x00 == REQUEST), and function (FUNC_ID_ZW_SEND_DATA == 0x013), then comes the target nodeID, then comes the actual command body, which I suppose is for a basic command: 您可以在Msg类构造函数中看到您要求的部分内容,该构造函数构造帧的开始(0x01),后跟消息长度(0x09 == 9字节),消息类型(0x00 == REQUEST)和函数(FUNC_ID_ZW_SEND_DATA) == 0x013),然后是目标nodeID,然后是实际的命令体,我想这是一个基本的命令:

./src/Defs.h:#define COMMAND_CLASS_BASIC 0x20 : ./src/Defs.h:#define COMMAND_CLASS_BASIC 0x20

bool Basic::SetValue
...
            Msg* msg = new Msg( "BasicCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
            msg->SetInstance( this, _value.GetID().GetInstance() );
            msg->Append( GetNodeId() );
            msg->Append( 3 );
            msg->Append( GetCommandClassId() );
            msg->Append( BasicCmd_Set );
            msg->Append( value->GetValue() );
            msg->Append( GetDriver()->GetTransmitOptions() );
            GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
            return true;
    }

    return false;
}

Found what I was looking for. 找到了我想要的东西。 In case anyone is interested, here's what I found after days and days of googling... 如果有人有兴趣,这是我在谷歌搜索的日子和天后发现的......

Huge compilation of Z-Wave information 巨大的Z-Wave信息汇编

A bit further down on that page (directly under the Z-Wave frame description) is a description of the frame structure that is used to communicate directly with the USB controller. 在该页面上稍微向下(直接在Z-Wave帧描述下)是用于直接与USB控制器通信的帧结构的描述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM