/** * Writes the given XBee packet in the connection interface of this device. * * @param packet XBee packet to be written. * * @throws IOException if an I/O error occurs while writing the XBee packet * in the connection interface. * * @see com.digi.xbee.api.packet.XBeePacket */ private void WritePacket(XBeePacket packet)/*throws IOException */{ logger.DebugFormat(ToString() + "Sending XBee packet: \n{0}", packet.ToPrettyString()); // Write bytes with the required escaping mode. switch (operatingMode) { case OperatingMode.API: default: var buf = packet.GenerateByteArray(); connectionInterface.SerialPort.Write(buf, 0, buf.Length); break; case OperatingMode.API_ESCAPE: var buf2 = packet.GenerateByteArrayEscaped(); connectionInterface.SerialPort.Write(buf2, 0, buf2.Length); break; } }
/** * Returns whether the sent packet is the same than the received one. * * @param sentPacket The packet sent. * @param receivedPacket The packet received. * * @return {@code true} if the sent packet is the same than the received * one, {@code false} otherwise. * * @see com.digi.xbee.api.packet.XBeePacket */ private bool isSamePacket(XBeePacket sentPacket, XBeePacket receivedPacket) { // TODO Should not we implement the {@code equals} method in the XBeePacket?? if (HexUtils.ByteArrayToHexString(sentPacket.GenerateByteArray()).Equals(HexUtils.ByteArrayToHexString(receivedPacket.GenerateByteArray()))) return true; return false; }