Class IntPacket


  • public class IntPacket
    extends Object
    Interface for the RN131 driver to send and receive integer values.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  IntPacket.Type  
    • Constructor Summary

      Constructors 
      Constructor Description
      IntPacket​(SLIP slip)
      Creates a IntPacket object on top of the SLIP interface.
    • Constructor Detail

      • IntPacket

        public IntPacket​(SLIP slip)
        Creates a IntPacket object on top of the SLIP interface.
        Parameters:
        slip - slip interface to use
    • Method Detail

      • writeInt

        public boolean writeInt​(int val)
        Writes an integer with the default header to the send buffer.
        Parameters:
        val - integer to send
        Returns:
        false if buffer is full, true otherwise
      • writeInt

        public boolean writeInt​(IntPacket.Type type,
                                int val)
        Writes an integer of the specified type to the send buffer.
        Parameters:
        type - type of the integer
        val - integer to send
        Returns:
        false if buffer is full, true otherwise
      • writeInt

        public boolean writeInt​(byte header,
                                int val)
        Writes an integer with a specified header to the send buffer.
        Parameters:
        header - header of the integer
        val - integer to send
        Returns:
        false if buffer is full, true otherwise
      • readInt

        public IntPacket.Type readInt()
        Reads an integer from the receive buffer. The value of the integer can be retrieved with the getCmd method. The value of the header can be retrieved with the getHeader method.
        Returns:
        Type.Int or Type.None if data was received. Type.Illegal if a corrupted packet was received and Type.None if buffer is empty.
      • getHeader

        public byte getHeader()
        Returns the header of the last received integer.
        Returns:
        header of the last received integer
      • getInt

        public int getInt()
        Returns the last received integer.
        Returns:
        last received integer