public function consumeFrame(&$frame)
 {
     $this->setExtendedPanId(Buffer::unpackEui64($frame));
     $this->setExtendedAddress(Buffer::unpackEui64($frame));
     $this->setNetworkAddress(Buffer::unpackInt16u($frame));
     $byte1 = Buffer::unpackInt8u($frame);
     $this->setDeviceType(($byte1 & 3) >> 0);
     $this->setRxOnWhenIdle(($byte1 & 12) >> 2);
     $this->setRelationship(($byte1 & 112) >> 5);
     $byte2 = Buffer::unpackInt8u($frame);
     $this->setPermitJoining($byte2 & 3);
     $this->setDepth(Buffer::unpackInt8u($frame));
     $this->setLqi(Buffer::unpackInt8u($frame));
 }
Пример #2
0
 public function setFrame($frame)
 {
     $this->setFrameEncoding(Buffer::unpackInt8u($frame));
     if ($this->getFrameEncoding() == self::FRAME_ENCODING_BASE64) {
         $frame = base64_decode($frame);
     }
     if ($frame === false) {
         throw new ZigbeeException("Error decoding base64");
     }
     if (!self::validateChecksum($frame)) {
         throw new ZigbeeException("Invalid checksum");
     }
     $this->setSMSHeader(Buffer::unpackInt8u($frame));
     Buffer::unpackInt16u($frame);
     // Checksum
     if ($this->isExtHeaderPresent()) {
         $this->setExtHeader(Buffer::unpackInt8u($frame));
     }
     if ($this->isTazBlockCountPresent()) {
         $this->setTazBlockCount(Buffer::unpackInt8u($frame));
     }
     if ($this->isAddressPresent()) {
         switch ($this->getAddressType()) {
             case self::ADDRESS_TYPE_EUI64:
                 $this->setAddress(Buffer::unpackEui64($frame));
                 break;
             case self::ADDRESS_TYPE_NODE_ID:
                 $this->setAddress(Buffer::unpackInt16u($frame));
                 break;
         }
     }
     for ($taz_index = 0; $taz_index < $this->getTazBlockCount(); $taz_index++) {
         $header = Buffer::unpackInt8u($frame);
         $length = Buffer::unpackInt8u($frame);
         $taz_frame = "";
         Buffer::packInt8u($taz_frame, $header);
         Buffer::packInt8u($taz_frame, $length);
         if ($length > strlen($frame)) {
             throw new ZigbeeException("Taz frame is too short");
         }
         $taz_frame .= substr($frame, 0, $length);
         $frame = substr($frame, $length);
         $this->taz_blocks[$taz_index] = new SMSTazBlock($taz_frame);
     }
     if (strlen($frame) > 0) {
         throw new ZigbeeException("Unparsed data (" . strlen($frame) . " bytes) at end of frame");
     }
 }
 public function setFrame($frame)
 {
     $this->setStatus(Buffer::unpackInt8u($frame));
     $this->setIeeeAddressRemoteDev(Buffer::unpackEui64($frame));
     $this->setNwkAddrRemoteDev(Buffer::unpackInt16u($frame));
     if (strlen($frame) > 0) {
         $this->setRequestType(self::REQUEST_TYPE_EXTENDED);
         $num_assoc_dev = Buffer::unpackInt8u($frame);
         // If there are any devices listed
         if ($num_assoc_dev > 0) {
             $this->setStartIndex(Buffer::unpackInt8u($frame));
             for ($i = 0; $i < $num_assoc_dev; $i++) {
                 $this->addAssociatedDevice(Buffer::unpackInt16u($frame));
             }
         }
     }
 }
Пример #4
0
 public function setFrame($frame)
 {
     $this->setIeeeAddress(Buffer::unpackEui64($frame));
     $this->setRequestType(Buffer::unpackInt8u($frame));
     $this->setStartIndex(Buffer::unpackInt8u($frame));
 }