Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MGasztold committed May 6, 2017
1 parent ed47dfa commit 3c124bf
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Android-IoT-SDK

This SDK is dedicated for handling discovery, connection and 2 way communication with the `ub_ble_scanner` dongle.
SDK also provides tools for BLE advertising and making mobile device act like a connectable `ub_ble_scanner` device.
This SDK is dedicated for handling discovery, connection and two way communication with the `ub_ble_scanner` dongle.
SDK also provides API to make mobile device act like a connectable `ub_ble_scanner` device.

## Installing

Expand Down Expand Up @@ -114,41 +114,9 @@ Then the `send(byte[] data)` can be called:
byte[] data = message.getBytes();
mDongle.send(data);

### Bluetooth LE advertising

Setup advertiser:

Advertiser advertiser = new Advertiser(mContext);
advertiser.setListener(new Advertiser.AdvertisingListener() {
@Override
public void onAdvertisingStarted() {
// advertising started
}

@Override
public void onAdvertisingStopped() {
// advertising started
}

@Override
public void onAdvertisingError(Error error) {
// advertising error
}
});

Start advertising as IBeacon:

advertiser.advertise(IBeacon.getAdvertiseBytes("67D37FC1-BE36-4EF5-A24D-D0ECD8119A7D", "12", "312", -55),true);

The boolean argument determines whether the device should be connectable or not.

Stop advertising:

advertiser.stopAdvertising();

### Make mobile device act as a connectable dongle

To make that happen the following code should be called before starting to advertise:
To make that happen the following code should be called to setup the `BluetoothGattServer`:

peripheralManager = new PeripheralManager(getApplicationContext(), new DeviceProfile() {

Expand Down Expand Up @@ -204,3 +172,35 @@ To make that happen the following code should be called before starting to adver
To stop the device from being a connectable peripheral:

peripheralManager.closeGattServer();

After `BluetoothGattServer` is active the mobile device must start advertising some Bluetooth LE packets to start being discoverable by other devices nearby.
Setting up the advertiser is as follows:

Advertiser advertiser = new Advertiser(mContext);
advertiser.setListener(new Advertiser.AdvertisingListener() {
@Override
public void onAdvertisingStarted() {
// advertising started
}

@Override
public void onAdvertisingStopped() {
// advertising started
}

@Override
public void onAdvertisingError(Error error) {
// advertising error
}
});

Start advertising as IBeacon:

advertiser.advertise(IBeacon.getAdvertiseBytes("67D37FC1-BE36-4EF5-A24D-D0ECD8119A7D", "12", "312", -55),true);

- the end `boolean` argument determines whether the mobile device is connectable or not. `true` must be set to allow devices nearby to connect,
- in the example above the advertisement is an IBeacon advertisement but the `advertise` method takes any byte array data (this SDK already provides the static method `IBeacon.getAdvertiseBytes`).

To stop advertising at any time call the following:

advertiser.stopAdvertising();

0 comments on commit 3c124bf

Please sign in to comment.