public synchronized static boolean setStoredBatteryBytes(String transmitterId, byte[] data) { UserError.Log.e(TAG, "Store: BatteryRX dbg: " + JoH.bytesToHex(data)); if (transmitterId.length() != 6) return false; if (data.length < 10) return false; Log.wtf(TAG, "Saving battery data: " + new BatteryInfoRxMessage(data).toString()); PersistentStore.setBytes(G5_BATTERY_MARKER + transmitterId, data); PersistentStore.setLong(G5_BATTERY_FROM_MARKER + transmitterId, JoH.tsl()); PersistentStore.setBoolean(G5_BATTERY_WEARABLE_SEND, true); return true; }
public BatteryInfoRxMessage(byte[] packet) { if (packet.length >= 10) { data = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN); if (data.get() == opcode) { status = data.get(); voltagea = getUnsignedShort(data); voltageb = getUnsignedShort(data); resist = getUnsignedShort(data); runtime = getUnsignedByte(data); temperature = data.get(); // not sure if signed or not, but <0c or >127C seems unlikely! } else { UserError.Log.wtf(TAG, "Invalid opcode for BatteryInfoRxMessage"); } } else { UserError.Log.wtf(TAG, "Invalid length for BatteryInfoMessage: " + packet.length); } }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { Log.wtf(TAG, "Exception in getFirmwareDetails: " + e); return null; } }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { Log.wtf(TAG, "Exception in getFirmwareDetails: " + e); return null; } }
public synchronized static boolean setStoredBatteryBytes(String transmitterId, byte[] data) { UserError.Log.e(TAG, "Store: BatteryRX dbg: " + JoH.bytesToHex(data)); if (transmitterId.length() != 6) return false; if (data.length < 10) return false; final BatteryInfoRxMessage batteryInfoRxMessage = new BatteryInfoRxMessage(data); UserError.Log.e(TAG, "Saving battery data: " + batteryInfoRxMessage.toString()); PersistentStore.setBytes(G5_BATTERY_MARKER + transmitterId, data); PersistentStore.setLong(G5_BATTERY_FROM_MARKER + transmitterId, JoH.tsl()); // TODO logic also needs to handle battery replacements of same transmitter id final long old_level = PersistentStore.getLong(G5_BATTERY_LEVEL_MARKER + transmitterId); if ((batteryInfoRxMessage.voltagea < old_level) || (old_level == 0)) { if (batteryInfoRxMessage.voltagea < LOW_BATTERY_WARNING_LEVEL) { if (JoH.pratelimit("g5-low-battery-warning", 40000)) { final boolean loud = !PowerStateReceiver.is_power_connected(); JoH.showNotification("G5 Battery Low", "G5 Transmitter battery has dropped to: " + batteryInfoRxMessage.voltagea + " it may fail soon", null, 770, NotificationChannels.LOW_TRANSMITTER_BATTERY_CHANNEL, loud, loud, null, null, null); } } PersistentStore.setLong(G5_BATTERY_LEVEL_MARKER + transmitterId, batteryInfoRxMessage.voltagea); } return true; }
public BatteryInfoRxMessage(byte[] packet) { if (packet.length >= 10) { data = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN); if (data.get() == opcode) { status = data.get(); voltagea = getUnsignedShort(data); voltageb = getUnsignedShort(data); resist = getUnsignedShort(data); runtime = getUnsignedByte(data); temperature = data.get(); // not sure if signed or not, but <0c or >127C seems unlikely! } else { UserError.Log.wtf(TAG, "Invalid opcode for BatteryInfoRxMessage"); } } else { UserError.Log.wtf(TAG, "Invalid length for BatteryInfoMessage: " + packet.length); } }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { Log.wtf(TAG, "Exception in getFirmwareDetails: " + e); return null; } }
public synchronized static boolean setStoredBatteryBytes(String transmitterId, byte[] data) { UserError.Log.e(TAG, "Store: BatteryRX dbg: " + JoH.bytesToHex(data)); if (transmitterId.length() != 6) return false; if (data.length < 10) return false; final BatteryInfoRxMessage batteryInfoRxMessage = new BatteryInfoRxMessage(data); UserError.Log.e(TAG, "Saving battery data: " + batteryInfoRxMessage.toString()); PersistentStore.setBytes(G5_BATTERY_MARKER + transmitterId, data); PersistentStore.setLong(G5_BATTERY_FROM_MARKER + transmitterId, JoH.tsl()); // TODO logic also needs to handle battery replacements of same transmitter id final long old_level = PersistentStore.getLong(G5_BATTERY_LEVEL_MARKER + transmitterId); if ((batteryInfoRxMessage.voltagea < old_level) || (old_level == 0)) { if (batteryInfoRxMessage.voltagea < LOW_BATTERY_WARNING_LEVEL) { if (JoH.pratelimit("g5-low-battery-warning", 40000)) { final boolean loud = !PowerStateReceiver.is_power_connected(); JoH.showNotification("G5 Battery Low", "G5 Transmitter battery has dropped to: " + batteryInfoRxMessage.voltagea + " it may fail soon", null, 770, NotificationChannels.LOW_TRANSMITTER_BATTERY_CHANNEL, loud, loud, null, null, null); } } PersistentStore.setLong(G5_BATTERY_LEVEL_MARKER + transmitterId, batteryInfoRxMessage.voltagea); } return true; }
public BatteryInfoRxMessage(byte[] packet) { if (packet.length >= 10) { data = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN); if (data.get() == opcode) { status = data.get(); voltagea = getUnsignedShort(data); voltageb = getUnsignedShort(data); resist = getUnsignedShort(data); runtime = getUnsignedByte(data); temperature = data.get(); // not sure if signed or not, but <0c or >127C seems unlikely! } else { UserError.Log.wtf(TAG, "Invalid opcode for BatteryInfoRxMessage"); } } else { UserError.Log.wtf(TAG, "Invalid length for BatteryInfoMessage: " + packet.length); } }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { if (JoH.quietratelimit("bi-exception", 15)) UserError.Log.e(TAG, "Exception in getBatteryDetails: " + e); return null; } }
public synchronized static boolean setStoredBatteryBytes(String transmitterId, byte[] data) { UserError.Log.e(TAG, "Store: BatteryRX dbg: " + JoH.bytesToHex(data)); if (transmitterId.length() != 6) return false; if (data.length < 10) return false; final BatteryInfoRxMessage batteryInfoRxMessage = new BatteryInfoRxMessage(data); UserError.Log.e(TAG, "Saving battery data: " + batteryInfoRxMessage.toString()); PersistentStore.setBytes(G5_BATTERY_MARKER + transmitterId, data); PersistentStore.setLong(G5_BATTERY_FROM_MARKER + transmitterId, JoH.tsl()); // TODO logic also needs to handle battery replacements of same transmitter id final long old_level = PersistentStore.getLong(G5_BATTERY_LEVEL_MARKER + transmitterId); if ((batteryInfoRxMessage.voltagea < old_level) || (old_level == 0)) { if (batteryInfoRxMessage.voltagea < LOW_BATTERY_WARNING_LEVEL) { if (JoH.pratelimit("g5-low-battery-warning", 40000)) { final boolean loud = !PowerStateReceiver.is_power_connected(); JoH.showNotification("G5 Battery Low", "G5 Transmitter battery has dropped to: " + batteryInfoRxMessage.voltagea + " it may fail soon", null, 770, NotificationChannels.LOW_TRANSMITTER_BATTERY_CHANNEL, loud, loud, null, null, null); } } PersistentStore.setLong(G5_BATTERY_LEVEL_MARKER + transmitterId, batteryInfoRxMessage.voltagea); } return true; }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { if (JoH.quietratelimit("bi-exception", 15)) UserError.Log.e(TAG, "Exception in getBatteryDetails: " + e); return null; } }
public synchronized static boolean setStoredBatteryBytes(String transmitterId, byte[] data) { UserError.Log.e(TAG, "Store: BatteryRX dbg: " + JoH.bytesToHex(data)); if (transmitterId.length() != 6) return false; if (data.length < 10) return false; updateBatteryWarningLevel(); final BatteryInfoRxMessage batteryInfoRxMessage = new BatteryInfoRxMessage(data); Log.wtf(TAG, "Saving battery data: " +batteryInfoRxMessage.toString()); PersistentStore.setBytes(G5_BATTERY_MARKER + transmitterId, data); PersistentStore.setLong(G5_BATTERY_FROM_MARKER + transmitterId, JoH.tsl()); // TODO logic also needs to handle battery replacements of same transmitter id final long old_level = PersistentStore.getLong(G5_BATTERY_LEVEL_MARKER + transmitterId); if ((batteryInfoRxMessage.voltagea < old_level) || (old_level == 0)) { if (batteryInfoRxMessage.voltagea < LOW_BATTERY_WARNING_LEVEL) { if (JoH.pratelimit("g5-low-battery-warning", 40000)) { final boolean loud = !PowerStateReceiver.is_power_connected(); JoH.showNotification("G5 Battery Low", "G5 Transmitter battery has dropped to: " + batteryInfoRxMessage.voltagea + " it may fail soon", null, 770, NotificationChannels.LOW_TRANSMITTER_BATTERY_CHANNEL, loud, loud, null, null, null); } } PersistentStore.setLong(G5_BATTERY_LEVEL_MARKER + transmitterId, batteryInfoRxMessage.voltagea); } return true; }
public static BatteryInfoRxMessage getBatteryDetails(String tx_id) { try { return new BatteryInfoRxMessage(PersistentStore.getBytes(G5_BATTERY_MARKER + tx_id)); } catch (Exception e) { if (JoH.quietratelimit("bi-exception", 15)) UserError.Log.e(TAG, "Exception in getBatteryDetails: " + e); return null; } }
public synchronized static boolean setStoredBatteryBytes(String transmitterId, byte[] data) { UserError.Log.e(TAG, "Store: BatteryRX dbg: " + JoH.bytesToHex(data)); if (transmitterId.length() != 6) return false; if (data.length < 10) return false; updateBatteryWarningLevel(); final BatteryInfoRxMessage batteryInfoRxMessage = new BatteryInfoRxMessage(data); Log.wtf(TAG, "Saving battery data: " +batteryInfoRxMessage.toString()); PersistentStore.setBytes(G5_BATTERY_MARKER + transmitterId, data); PersistentStore.setLong(G5_BATTERY_FROM_MARKER + transmitterId, JoH.tsl()); // TODO logic also needs to handle battery replacements of same transmitter id final long old_level = PersistentStore.getLong(G5_BATTERY_LEVEL_MARKER + transmitterId); if ((batteryInfoRxMessage.voltagea < old_level) || (old_level == 0)) { if (batteryInfoRxMessage.voltagea < LOW_BATTERY_WARNING_LEVEL) { if (JoH.pratelimit("g5-low-battery-warning", 40000)) { final boolean loud = !PowerStateReceiver.is_power_connected(); JoH.showNotification("G5 Battery Low", "G5 Transmitter battery has dropped to: " + batteryInfoRxMessage.voltagea + " it may fail soon", null, 770, NotificationChannels.LOW_TRANSMITTER_BATTERY_CHANNEL, loud, loud, null, null, null); } } PersistentStore.setLong(G5_BATTERY_LEVEL_MARKER + transmitterId, batteryInfoRxMessage.voltagea); } return true; }
return new PacketShop(PACKET.VersionRequestRxMessage, new VersionRequestRxMessage(packet)); case BatteryInfoRxMessage.opcode: return new PacketShop(PACKET.BatteryInfoRxMessage, new BatteryInfoRxMessage(packet)); case SessionStartRxMessage.opcode: return new PacketShop(PACKET.SessionStartRxMessage, new SessionStartRxMessage(packet, getTransmitterID()));
return new PacketShop(PACKET.VersionRequestRxMessage, new VersionRequestRxMessage(packet)); case BatteryInfoRxMessage.opcode: return new PacketShop(PACKET.BatteryInfoRxMessage, new BatteryInfoRxMessage(packet)); case SessionStartRxMessage.opcode: return new PacketShop(PACKET.SessionStartRxMessage, new SessionStartRxMessage(packet, getTransmitterID()));
return new PacketShop(PACKET.VersionRequestRxMessage, new VersionRequestRxMessage(packet)); case BatteryInfoRxMessage.opcode: return new PacketShop(PACKET.BatteryInfoRxMessage, new BatteryInfoRxMessage(packet)); case SessionStartRxMessage.opcode: return new PacketShop(PACKET.SessionStartRxMessage, new SessionStartRxMessage(packet, getTransmitterID()));