Giter VIP home page Giter VIP logo

Comments (3)

manup avatar manup commented on September 25, 2024

That's a Zigbee Green Power (ZGP) raw data indication frame

CMD_GP_DATA_INDICATION = 0x19

The frame is formatted identical to the ZGP specification (just a raw copy).
If it is helpful here is the C++ code how it is processed:

Note: Often the same frame is received 3 times this needs to be filtered by the application.

bool GpDataIndication::readFromStream(QDataStream &stream)
{
    Q_D(GpDataIndication);

    if (stream.atEnd()) { return false; }
    stream >> d->nwkFrameControl;

    // check frame type
    quint8 frameType = d->nwkFrameControl & 0x03;

    if ((frameType != GP_NwkDataFrame) &&
        (frameType != GP_NwkMaintenanceFrame))
    {
        return false;
    }

    // check green power protocol version
    if (((d->nwkFrameControl >> 2)& 0x03) != GP_NwkProtocolVersion)
    {
        return false;
    }

    // extended frame control
    if (d->nwkFrameControl & GP_NwkFrameControlExtensionFlag)
    {
        if (stream.atEnd()) { return false; }
        stream >> d->nwkExtFrameControl.byte;
    }
    else
    {
        d->nwkExtFrameControl.byte = 0;
    }

    // check supported application IDs
    switch (d->nwkExtFrameControl.bits.applicationId)
    {
    case 0: // 0b000 (GP)
    case 2: // 0b010 (GP)
    case 1: // 0b001 (LPED)
        break;

    default:
        return false;
    }

    // GPD SrcID field
    if ((frameType == GP_NwkDataFrame) && (d->nwkExtFrameControl.bits.applicationId == 0))
    {
        if (stream.atEnd()) { return false; }
        stream >> d->gpdSrcId;
    }
    else if ((frameType == GP_NwkMaintenanceFrame) && (d->nwkFrameControl & GP_NwkFrameControlExtensionFlag) && (d->nwkExtFrameControl.bits.applicationId == 0))
    {
        if (stream.atEnd()) { return false; }
        stream >> d->gpdSrcId;
    }
    else
    {
        d->gpdSrcId = 0; // unspecified
    }

    // frame counter filed
    // The presence and length of the Security frame counter field is dependent on the value of ApplicationID
    // and SecurityLevel (see A.1.4.1.3).
    d->frameCounter = 0;
    if (d->nwkFrameControl & GP_NwkFrameControlExtensionFlag)
    {
        switch (d->nwkExtFrameControl.bits.applicationId)
        {
        case 0: // 0b000 (GP)
        case 2: // 0b010 (GP)
        {
            switch (d->nwkExtFrameControl.bits.securityLevel)
            {
            case 0: // 0b00 No security
            case 1: // 0b01 1LSB of frame counter and short (2B) MIC only
                break;

            case 2: // 0b10 Full (4B) frame counter and full (4B) MIC only
            case 3: // 0b11 Encryption & full (4B) frame counter and full (4B) MIC
            {
                if (stream.atEnd()) { return false; }
                stream >> d->frameCounter;
            }
                break;

            default:
                break;
            }
        }
            break;

        case 1: // 0b001 (LPED)
            break;

        default:
            break;
        }
    }

    d->gpdCommandPayload.clear();

    switch (d->nwkExtFrameControl.bits.applicationId)
    {
    case 0: // 0b000 (GP)
    case 2: // 0b010 (GP)
    {
        if (stream.atEnd()) { return false; }
        stream >> d->gpdCommandId;

        quint8 byte;
        while (!stream.atEnd())
        {
            stream >> byte;
            d->gpdCommandPayload.append(byte);
        }
    }
        break;

    default:
        d->gpdCommandId = 0;
        break;
    }

    return true;
}

from deconz-serial-protocol.

dbdbdb avatar dbdbdb commented on September 25, 2024

Thanks a lot Manuel. I really appreciate your work! I've been using the serial protocol for a couple of years and it has been working great for me. Time for me to read up on the ZGP specification that I've mostly managed to avoid so far! :-)

Do you want to keep the issue open? In case you want to update the documentation I mean.

from deconz-serial-protocol.

manup avatar manup commented on September 25, 2024

Yes lets keep it open until this is completed in the docs.

from deconz-serial-protocol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.