// UnmarshalBinary unmarshals a raw byte slice into a NII.
//
// If the byte slice is not exactly 3 bytes in length, io.ErrUnexpectedEOF
// is returned.
327240
func (n *NII) UnmarshalBinary(b []byte) error {
	// Length must be exactly 3
	if len(b) != 3 {
		return io.ErrUnexpectedEOF
	}

	n.Type = b[0]
	n.Major = b[1]
	n.Minor = b[2]

	return nil
}
30064
func (p *DeviceModeIndPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}

	p.Class = DeviceModeClass(data[0])

	return nil
}
684354
func (s *Series4h) UnmarshalBinary(b []byte) error {
	buf := bytes.NewReader(b)
	em := &errMarshal{r: buf}
	em.read(&s.T0)
	em.read(&s.leading)
	em.read(&s.t)
	em.read(&s.tDelta)
	em.read(&s.trailing)
	em.read(&s.val)
	outBuf := make([]byte, buf.Len())
	em.read(outBuf)
	err := s.bw.UnmarshalBinary(outBuf)
	if err != nil {
		return err
	}
	if em.err != nil {
		return em.err
	}
	return nil
}
172963
func (f *FileNameV3) UnmarshalBinary(data []byte) error {
	buf := bytes.NewBuffer(data)

	fields := []interface{}{
		&f.Length, &f.Flags, &f.CaseType, &f.ID,
	}

	for _, p := range fields {
		if err := binary.Read(buf, binary.LittleEndian, p); err != nil {
			return err
		}
	}

	f.Name = string(buf.Next(int(f.Length)))

	return nil
}
301669
func (d *Data) UnmarshalBinary(p []byte) error {
	b := buffer.New(p)
	return d.Unmarshal(b)
}
479269
func (meta *Meta) UnmarshalBinary(data []byte) error {
	return meta.ReadBinary(bytes.NewReader(data))
}
357204
func (i *IPs) UnmarshalBinary(p []byte) error {
	b := uio.NewBigEndianBuffer(p)

	*i = make([]net.IP, 0, b.Len()/net.IPv4len)
	for b.Has(net.IPv4len) {
		*i = append(*i, net.IP(b.CopyN(net.IPv4len)))
	}
	return b.FinError()
}
325760
func (u *URL) UnmarshalBinary(b []byte) error {
	uu, err := url.Parse(string(b))
	if err != nil {
		return err
	}

	*u = URL(*uu)
	return nil
}
826937
func (p *NewChannelAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}
	p.ChannelFrequencyOK = data[0]&(1<<0) > 0
	p.DataRateRangeOK = data[0]&(1<<1) > 0
	return nil
}
158771
func (v *Version) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}
	v.Minor = data[0]
	return nil
}
955201
func (p *ResetConfPayload) UnmarshalBinary(data []byte) error {
	return p.ServLoRaWANVersion.UnmarshalBinary(data)
}
707542
func (a *App) UnmarshalBinary(b []byte) error {
	return json.Unmarshal(b, a)
}
224753
func (l *mvccLock) UnmarshalBinary(data []byte) error {
	var mh marshalHelper
	buf := bytes.NewBuffer(data)
	mh.ReadNumber(buf, &l.startTS)
	mh.ReadSlice(buf, &l.primary)
	mh.ReadSlice(buf, &l.value)
	mh.ReadNumber(buf, &l.op)
	mh.ReadNumber(buf, &l.ttl)
	return errors.Trace(mh.err)
}
1297809
func (p *NewChannelReqPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 5 {
		return errors.New("lorawan: 5 bytes of data are expected")
	}
	p.ChIndex = data[0]
	p.MinDR = data[4] & ((1 << 3) ^ (1 << 2) ^ (1 << 1) ^ (1 << 0))
	p.MaxDR = (data[4] & ((1 << 7) ^ (1 << 6) ^ (1 << 5) ^ (1 << 4))) >> 4

	b := make([]byte, len(data))
	copy(b, data)
	b[4] = byte(0)
	p.Freq = binary.LittleEndian.Uint32(b[1:5]) * 100
	return nil
}
170283
func (s *SubnetMask) UnmarshalBinary(p []byte) error {
	buf := uio.NewBigEndianBuffer(p)
	*s = buf.CopyN(net.IPv4len)
	return buf.FinError()
}
1257548
func (p *PingSlotChannelAnsPayload) UnmarshalBinary(data []byte) error {
	if len(data) != 1 {
		return errors.New("lorawan: 1 byte of data is expected")
	}

	p.ChannelFrequencyOK = data[0]&(1<<0) != 0
	p.DataRateOK = data[0]&(1<<1) != 0

	return nil
}
668152
func (u *Uint32) UnmarshalBinary(p []byte) error {
	b := uio.NewBigEndianBuffer(p)
	*u = Uint32(b.Read32())
	return b.FinError()
}