Exemple #1
0
func (deviceList *DeviceList) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, deviceList.Header())
	read += bytesRead
	if err != nil {
		return
	}
	var length int
	bytesRead, err = encoding.ReadInt(reader, &length)
	read += bytesRead
	if err != nil {
		return
	}
	devices := make([]encoding.Device, length)
	for index := 0; index < length; index++ {
		device := *new(encoding.Device)
		bytesRead, err = encoding.ReadCSUUID(reader, &device.ClusterId, &device.DeviceId)
		read += bytesRead
		if err != nil {
			return
		}
		devices[index] = device
	}
	deviceList.Devices = devices
	return
}
Exemple #2
0
func (request *DeviceChangeRequest) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, request.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadUUID(reader, &request.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &request.Current.ClusterId, &request.Current.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &request.Previous.ClusterId, &request.Previous.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Exemple #3
0
func (connChange *ConnChange) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, connChange.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &connChange.ClusterId, &connChange.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	var rawStatus int
	bytesRead, err = encoding.ReadInt(reader, &rawStatus)
	read += bytesRead
	if err != nil {
		return
	}
	connChange.Status = ConnStatus(rawStatus)
	return
}
Exemple #4
0
func (request *DeliverRequest) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, request.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadUUID(reader, &request.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &request.ClusterId, &request.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadString(reader, &request.Data, encoding.MaxPayloadSize)
	read += bytesRead
	if err != nil {
		return
	}
	return
}