Android Open Source - BleAdapter Event Logger






From Project

Back to project page BleAdapter.

License

The source code is released under:

Apache License

If you think the Android project BleAdapter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.indy.labs.android.BleEventAdapter;
//from  w  ww .j  av a2 s .com

import android.bluetooth.BluetoothGattService;
import android.util.Log;
import com.indy.labs.android.BleEventAdapter.events.*;
import com.squareup.otto.Subscribe;

import java.util.List;

public class EventLogger {

    private static final String TAG = "BLE_EVENT_BUS";
    private final BleEventBus mBleEventBus;

    public EventLogger() {
        mBleEventBus = BleEventBus.getInstance();
        mBleEventBus.register(this);
    }

    @Subscribe
    public void logDeviceDiscovered(DiscoveredDevicesEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void logScanningEvent(ScanningEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(CharacteristicChangedEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(CharacteristicReadEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(CharacteristicWriteEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(DescriptorReadEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(DescriptorWriteEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(GattConnectionStateChangedEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(ReadRemoteRssiEvent event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(ReliableWriteCompleted event) {
        Log.i(TAG, event.toString());
    }

    @Subscribe
    public void log(ServiceDiscoveredEvent event) {
        Log.i(TAG, event.toString());
        List<BluetoothGattService> services = event.getmGatt().getServices();
        for(BluetoothGattService service : services)
        {
            Log.i(TAG, service.getClass().getSimpleName() + " : "
                    + service.getUuid().toString() + " "
                    + service.getCharacteristics().size() + " Characteristics" + " "
                    + service.getIncludedServices().size() + " Included Services");
        }
    }

    @Subscribe
    public void log(DiscoveryServiceEvent event) {
        Log.i(TAG, event.toString());
    }
}




Java Source Code List

com.indy.labs.android.BleEventAdapter.BleEventAdapter.java
com.indy.labs.android.BleEventAdapter.BleEventBus.java
com.indy.labs.android.BleEventAdapter.EventLogger.java
com.indy.labs.android.BleEventAdapter.events.CharacteristicChangedEvent.java
com.indy.labs.android.BleEventAdapter.events.CharacteristicReadEvent.java
com.indy.labs.android.BleEventAdapter.events.CharacteristicWriteEvent.java
com.indy.labs.android.BleEventAdapter.events.DescriptorReadEvent.java
com.indy.labs.android.BleEventAdapter.events.DescriptorWriteEvent.java
com.indy.labs.android.BleEventAdapter.events.DiscoveredDevicesEvent.java
com.indy.labs.android.BleEventAdapter.events.DiscoveryServiceEvent.java
com.indy.labs.android.BleEventAdapter.events.GattConnectionStateChangedEvent.java
com.indy.labs.android.BleEventAdapter.events.ReadRemoteRssiEvent.java
com.indy.labs.android.BleEventAdapter.events.ReliableWriteCompleted.java
com.indy.labs.android.BleEventAdapter.events.ScanningEvent.java
com.indy.labs.android.BleEventAdapter.events.ServiceDiscoveredEvent.java
com.indy.labs.android.BleEventAdapter.service.discovery.device.DeviceDiscoveryService.java
com.indy.labs.android.BleEventAdapter.service.gatt.GattConnectionState.java
com.indy.labs.android.BleEventAdapter.service.gatt.GattService.java