Class 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" status
      void setNotifier​(datahop.BleAdvNotifier notifier)
      Set the notifier that receives the events advertised when creating or destroying the group or when receiving users connections
      void start​(java.lang.String serviceid)
      This method configures AdvertiseSettings, starts advertising via BluetoothLeAdvertiser and starts the GATT server
      void stop()
      This method stops the advertising service
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface datahop.BleAdvertisingDriver

        notifyEmptyValue, notifyNetworkInformation
    • 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 interface datahop.BleAdvertisingDriver
        Specified by:
        start in interface datahop.BleDiscoveryDriver
        Parameters:
        serviceid - service id
      • stop

        public void stop()
        This method stops the advertising service
        Specified by:
        stop in interface datahop.BleAdvertisingDriver
        Specified by:
        stop in interface datahop.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 interface datahop.BleAdvertisingDriver
        Specified by:
        addAdvertisingInfo in interface datahop.BleDiscoveryDriver
        Parameters:
        topic - topic id
        info - 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 - SSID
        password -
        info - other network information
      • notifyEmptyValue

        public void notifyEmptyValue()
        This method can be used to notify no different "topic" status is detected.