Class BluetoothMessageHandler


  • public class BluetoothMessageHandler
    extends com.microej.layout.sync.MessageHandler
    Implements the server-side logic of the Facer watchface sync, using a bluetooth connection.

    When a Facer client (i.e., the Facer mobile application) will connect to the watch using bluetooth, this class will handle incoming messages and answer accordingly.

    • Constructor Summary

      Constructors 
      Constructor Description
      BluetoothMessageHandler​(com.microej.layout.sync.FileWriter fileWriter, com.microej.layout.sync.SyncListener listener, ej.bluetooth.BluetoothService service)
      Creates a server for handling the messages sent by a remote Facer client.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void sendMessage​(byte[] data)  
      void startListening()
      Starts the server.
      void stopListening()
      Stops the server.
      • Methods inherited from class com.microej.layout.sync.MessageHandler

        cancelSync, handleMessage
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BluetoothMessageHandler

        public BluetoothMessageHandler​(com.microej.layout.sync.FileWriter fileWriter,
                                       com.microej.layout.sync.SyncListener listener,
                                       ej.bluetooth.BluetoothService service)
                                throws ej.bluetooth.util.AttributeNotFoundException
        Creates a server for handling the messages sent by a remote Facer client.

        The specified BluetoothService must provide the characteristics defined in the Facer GATT Service specification.

        Parameters:
        fileWriter - the instance to use for writing the watchface files to the device memory
        listener - the instance to notify on watchface sync events
        service - the bluetooth service
        Throws:
        ej.bluetooth.util.AttributeNotFoundException - if the specified bluetooth service does not provide the mandatory Facer characteristics.
    • Method Detail

      • startListening

        public void startListening()
        Starts the server.

        After calling this method, the server will start listening for write requests from the remote client.

      • stopListening

        public void stopListening()
        Stops the server.

        After calling this method, the server will stop listening for write requests from the remote client.

      • sendMessage

        protected void sendMessage​(byte[] data)
                            throws java.io.IOException
        Specified by:
        sendMessage in class com.microej.layout.sync.MessageHandler
        Throws:
        java.io.IOException