Package network.datahop.blediscovery
Class BLEAdvertising
- java.lang.Object
-
- network.datahop.blediscovery.BLEAdvertising
-
- All Implemented Interfaces:
datahop.BleAdvertisingDriver
,datahop.BleDiscoveryDriver
public class BLEAdvertising extends java.lang.Object implements datahop.BleAdvertisingDriver
BLEAdvertising class is used for service discovery using Bluetooth Low Energy beacons. BLEAdvertising is responsible of advertising service discovery data and exchange service status using GATT server and GATT characteristics. Advertised data for each service is structured in "topics" and each topic is configured as a BLE characteristic in the GATT server. Characteristics are compared in the GATT Server when accepting connections to compare status for each "topic. When detected different values of the "topics" means different service status and it can reply with network information.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdvertisingInfo(java.lang.String topic, byte[] info)
This method adds advertising information value for the specified "topic".static BLEAdvertising
getInstance(android.content.Context appContext)
void
notifyEmptyValue()
This method can be used to notify no different "topic" status is detected.void
notifyNetworkInformation(java.lang.String network, java.lang.String password, java.lang.String info)
This method can be used to notify network information (SSID, password, node info) when detected different "topic" statusvoid
setNotifier(datahop.BleAdvNotifier notifier)
Set the notifier that receives the events advertised when creating or destroying the group or when receiving users connectionsvoid
start(java.lang.String serviceid)
This method configures AdvertiseSettings, starts advertising via BluetoothLeAdvertiser and starts the GATT servervoid
stop()
This method stops the advertising service
-
-
-
Method Detail
-
getInstance
public static BLEAdvertising getInstance(android.content.Context appContext)
-
setNotifier
public void setNotifier(datahop.BleAdvNotifier notifier)
Set the notifier that receives the events advertised when creating or destroying the group or when receiving users connections- Parameters:
notifier
- instance
-
start
public void start(java.lang.String serviceid)
This method configures AdvertiseSettings, starts advertising via BluetoothLeAdvertiser and starts the GATT server- Specified by:
start
in interfacedatahop.BleAdvertisingDriver
- Specified by:
start
in interfacedatahop.BleDiscoveryDriver
- Parameters:
serviceid
- service id
-
stop
public void stop()
This method stops the advertising service- Specified by:
stop
in interfacedatahop.BleAdvertisingDriver
- Specified by:
stop
in interfacedatahop.BleDiscoveryDriver
-
addAdvertisingInfo
public void addAdvertisingInfo(java.lang.String topic, byte[] info)
This method adds advertising information value for the specified "topic". In case "topic" already exists information is updated- Specified by:
addAdvertisingInfo
in interfacedatahop.BleAdvertisingDriver
- Specified by:
addAdvertisingInfo
in interfacedatahop.BleDiscoveryDriver
- Parameters:
topic
- topic idinfo
- value advertised
-
notifyNetworkInformation
public void notifyNetworkInformation(java.lang.String network, java.lang.String password, java.lang.String info)
This method can be used to notify network information (SSID, password, node info) when detected different "topic" status- Parameters:
network
- SSIDpassword
-info
- other network information
-
notifyEmptyValue
public void notifyEmptyValue()
This method can be used to notify no different "topic" status is detected.
-
-