Search in sources :

Example 6 with GBDeviceEventMusicControl

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl in project Gadgetbridge by Freeyourgadget.

the class HuamiSupport method handleMediaButton.

private void handleMediaButton(String MediaAction) {
    if (MediaAction.equals(PREF_DEVICE_ACTION_SELECTION_OFF)) {
        return;
    }
    GBDeviceEventMusicControl deviceEventMusicControl = new GBDeviceEventMusicControl();
    deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.valueOf(MediaAction);
    evaluateGBDeviceEvent(deviceEventMusicControl);
}
Also used : GBDeviceEventMusicControl(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl)

Example 7 with GBDeviceEventMusicControl

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl in project Gadgetbridge by Freeyourgadget.

the class FitProDeviceSupport method handleMediaButton.

public void handleMediaButton(byte command) {
    GBDeviceEventMusicControl deviceEventMusicControl = new GBDeviceEventMusicControl();
    if (command == RX_MEDIA_PLAY_PAUSE) {
        deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.PLAYPAUSE;
        evaluateGBDeviceEvent(deviceEventMusicControl);
    } else if (command == RX_MEDIA_FORW) {
        deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.NEXT;
        evaluateGBDeviceEvent(deviceEventMusicControl);
    } else if (command == RX_MEDIA_BACK) {
        deviceEventMusicControl.event = GBDeviceEventMusicControl.Event.PREVIOUS;
        evaluateGBDeviceEvent(deviceEventMusicControl);
    }
}
Also used : GBDeviceEventMusicControl(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl)

Example 8 with GBDeviceEventMusicControl

use of nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl in project Gadgetbridge by Freeyourgadget.

the class CasioGB6900DeviceSupport method onCharacteristicWriteRequest.

@Override
public boolean onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
    GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl();
    if (!characteristic.getUuid().equals(CasioConstants.KEY_CONTAINER_CHARACTERISTIC_UUID)) {
        LOG.warn("unexpected write request");
        return false;
    }
    if ((value[0] & 0x03) == 0) {
        int button = value[1] & 0x0f;
        LOG.info("Button pressed: " + button);
        switch(getModel()) {
            case MODEL_CASIO_5600B:
                musicCmd.event = parse2Button(button);
                break;
            case MODEL_CASIO_6900B:
            case MODEL_CASIO_GENERIC:
                musicCmd.event = parse3Button(button);
                break;
            case MODEL_CASIO_STB1000:
                musicCmd.event = parse5Button(button);
                break;
            default:
                LOG.warn("Unhandled device");
                return false;
        }
        evaluateGBDeviceEvent(musicCmd);
    } else {
        LOG.info("received from device: " + value.toString());
    }
    return true;
}
Also used : GBDeviceEventMusicControl(nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl)

Aggregations

GBDeviceEventMusicControl (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl)8 GBDeviceEventCallControl (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl)3 UUID (java.util.UUID)2 Pair (android.util.Pair)1 ByteBuffer (java.nio.ByteBuffer)1 GBDeviceEvent (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent)1 GBDeviceEventAppInfo (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo)1 GBDeviceEventAppManagement (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagement)1 GBDeviceEventAppMessage (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppMessage)1 GBDeviceEventSendBytes (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes)1 GBDeviceEventVersionInfo (nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo)1 GBDeviceApp (nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp)1 TransactionBuilder (nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)1 MusicControlRequest (nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.music.MusicControlRequest)1 MUSIC_WATCH_REQUEST (nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.music.MusicControlRequest.MUSIC_WATCH_REQUEST)1 GBPrefs (nodomain.freeyourgadget.gadgetbridge.util.GBPrefs)1 Prefs (nodomain.freeyourgadget.gadgetbridge.util.Prefs)1 JSONException (org.json.JSONException)1