List of usage examples for java.nio ByteOrder LITTLE_ENDIAN
ByteOrder LITTLE_ENDIAN
To view the source code for java.nio ByteOrder LITTLE_ENDIAN.
Click Source Link
From source file:org.mycontroller.standalone.provider.mycontroller.structs.McFirmwareRequest.java
public McFirmwareRequest() { try {/* w w w. j a v a2 s . co m*/ this.setByteBuffer( ByteBuffer.wrap(Hex.decodeHex("FFFFFFFFFFFF".toCharArray())).order(ByteOrder.LITTLE_ENDIAN), 0); } catch (DecoderException ex) { _logger.error("Unable to create 'FirmwareConfigResponse' struct", ex); } }
From source file:nl.dobots.bluenet.ble.base.structs.CrownstoneServiceData.java
public CrownstoneServiceData(byte[] bytes) { super();//from w ww . ja v a2 s . c om ByteBuffer bb = ByteBuffer.wrap(bytes); bb.order(ByteOrder.LITTLE_ENDIAN); bb.getShort(); // skip first two bytes (service UUID) bb.mark(); int val = bb.get(); if (val == 1) { setCrownstoneId(bb.getShort()); setCrownstoneStateId(bb.getShort()); setSwitchState((bb.get() & 0xff)); setEventBitmask(bb.get()); setTemperature(bb.get()); setPowerUsage(bb.getInt()); setAccumulatedEnergy(bb.getInt()); setRelayState(BleUtils.isBitSet(getSwitchState(), 7)); setPwm(getSwitchState() & ~(1 << 7)); } else { bb.reset(); setCrownstoneId(bb.getShort()); setCrownstoneStateId(bb.getShort()); setSwitchState((bb.get() & 0xff)); setEventBitmask(bb.get()); setTemperature(bb.get()); bb.get(); // skip reserved // bb.getShort(); // skip reserved setPowerUsage(bb.getInt()); setAccumulatedEnergy(bb.getInt()); setRelayState(BleUtils.isBitSet(getSwitchState(), 7)); setPwm(getSwitchState() & ~(1 << 7)); } }
From source file:org.mycontroller.standalone.mysensors.structs.FirmwareResponse.java
public FirmwareResponse() { try {/*from w w w . j a v a2s .c o m*/ this.setByteBuffer( ByteBuffer.wrap(Hex.decodeHex("FFFFFFFFFFFF".toCharArray())).order(ByteOrder.LITTLE_ENDIAN), 0); } catch (DecoderException ex) { _logger.error("Unable to create 'FirmwareResponse' struct", ex); } }
From source file:ru.jts_dev.common.packets.OutgoingMessageWrapper.java
protected OutgoingMessageWrapper() { buffer = buffer().order(ByteOrder.LITTLE_ENDIAN); headers = new MutableMessageHeaders(null); }
From source file:org.mycontroller.standalone.mysensors.structs.FirmwareConfigResponse.java
public FirmwareConfigResponse() { try {/*w w w. ja v a 2s . co m*/ this.setByteBuffer( ByteBuffer.wrap(Hex.decodeHex("FFFFFFFFFFFFFFFF".toCharArray())).order(ByteOrder.LITTLE_ENDIAN), 0); } catch (DecoderException ex) { _logger.error("Unable to create 'FirmwareConfigResponse' struct", ex); } }
From source file:org.mycontroller.standalone.provider.mycontroller.structs.McFirmwareResponse.java
public McFirmwareResponse() { try {// w w w . j a v a 2s. c o m StringBuilder builder = new StringBuilder("FFFFFFFFFFFFFFFF"); for (int i = 0; i < FirmwareUtils.FIRMWARE_BLOCK_SIZE_BIN; i++) { builder.append("FF"); } this.setByteBuffer( ByteBuffer.wrap(Hex.decodeHex(builder.toString().toCharArray())).order(ByteOrder.LITTLE_ENDIAN), 0); } catch (DecoderException ex) { _logger.error("Unable to create 'FirmwareResponse' struct", ex); } }
From source file:StreamUtility.java
/** * Converts little endian bytes to a int * @param value byte array to read// w w w . j a v a 2s . c om * @return integer value of the byte array */ public static int littleEndianToInt(byte[] value) { return ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getInt(); }
From source file:com.github.cambierr.lorawanpacket.semtech.PullResp.java
public PullResp(byte[] _randoms, ByteBuffer _raw) throws MalformedPacketException { super(_randoms, PacketType.PULL_RESP); _raw.order(ByteOrder.LITTLE_ENDIAN); if (_raw.remaining() < 1) { throw new MalformedPacketException("too short"); }// w w w . j a v a 2 s .c om byte[] json = new byte[_raw.remaining()]; _raw.get(json); JSONObject jo; try { jo = new JSONObject(new String(json)); } catch (JSONException ex) { throw new MalformedPacketException("malformed json"); } txpks = new ArrayList<>(); if (!jo.has("txpk")) { throw new MalformedPacketException("missing json (txpk)"); } if (!jo.get("txpk").getClass().equals(JSONArray.class)) { throw new MalformedPacketException("malformed json (txpk)"); } JSONArray rxpk = jo.getJSONArray("txpk"); for (int i = 0; i < rxpk.length(); i++) { txpks.add(new Txpk(rxpk.getJSONObject(i))); } }
From source file:org.mycontroller.standalone.provider.mycontroller.structs.McFirmwareConfig.java
public McFirmwareConfig() { try {/*from w w w.j a va 2s . c o m*/ this.setByteBuffer( ByteBuffer .wrap(Hex.decodeHex(("FFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF").toCharArray())) .order(ByteOrder.LITTLE_ENDIAN), 0); } catch (DecoderException ex) { _logger.error("Unable to create 'FirmwareResponse' struct", ex); } }
From source file:org.jmangos.sniffer.handler.PKTLogHandler.java
@Override public void init() { final String date = String.format("%X", System.currentTimeMillis()); final ByteBuffer buffer = ByteBuffer.allocate(66); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.put("PKT".getBytes()); buffer.put((byte) 1); buffer.put((byte) 3); buffer.put((byte) 12); buffer.putInt(this.build); buffer.put("xxXX".getBytes()); buffer.put(this.keyReader.getKey()); buffer.putInt((int) (System.currentTimeMillis() / 1000L)); buffer.putInt(0);/*from w w w . j a v a 2 s .c o m*/ buffer.putInt(0); try { this.fous = new DataOutputStream(new FileOutputStream(new File(this.build + "_" + date + ".pkt"))); this.fous.write(buffer.array()); setInit(true); } catch (final FileNotFoundException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); } }