コード例 #1
0
func Parse_Add_Del_Device(buffer []byte, id uint64) *Add_Del_Device_Packet {
	reader := ParseHeader(buffer)
	action, _ := reader.ReadByte()
	deviceid := base.ReadQuaWord(reader)
	namelen, _ := reader.ReadByte()
	name := base.ReadString(reader, namelen)
	device_type_count, _ := reader.ReadByte()
	var device base.Device
	device.ID = deviceid
	device.Name = name
	for i := 0; byte(i) < device_type_count; i++ {
		endpoint, _ := reader.ReadByte()
		devicetypeid := base.ReadWord(reader)
		var zonetype uint16 = 0
		if devicetypeid == base.SS_Device_DeviceTypeID {
			zonetype = base.ReadWord(reader)
		}
		device.Endpoints = append(device.Endpoints, base.Endpoint{
			Endpoint:     endpoint,
			DeviceTypeID: devicetypeid,
			Zonetype:     zonetype,
		})
	}

	return &Add_Del_Device_Packet{
		GatewayID: id,
		Name:      name,
		Action:    action,
		Device:    &device,
	}
}
コード例 #2
0
func Parse_Feedback_Query_Attr(buffer []byte, id uint64) *Feedback_Query_Attr_Packet {
	reader := ParseHeader(buffer)
	serialnum := base.ReadDWord(reader)
	deviceid := base.ReadQuaWord(reader)
	endpoint, _ := reader.ReadByte()
	shortaddr := base.ReadWord(reader)
	profileid := base.ReadWord(reader)
	zclversion, _ := reader.ReadByte()
	applicationversion, _ := reader.ReadByte()
	stackversion, _ := reader.ReadByte()
	hwversion, _ := reader.ReadByte()
	manufacturernamelen, _ := reader.ReadByte()
	manufacturername := base.ReadString(reader, manufacturernamelen)
	modelidentifierlen, _ := reader.ReadByte()
	modelidentifier := base.ReadString(reader, modelidentifierlen)
	datecodelen, _ := reader.ReadByte()
	datecode := base.ReadString(reader, datecodelen)
	powersouce, _ := reader.ReadByte()

	return &Feedback_Query_Attr_Packet{
		GatewayID:          id,
		SerialNum:          serialnum,
		DeviceID:           deviceid,
		Endpoint:           endpoint,
		ShortAddr:          shortaddr,
		ProfileID:          profileid,
		ZclVersion:         zclversion,
		ApplicationVersion: applicationversion,
		StackVersion:       stackversion,
		HwVersion:          hwversion,
		ManufacturerName:   manufacturername,
		ModelIdentifier:    modelidentifier,
		DateCode:           datecode,
		PowerSource:        powersouce,
	}
}
コード例 #3
0
func Parse_Feedback_SetName(buffer []byte, id uint64) *Feedback_SetName_Packet {
	reader := ParseHeader(buffer)
	serialnum := base.ReadDWord(reader)
	deviceid := base.ReadQuaWord(reader)
	result, _ := reader.ReadByte()
	devicename_length, _ := reader.ReadByte()
	devicename := base.ReadString(reader, devicename_length)

	return &Feedback_SetName_Packet{
		GatewayID:  id,
		DeviceID:   deviceid,
		SerialNum:  serialnum,
		Result:     result,
		DeviceName: devicename,
	}
}