@Test public void isPillOneFive() throws Exception { final AdvertisingDataBuilder builder = new AdvertisingDataBuilder(); builder.add(AdvertisingData.TYPE_MANUFACTURER_SPECIFIC_DATA, Bytes.toString(PillPeripheral.MANUFACTURE_DATA_PILL_ONE_FIVE_PREFIX)); assertTrue(PillPeripheral.isPillOneFive(builder.build())); }
public static boolean isPillOneFive(@Nullable final AdvertisingData advertisingData) { if(advertisingData == null){ return false; } for(final int recordType : advertisingData.copyRecordTypes()){ if(advertisingData.anyRecordMatches(recordType, b -> Bytes.startWith(b, MANUFACTURE_DATA_PILL_ONE_FIVE_PREFIX))){ return true; } } return false; }
PillPeripheral implements Serializable { public static boolean isPillOneFive(@Nullable final AdvertisingData advertisingData) { if(advertisingData == null){ return false; } for(final int recordType : advertisingData.copyRecordTypes()){ if(advertisingData.anyRecordMatches(recordType, b -> Bytes.startWith(b, MANUFACTURE_DATA_PILL_ONE_FIVE_PREFIX))){ return true; } } return false; } }
PillPeripheral implements Serializable { public static boolean isPillOneFive(@Nullable final AdvertisingData advertisingData) { if(advertisingData == null){ return false; } for(final int recordType : advertisingData.copyRecordTypes()){ if(advertisingData.anyRecordMatches(recordType, b -> Bytes.startWith(b, MANUFACTURE_DATA_PILL_ONE_FIVE_PREFIX))){ return true; } } return false; } PillPeripheral(@NonNull final GattPeripheral gattPeripheral); }
PillPeripheral implements Serializable { public static boolean isPillOneFive(@Nullable final AdvertisingData advertisingData) { if(advertisingData == null){ return false; } for(final int recordType : advertisingData.copyRecordTypes()){ if(advertisingData.anyRecordMatches(recordType, b -> Bytes.startWith(b, MANUFACTURE_DATA_PILL_ONE_FIVE_PREFIX))){ return true; } } return false; } PillPeripheral(@NonNull final GattPeripheral gattPeripheral); static boolean isPillDfu(@Nullable final AdvertisingData advertisingData); static boolean isPillNormal(@Nullable final AdvertisingData advertisingData); static boolean isPillOneFive(@Nullable final AdvertisingData advertisingData); @Nullable static PillPeripheral getClosestByRssi(@NonNull final List<GattPeripheral> peripherals); Observable<PillPeripheral> clearCache(@NonNull final Context context); int getScanTimeRssi(); String getAddress(); String getName(); boolean isTooFar(); boolean isConnected(); @NonNull Observable<PillPeripheral> enterDfuMode(@NonNull final Context context, @NonNull final DfuCallback callback); Observable<PillPeripheral> disconnect(); @NonNull Observable<PillPeripheral> connect(); @NonNull Observable<PillPeripheral> removeBond(); Observable<PillPeripheral> wipeFirmware(); }
PillPeripheral implements Serializable { public static boolean isPillOneFive(@Nullable final AdvertisingData advertisingData) { if(advertisingData == null){ return false; } for(final int recordType : advertisingData.copyRecordTypes()){ if(advertisingData.anyRecordMatches(recordType, b -> Bytes.startWith(b, MANUFACTURE_DATA_PILL_ONE_FIVE_PREFIX))){ return true; } } return false; } PillPeripheral(@NonNull final GattPeripheral gattPeripheral); static boolean isPillDfu(@Nullable final AdvertisingData advertisingData); static boolean isPillNormal(@Nullable final AdvertisingData advertisingData); static boolean isPillOneFive(@Nullable final AdvertisingData advertisingData); @Nullable static PillPeripheral getClosestByRssi(@NonNull final List<GattPeripheral> peripherals); Observable<PillPeripheral> clearCache(@NonNull final Context context); int getScanTimeRssi(); String getAddress(); String getName(); boolean isTooFar(); boolean isConnected(); @NonNull Observable<PillPeripheral> enterDfuMode(@NonNull final Context context, @NonNull final DfuCallback callback); Observable<PillPeripheral> disconnect(); @NonNull Observable<PillPeripheral> connect(); @NonNull Observable<PillPeripheral> removeBond(); Observable<PillPeripheral> wipeFirmware(); static final byte[] NORMAL_ADVERTISEMENT_SERVICE_128_BIT; static final byte[] DFU_ADVERTISEMENT_SERVICE_128_BIT; static final byte[] MANUFACTURE_DATA_PILL_ONE_FIVE_PREFIX; }