-
Notifications
You must be signed in to change notification settings - Fork 1
Smart Properties
Smart Properties are featuring Bluetooth device characteristics from a higher level.
Description
type | method | description |
---|---|---|
Properties | getProperty() | property enum value |
Functions | getFunction() | device function enum value |
T | getValue() | property generic value |
String | getDeviceUid() | device identifier |
PropertyTypes | getType() | property value type |
EnumSet | getCapabilities() | an enum set of capabilities |
A Smart property can have only value which is generic and list of supported types are describe in PropertyTypes
enum.
Property value types :
name | value | class type |
---|---|---|
INTEGER | 1 | java.lang.Integer |
BOOLEAN | 2 | java.lang.Boolean |
FLOAT | 3 | java.lang.Float |
VOID | 4 | java.lang.Void |
BUTTON_STATE | 7 | fr.bouyguestelecom.tv.bboxiot.datamodel.enums.ButtonState |
This list is flexible and can change according to BboxIoT library versions
Using PULL Api with bboxIotService.getBluetoothManager().pullValue(String request)
:
String pullRequest = EventBuilder.buildPullRequest(smartProperty);
boolean status = bboxIotService.getBluetoothManager().pullValue(pullRequest);
if (status){
// request successfully sent
}
else{
// request failure
}
or
String pullRequest = EventBuilder.buildPullRequest(deviceUuid,function,property);
boolean status = bboxIotService.getBluetoothManager().pullValue(pullRequest);
if (status){
// request successfully sent
}
else{
// request failure
}
You can build pull value JSON request with :
EventBuilder.buildPullRequest(String deviceUuid,Function function,Property property)
EventBuilder.buildPullRequest(SmartProperty smartProperty)
See Property response part to know how to retrieve pull response.
Using PUSH Api with bboxIotService.getBluetoothManager().pushValue(String request)
:
String pushRequest = EventBuilder.buildPushRequest(smartProperty, value);
boolean status = bboxIotService.getBluetoothManager().pushValue(pushRequest);
if (status){
// request successfully sent
}
else{
// request failure
}
or
String pushRequest = EventBuilder.buildPushRequest(deviceUuid,function,property, value);
boolean status = bboxIotService.getBluetoothManager().pushValue(pushRequest);
if (status){
// request successfully sent
}
else{
// request failure
}
You can build push value JSON request with :
EventBuilder.buildPushRequest(String deviceUuid,Function function,Property property,Object value)
EventBuilder.buildPushRequest(SmartProperty smartProperty,Object value)
To receive PUSH or PULL response event or Property incoming event, you have to subscribe to topic EventSubscription.PROPERTIES
with String subscribe(String request, IBluetoothEventListener listener)
.
Arguments are :
String request
This is JSON string request featuring a set of EventSubscription
element. EventSubscription
is an enum which contains all subscription types, a client can registrate to.
IBluetoothEventListener listener
This is a listener whose callback will be called on each event pushed by BboxIoT service
import fr.bouyguestelecom.tv.bboxiot.protocol.bluetooth.IBluetoothEventListener;
import fr.bouyguestelecom.tv.bboxiot.events.EventBuilder;
import fr.bouyguestelecom.tv.bboxiot.events.IGenericEvent;
......
IBboxIotService service = .... ;
......
Set<EventSubscription> subscriptionSet = new HashSet<>();
subscriptionSet.add(EventSubscription.PROPERTIES);
String request = EventBuilder.buildSubscription(subscriptionSet).toJsonString();
String listenerId = bboxIotService.getBluetoothManager().subscribe(request, new IBluetoothEventListener.Stub() {
public void onEventReceived(int type, int topic, String event) {
IGenericEvent genericEvent = IotEvent.parse(event);
if (genericEvent != null) {
if (genericEvent instanceof IPropertyResponseEvent) {
Log.i(TAG, "received property response event");
IPropertyResponseEvent btEvent = (IPropertyResponseEvent) genericEvent;
} else if (genericEvent instanceof IPropertyIncomingEvent) {
Log.i(TAG, "received property incoming event");
IPropertyIncomingEvent btEvent = (IPropertyIncomingEvent) genericEvent;
}
}
}
});
You will notice that we use EventBuilder
class to build subscription JSON event which take a Set of EventSubscription
as input parameter. You can add as much EventSubscription
entries as you want if you want to subscribe to other subscription types.
Event is parsed with IGenericEvent IotEvent.parse(String event)
which will give you an interface you can cast to whichever Event you are interested in.
There are 3 types of property event :
event class name | description |
---|---|
IPropertyIncomingEvent | unexpected event (notification from device) |
IPropertyRequestEvent | request event (PULL/PUSH request event) |
IPropertyResponseEvent | response event (PULL/PUSH response event) |
Client side is interested in :
-
PropertyIncomingEvent
which are modifications of properties caused by notifications or internal scheduled PULL -
PropertyResponseEvent
which are response to client PUSH / PULL response events
These event can be catched with an instanceof
check with IPropertyIncomingEvent
:
if (genericEvent instanceof IPropertyIncomingEvent) {
Log.i(TAG, "received property incoming event");
IPropertyIncomingEvent btEvent = (IPropertyIncomingEvent) genericEvent;
}
IPropertyIncomingEvent
Description
type | method | description |
---|---|---|
SmartProperty | getProperty() | Smart property incoming object |
String | getDeviceUid() | device identifier |
These event can be catched with an instanceof
check with IPropertyResponseEvent
:
if (genericEvent instanceof IPropertyResponseEvent) {
Log.i(TAG, "received property response event");
IPropertyResponseEvent btEvent = (IPropertyResponseEvent) genericEvent;
}
IPropertyResponseEvent
Description
type | method | description |
---|---|---|
SmartProperty | getProperty() | retreive smart property incoming object |
String | getDeviceUid() | device identifier |
ActionStatus | getStatus() | SUCCESS or ERROR status enum |
PropertyEventType | getActionType() | action type (PUSH / PULL / PROPERTY / INCOMING) |
String | getActionId() | this is the event id of the corresponding PUSH / PULL request initiated by client |
In property events, SmartProperty
value member is always refering to the present property value (not the older one)