LBLECentral

Singleton objects that represents a BLE central device.

This class allows LinkIt 7697 to act as a BLE central device. It can scan nearby BLE peripherals, checking if they are beacons or devices that provides GATT services.

This class does not provide functions to connect to remote peripheral devices. Use LBLEClient class instead to connect to a remote device and read/write its characteristics.

To use this object, call scan() first and check if there's any peripherals nearby with getPeripheralCount, and then use APIs such as getName and getAddress:

// start scanning
LBLECentral.scan();
// wait for 5 seconds to scan
for(int i = 0; i < 5; ++i)
{
  delay(1000);
  Serial.print(".");
}
// list name of the peripherals found.
const int found = LBLECentral.getPeripheralCount();
for (int i = 0; i < found; ++i) {
    Serial.println(LBLECentral.getName(i));
}

Scan Methods

scan()

stopScan()

getPeripheralCount ()

Start scanning nearby BLE peripherals. This puts the system into a scanning state. The system keeps updating the peripheral list in the background.

The result of getPeripheralCount() will be updated once a new peripheral is found.

Note that it may took sometime for peripherals to get scanned.

To get the scanned peripheral, call getPeripheralCount() and use methods such as getPeripheralName or isBeacon with index as input.

Syntax

Parameters

n/a

Returns

n/a

Methods for Scanned Device Information

After a peripheral is found, you can use the index to query information on the scanned device. Note that due to the design of BLE advertisement packets, not all devices broadcast the same information, so the query result can be empty.

getAddress()

getBLEAddress()

getManufacturer()

getName()

getRSSI()

getTxPower()

getServiceUuid()

getIBeaconInfo()

Get scanned peripheral information by index.

Get address of the peripheral in the list of scanned devices.

Syntax

Parameters

index ranges from 0 to (getRemotePeripheralCount() - 1). The same index represents the same device.

Returns

Device address (in string format) of the scanned peripheral.

Get scanned RSSI of the peripheral in the list of scanned devices.

Syntax

Parameters

index ranges from 0 to (getRemotePeripheralCount() - 1). The same index represents the same device.

Returns

RSSI value in dbm.

Last updated