Skip to content

Bluetooth Library that simplifies Bluetooth Smart connectivity.

License

Notifications You must be signed in to change notification settings

jlandrum/bluetoothsmart

Repository files navigation

BluetoothSmart

BluetoothSmart is a library that allows a more objective approach to communicating with Bluetooth Smart devices.

Use

In order to begin, a device must be created that extends the SmartDevice object:

@SmartDeviceDef
public class MyDevice extends SmartDevice {
}

In order to filter the device out, the class must also provide an identifier:

@Identifier
public static boolean identify(byte[] data) {
	return Arrays.equals(Arrays.copyOfRange(data, 9, 11), MY_MANUFACTURER_ID);
}

To scan for devices, use the DeviceScanner instance:

DeviceScanner scanner = DeviceScanner.getInstance();
scanner.addDeviceType(MyDevice.class);
if (BluetoothAdapter.getDefaultAdapter.isEnabled())
	scanner.startScan(DeviceScanner.SCAN_MODE_LOW_LATENCY);

SmartDevice objects can now contain specially annotated variables that can infer data from advertisements:

@AdInteger(start=20) private int mBatteryLevel;
@CharDef(service = SERVICE_UUID, id = CHARACTERISTIC_UUID) public Characteristic BATTERY_LEVEL;

JavaDoc will soon be provided as well as some samples to work with common BLE devices.

About

Bluetooth Library that simplifies Bluetooth Smart connectivity.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages