Skip to content

Commit

Permalink
rename BtAssociatedItem class to BtAssociatedDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
bertrandmartel committed Mar 9, 2016
1 parent 7bbd7da commit 5de66ec
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 42 deletions.
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,9 @@ Specific features are :
## Including in your project

```
compile 'bboxlab:bboxiot-library:0.75'
compile 'bboxlab:bboxiot-library:0.76'
```

## Version History

Current release : <a href="https://github.com/BboxLab/bboxiot-library/releases/tag/0.75">version 0.75</a>

| version | comment |
|------------------------------------------------------------------------|----------------------------|
| 0.75 | bugs fix / more verbose JSON protocol / string alias for properties-functions |
| 0.73 | unit support for properties |
| 0.72 | SmarLite / Oblo / Notti devices support |
| 0.71 | fewer API with JSON input for usability |
| 0.7 | API refactoring |
| 0.6 | witti devices support |

## Requirements

To be able to use this library, you must have a Miami Box Android TV with BboxIoT service running
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import fr.bouyguestelecom.tv.bboxiot.events.enums.ScanningAction;
import fr.bouyguestelecom.tv.bboxiot.events.enums.ScanningType;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.BluetoothSmartDevice;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedItem;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedDevice;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.constant.BluetoothConst;
import fr.bouyguestelecom.tv.bboxiot.utils.RandomGen;

Expand All @@ -68,7 +68,7 @@ public class EventBuilder {
* @param connection connection object
* @return
*/
public static GenericEventAbstr buildConnectionItem(BtAssociatedItem connection) {
public static GenericEventAbstr buildConnectionItem(BtAssociatedDevice connection) {

JSONObject data = new JSONObject();

Expand All @@ -89,7 +89,7 @@ public static GenericEventAbstr buildConnectionItem(BtAssociatedItem connection)
* @param connectionList associated item list
* @return
*/
public static GenericEventAbstr buildConnectionList(List<BtAssociatedItem> connectionList) {
public static GenericEventAbstr buildConnectionList(List<BtAssociatedDevice> connectionList) {

JSONObject data = new JSONObject();
JSONArray items = new JSONArray();
Expand Down Expand Up @@ -118,7 +118,7 @@ public static GenericEventAbstr buildConnectionList(List<BtAssociatedItem> conne
* @param connection association item
* @return
*/
public static GenericEventAbstr buildAssociationEvent(ConnectionState state, BtAssociatedItem connection) {
public static GenericEventAbstr buildAssociationEvent(ConnectionState state, BtAssociatedDevice connection) {

JSONObject data = new JSONObject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import fr.bouyguestelecom.tv.bboxiot.events.enums.EventTopic;
import fr.bouyguestelecom.tv.bboxiot.events.enums.EventType;
import fr.bouyguestelecom.tv.bboxiot.events.inter.IAssociationList;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedItem;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedDevice;

/**
* features an association list
Expand All @@ -48,7 +48,7 @@ public class AssociationList extends GenericEventAbstr implements IAssociationLi

private static String TAG = ConnectionEvent.class.getSimpleName();

private Map<String, BtAssociatedItem> connectionList = new HashMap<>();
private Map<String, BtAssociatedDevice> connectionList = new HashMap<>();

private JSONArray connectionItems = new JSONArray();

Expand All @@ -62,7 +62,7 @@ public AssociationList(EventTopic topic, EventType type, String eventId, JSONObj

for (int i = 0; i < connectionItems.length(); i++) {

BtAssociatedItem connection = BtAssociatedItem.parse((JSONObject) connectionItems.get(i));
BtAssociatedDevice connection = BtAssociatedDevice.parse((JSONObject) connectionItems.get(i));

if (connection != null) {
connectionList.put(connection.getDeviceUuid(), connection);
Expand All @@ -79,7 +79,7 @@ public AssociationList(EventTopic topic, EventType type, String eventId, JSONObj
}

@Override
public Map<String, BtAssociatedItem> getList() {
public Map<String, BtAssociatedDevice> getList() {
return connectionList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import fr.bouyguestelecom.tv.bboxiot.events.enums.EventTopic;
import fr.bouyguestelecom.tv.bboxiot.events.enums.EventType;
import fr.bouyguestelecom.tv.bboxiot.events.inter.IAssociationEvent;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedItem;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedDevice;

/**
* Connection event type
Expand All @@ -52,7 +52,7 @@ public class ConnectionEvent extends GenericEventAbstr implements IAssociationEv
*/
private ConnectionState state = ConnectionState.UNDEFINED;

private BtAssociatedItem connection = null;
private BtAssociatedDevice connection = null;

public ConnectionEvent(EventTopic topic, EventType type, String eventId, JSONObject data) {
super(topic, type, eventId, data);
Expand All @@ -64,7 +64,7 @@ public ConnectionEvent(EventTopic topic, EventType type, String eventId, JSONObj
state = ConnectionState.getConnectionStateStr(data.getString(AssociationEventConstant.ASSOCIATION_EVENT_STATE));

if (data.has(AssociationEventConstant.ASSOCIATION_EVENT_CONNECTION))
connection = BtAssociatedItem.parse(data.getJSONObject(AssociationEventConstant.ASSOCIATION_EVENT_CONNECTION));
connection = BtAssociatedDevice.parse(data.getJSONObject(AssociationEventConstant.ASSOCIATION_EVENT_CONNECTION));
} else {
Log.e(TAG, "Error bad format for association event");
}
Expand All @@ -80,7 +80,7 @@ public ConnectionState getState() {
}

@Override
public BtAssociatedItem getConnection() {
public BtAssociatedDevice getConnection() {
return connection;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import fr.bouyguestelecom.tv.bboxiot.events.enums.EventTopic;
import fr.bouyguestelecom.tv.bboxiot.events.enums.EventType;
import fr.bouyguestelecom.tv.bboxiot.events.inter.IConnectionItem;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedItem;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedDevice;

/**
* Connection item
Expand All @@ -47,7 +47,7 @@ public class ConnectionItem extends GenericEventAbstr implements IConnectionItem

private static String TAG = ScanItemEvent.class.getSimpleName();

private BtAssociatedItem btConnection = null;
private BtAssociatedDevice btConnection = null;

public ConnectionItem(EventTopic topic, EventType type, String eventId, JSONObject data) {
super(topic, type, eventId, data);
Expand All @@ -57,7 +57,7 @@ public ConnectionItem(EventTopic topic, EventType type, String eventId, JSONObje

JSONObject connectionJson = data.getJSONObject(AssociationEventConstant.ASSOCIATION_EVENT_CONNECTION);

btConnection = BtAssociatedItem.parse(connectionJson);
btConnection = BtAssociatedDevice.parse(connectionJson);

} else {
Log.e(TAG, "Error in association item event format");
Expand All @@ -68,7 +68,7 @@ public ConnectionItem(EventTopic topic, EventType type, String eventId, JSONObje
}

@Override
public BtAssociatedItem getItem() {
public BtAssociatedDevice getItem() {
return btConnection;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package fr.bouyguestelecom.tv.bboxiot.events.inter;

import fr.bouyguestelecom.tv.bboxiot.events.enums.ConnectionState;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedItem;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedDevice;

/**
* Association event interface
Expand All @@ -45,5 +45,5 @@ public interface IAssociationEvent {
*
* @return
*/
BtAssociatedItem getConnection();
BtAssociatedDevice getConnection();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import java.util.Map;

import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedItem;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedDevice;

/**
* Association list interface
Expand All @@ -41,7 +41,7 @@ public interface IAssociationList {
*
* @return
*/
Map<String, BtAssociatedItem> getList();
Map<String, BtAssociatedDevice> getList();

/**
* retrieve list of associated devices in json array format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import org.json.JSONArray;

import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedItem;
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.connection.BtAssociatedDevice;

/**
* Connection object interface
Expand All @@ -39,7 +39,7 @@ public interface IConnectionItem {
*
* @return
*/
BtAssociatedItem getItem();
BtAssociatedDevice getItem();

/**
* retrieve all function/properties of connection object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*
* @author Bertrand Martel Bouygues Telecom
*/
public class BtAssociatedItem {
public class BtAssociatedDevice {

/**
* Bluetooth devivce object
Expand All @@ -63,7 +63,7 @@ public class BtAssociatedItem {
*/
protected HashMap<Functions, HashMap<Properties, SmartProperty>> deviceFunctions = new HashMap<>();

private static String TAG = BtAssociatedItem.class.getSimpleName();
private static String TAG = BtAssociatedDevice.class.getSimpleName();

/**
* define if device has already been connected before
Expand Down Expand Up @@ -95,7 +95,7 @@ public class BtAssociatedItem {
* @param device bluetooth device object
* @param deviceFunctions map of functions/property for this item
*/
public BtAssociatedItem(String deviceUuid, boolean connected, boolean isFirstConnection, boolean busy, BluetoothSmartDevice device, HashMap<Functions, HashMap<Properties, SmartProperty>> deviceFunctions) {
public BtAssociatedDevice(String deviceUuid, boolean connected, boolean isFirstConnection, boolean busy, BluetoothSmartDevice device, HashMap<Functions, HashMap<Properties, SmartProperty>> deviceFunctions) {
this.deviceUuid = deviceUuid;
this.connected = connected;
this.firstConnection = isFirstConnection;
Expand Down Expand Up @@ -239,7 +239,7 @@ public BluetoothSmartDevice getBtSmartDevice() {
* @param item association item in json format
* @return
*/
public static BtAssociatedItem parse(JSONObject item) {
public static BtAssociatedDevice parse(JSONObject item) {

try {
if (item.has(BluetoothConst.BLUETOOTH_DEVICE_UUID) &&
Expand Down Expand Up @@ -328,10 +328,10 @@ public static BtAssociatedItem parse(JSONObject item) {
return null;
}

return new BtAssociatedItem(deviceUuid, connected, isFirstConnection, busy, smartDevice, smartFunctions);
return new BtAssociatedDevice(deviceUuid, connected, isFirstConnection, busy, smartDevice, smartFunctions);

} else {
Log.e(TAG, "Error wrong formatted BtAssociatedItem json Object");
Log.e(TAG, "Error wrong formatted BtAssociatedDevice json Object");
}
} catch (JSONException e) {
e.printStackTrace();
Expand Down

0 comments on commit 5de66ec

Please sign in to comment.