func (p *Nsq_Query_Attr_Packet) SerializeOnline() []byte {
	var writer bytes.Buffer
	writer.WriteByte(STARTFLAG)
	base.WriteWord(&writer, CMD_QUERY_ATTR_LEN)
	base.WriteWord(&writer, CMD_QUERY_ATTR)
	base.WriteDWord(&writer, p.SerialNum)
	base.WriteQuaWord(&writer, p.DeviceID)
	writer.WriteByte(p.Endpoint)
	writer.WriteByte(CheckSum(writer.Bytes(), uint16(writer.Len())))
	writer.WriteByte(ENDFLAG)

	return writer.Bytes()
}
func (p *Nsq_Identify_Packet) Serialize() []byte {
	var writer bytes.Buffer
	writer.WriteByte(STARTFLAG)
	base.WriteWord(&writer, CMD_IDENTIFY_LEN)
	base.WriteWord(&writer, CMD_IDENTIFY)
	base.WriteDWord(&writer, p.SerialNum)
	base.WriteQuaWord(&writer, p.DeviceID)
	writer.WriteByte(p.Endpoint)
	writer.WriteByte(CheckSum(writer.Bytes(), uint16(writer.Len())))
	writer.WriteByte(ENDFLAG)

	return writer.Bytes()
}
func (p *Nsq_Read_OnOff_Status_Packet) SerializeOnline() []byte {
	var writer bytes.Buffer
	writer.WriteByte(STARTFLAG)
	base.WriteWord(&writer, CMD_READ_ONOFF_STATUS_LEN)
	base.WriteWord(&writer, CMD_READ_ONOFF_STATUS)
	base.WriteDWord(&writer, p.SerialNum)
	base.WriteQuaWord(&writer, p.DeviceID)
	writer.WriteByte(p.Endpoint)
	writer.WriteByte(CheckSum(writer.Bytes(), uint16(writer.Len())))
	writer.WriteByte(ENDFLAG)

	return writer.Bytes()
}
func (p *Nsq_Set_Devcie_Name_Packet) SerializeOnline() []byte {
	fmt.Printf("%+v\n", p)
	var writer bytes.Buffer
	writer.WriteByte(STARTFLAG)
	base.WriteWord(&writer, 0)
	base.WriteWord(&writer, CMD_SET_DEVICE_NAME)
	base.WriteDWord(&writer, p.SerialNum)
	base.WriteQuaWord(&writer, p.DeviceID)
	writer.WriteByte(byte(len(p.Name)))
	writer.WriteString(p.Name)
	base.WriteLength(&writer)
	writer.WriteByte(CheckSum(writer.Bytes(), uint16(writer.Len())))
	writer.WriteByte(ENDFLAG)

	return writer.Bytes()
}
func (p *Nsq_Deployment_Packet) SerializeOnline() []byte {
	var writer bytes.Buffer
	writer.WriteByte(STARTFLAG)
	base.WriteWord(&writer, CMD_DEPLOYMENT_LEN)
	base.WriteWord(&writer, CMD_DEPLOYMENT)
	base.WriteDWord(&writer, p.SerialNum)
	base.WriteQuaWord(&writer, p.DeviceID)
	writer.WriteByte(byte(p.Endpoint))
	writer.WriteByte(byte(p.ArmMode))
	writer.WriteByte(byte(p.ArmStartTimeHour))
	writer.WriteByte(byte(p.ArmStartTimeMin))
	writer.WriteByte(byte(p.ArmEndTImeHour))
	writer.WriteByte(byte(p.ArmEndTImeMin))
	writer.WriteByte(CheckSum(writer.Bytes(), uint16(writer.Len())))
	writer.WriteByte(ENDFLAG)

	return writer.Bytes()
}
func (p *Nsq_Level_Control_Packet) Serialize() []byte {
	var writer bytes.Buffer
	writer.WriteByte(STARTFLAG)
	base.WriteWord(&writer, CMD_LEVEL_CONTROL_LEN)
	base.WriteWord(&writer, CMD_LEVEL_CONTROL)
	base.WriteDWord(&writer, p.SerialNum)
	base.WriteQuaWord(&writer, p.DeviceID)
	writer.WriteByte(byte(p.Endpoint))
	writer.WriteByte(byte(p.CommandID))
	if p.CommandID != CMD_LEVEL_PAUSE {
		writer.WriteByte(byte(p.Level))
		base.WriteWord(&writer, p.TransactionTime)
	}
	writer.WriteByte(CheckSum(writer.Bytes(), uint16(writer.Len())))
	writer.WriteByte(ENDFLAG)

	return writer.Bytes()
}
func (p *Nsq_Warn_Packet) Serialize() []byte {
	var writer bytes.Buffer
	writer.WriteByte(STARTFLAG)
	base.WriteWord(&writer, CMD_WARN_LEN)
	base.WriteWord(&writer, CMD_WARN)
	base.WriteDWord(&writer, p.SerialNum)
	base.WriteQuaWord(&writer, p.DeviceID)
	writer.WriteByte(p.Endpoint)
	base.WriteWord(&writer, p.WarningDuration)
	writer.WriteByte(p.WarningMode)
	writer.WriteByte(p.Strobe)
	writer.WriteByte(p.SirenLevel)
	writer.WriteByte(p.StrobeLevel)
	writer.WriteByte(p.StrobeDutyCycle)
	writer.WriteByte(CheckSum(writer.Bytes(), uint16(writer.Len())))
	writer.WriteByte(ENDFLAG)

	return writer.Bytes()
}