IWDS Service

IWDS services provide a common service component for wearable devices, simplifying application development. These services are managed through a unified framework that requires users to get an instance connected theservice component to use the service, regardless of when the service is started, But also allows multiple clients to access at the same time.

Android IWDS Service

Basic concept

ServiceManagerContext

It is the base class for all IWDS service components, and the user can call the service method as long as it gets an instance object connected service component.

ServiceClient

IWDS system services to access the client, the user to use IWDS system services need to instantiate a ServiceClient client object, specify the need to access the service name and callback interface object, and then connect the service, if succeed, in the callback to get a service Instance can access the service.

ConnectionCallbacks

Connecting IWDS system services need to provide the callback interface (ServiceClient defined), if succeed, get the service instance object to use, disconnect the service instance object after the failure or disconnect.

public static abstract interface ConnectionCallbacks {

        /**
         * connect successfull
         * 
         * @param serviceClient
         *            ServiceClient object
         */
        void onConnected(ServiceClient serviceClient);

        /**
         * disconnect
         * 
         * @param serviceClient
         *            ServiceClient object
         * @param unexpected
         * 
         */
        void onDisconnected(ServiceClient serviceClient, boolean unexpected);

        /**
         * connect failed
         * 
         * @param serviceClient
         *            ServiceClient object
         * @param reason
         *
         */
        void onConnectFailed(ServiceClient serviceClient,
                ConnectFailedReason reason);
    }

How to use

1. First,obtain an ServiceClient object and passing the service component name (service name defined in ServiceManagerContext).

ServiceClient mServiceClient = new ServiceClient(mContext,
                ServiceManagerContext.XXX, mConnectionCallbacks);
mServiceClient.connect();

2. And then connect the success of the callback function to obtain the service instance object, access to the instance can be called after its public interface for device management-related operations.

public void onConnected(ServiceClient serviceClient) {
    mXXXManager = (XXXManager) serviceClient.getServiceManagerContext();

3. If the application quits or does not need to use the service, the connection needs to be released.

mServiceClient.disconnect();
public void onDisconnected(ServiceClient serviceClient, boolean unexpected) {
    m_ mXXXManager = null;
}

iOS IWDS Service

Client Note

1. Services in the use of IWDS you must let AppDelegate inherited from IWDSAppDelegate, and the application:didFinishLaunchingWithOptions: method calls initializeDevices:deviceSubClass: to initialize the equipment information, so in the subsequent development of IWDS related to the normal use of the service function;

2. IWDS services currently used for communication of Bluetooth BLE, to ensure that the application in the background mode can be a normal communication and intelligent wearable devices, so it must turn on the Bluetooth background mode for application (User Bluetooth LE accessory);

3. At present, Iwds.framwork can also support CocoaPods introduced, Just pod 'IwdsSDK', '~> 1.3.0' joined in Podfile.