Skip to content

Commit

Permalink
device property incoming event support
Browse files Browse the repository at this point in the history
  • Loading branch information
bertrandmartel committed Dec 9, 2015
1 parent 3113961 commit 409cb98
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Binary file modified app/libs/bboxiot-lib-debug.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import fr.bmartel.android.dotti.R;
import fr.bouyguestelecom.tv.bboxiot.config.GenericDevice;
import fr.bouyguestelecom.tv.bboxiot.config.Protocols;
import fr.bouyguestelecom.tv.bboxiot.config.SupportedDevices;
import fr.bouyguestelecom.tv.bboxiot.datamodel.SmartProperty;
import fr.bouyguestelecom.tv.bboxiot.datamodel.enums.Functions;
import fr.bouyguestelecom.tv.bboxiot.datamodel.enums.Properties;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.BluetoothSmartDevice;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtConnection;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.ConnectionMode;
Expand Down Expand Up @@ -51,8 +55,8 @@ protected void setUp() throws Exception {
BluetoothSmartDevice smartDevice1 = new BluetoothSmartDevice(address, deviceUid, deviceName, manufacturerData, time, genericDevice1, ConnectionMode.MODE_NONE);
BluetoothSmartDevice smartDevice2 = new BluetoothSmartDevice(address, deviceUid, deviceName, manufacturerData, time, genericDevice2, ConnectionMode.MODE_NONE);

connection1 = new BtConnection(smartDevice1.getDeviceUuid(), false, false, false, smartDevice1, new ArrayList<SmartFunction>());
connection2 = new BtConnection(smartDevice2.getDeviceUuid(), false, false, false, smartDevice2, new ArrayList<SmartFunction>());
connection1 = new BtConnection(smartDevice1.getDeviceUuid(), false, false, false, smartDevice1, new HashMap<Functions, HashMap<Properties, SmartProperty>>());
connection2 = new BtConnection(smartDevice2.getDeviceUuid(), false, false, false, smartDevice2, new HashMap<Functions, HashMap<Properties, SmartProperty>>());

btDeviceList.add(connection1);
btDeviceList.add(connection2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.events.impl.ConnectionEvent;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.events.impl.ScanItemEvent;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.events.impl.ScanStatusChangeEvent;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.events.inter.IPropertyEvent;

/**
* Dotti device management main activity
Expand Down Expand Up @@ -414,6 +415,7 @@ public void run() {
registrationSet.add(EventSubscription.BLUETOOTH_STATE);
registrationSet.add(EventSubscription.SCANNING);
registrationSet.add(EventSubscription.CONNECTION);
registrationSet.add(EventSubscription.PROPERTIES);

bboxIotService.getBluetoothManager().subscribe(EventBuilder.buildSubscription(registrationSet).toJsonString(), new IBluetoothEventListener.Stub() {

Expand Down Expand Up @@ -507,6 +509,33 @@ public void run() {
}
}
});

} else if (genericEvent instanceof IPropertyEvent) {

Log.i(TAG, "received property event");

final IPropertyEvent btEvent = (IPropertyEvent) genericEvent;

System.out.println(btEvent.getProperty().toJson().toString());

System.out.println("updating adapter");

runOnUiThread(new Runnable() {
@Override
public void run() {

if (connectionEventListAdapter.getCount() > 10) {

for (int i = connectionEventListAdapter.getCount() - 1; i >= 10; i--) {
connectionEventListAdapter.getDeviceList().remove(i);
}
}

connectionEventListAdapter.insert(new AssociationEventObj(btEvent.getDeviceUid(), btEvent.getProperty().getFunction().toString() + " " + btEvent.getProperty().getProperty().toString() + " " + btEvent.getProperty().getValue().toString()), 0);
connectionEventListAdapter.notifyDataSetChanged();
}
});

} else if (genericEvent instanceof ConnectionEvent) {

final ConnectionEvent btEvent = (ConnectionEvent) genericEvent;
Expand Down

0 comments on commit 409cb98

Please sign in to comment.