0

Luminaire app How i should to call the methods of org.allseen.LSF and read the properties?

asked 2016-01-13 09:18:56 -0800

vincenzo_pellegrini gravatar image

I downloaded Luminaire app from play store

Currently I'm developing in java(linux) a client to controll the Luminaire app

The client is capable of displaying information that was announced to it from the Service.

2016-01-13 INFO  DeviceAnnouncementHandler:53 - *******************Contents of Announce Signal*******************
2016-01-13 INFO  DeviceAnnouncementHandler:54 - port  42
2016-01-13 INFO  DeviceAnnouncementHandler:55 - Unique BusName:  :fMaKWw1I.3
2016-01-13 INFO  DeviceAnnouncementHandler:56 - ObjectDescriptions:
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /About
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.About
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /About/DeviceIcon
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.Icon
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /org/allseen/LSF/Lamp
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.allseen.LSF.LampService
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.allseen.LSF.LampParameters
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.allseen.LSF.LampDetails
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.allseen.LSF.LampState
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /Config
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.Config
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /notificationDismisser
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.Notification.Dismisser
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /emergency
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.Notification
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /warning
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.Notification
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /info
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.Notification
2016-01-13 INFO  DeviceAnnouncementHandler:58 -     ObjectPath = /notificationProducer
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.Notification.Producer
2016-01-13 INFO  DeviceAnnouncementHandler:60 -         Interface = org.alljoyn.Notification.Dismisser
2016-01-13 INFO  DeviceAnnouncementHandler:63 - AnnounceData:
2016-01-13 INFO  DeviceAnnouncementHandler:203 -    Key = AppId Value = 000ae0fa-0790-ca04-a000-000000000000
2016-01-13 INFO  DeviceAnnouncementHandler:208 -    Key = DefaultLanguage Value = en
2016-01-13 INFO  DeviceAnnouncementHandler:214 -    Key = DeviceName Value = Luminaire-9CA4A
2016-01-13 INFO  DeviceAnnouncementHandler:220 -    Key = DeviceId Value = 000AE0FA0790CA04A000000000000000
2016-01-13 INFO  DeviceAnnouncementHandler:226 -    Key = AppName Value = Luminaire
2016-01-13 INFO  DeviceAnnouncementHandler:232 -    Key = Manufacturer Value = Qualcomm Connected Experiences
2016-01-13 INFO  DeviceAnnouncementHandler:238 -    Key = ModelNumber Value = 001
2016-01-13 INFO  DeviceAnnouncementHandler:65 - 
2016-01-13 INFO  DeviceAnnouncementHandler:78 - BusAttachment with name :fMaKWw1I.3 is still present joining session.
2016-01-13 INFO  DeviceAnnouncementHandler:128 - Succesfully joined session with: ":fMaKWw1I.3" SessionId: "1572141560"
2016-01-13 INFO  DeviceAnnouncementHandler:136 - --------------Getting org.alljoyn.About.Version property-------------
2016-01-13 INFO  DeviceAnnouncementHandler:138 - version: 1
2016-01-13 INFO  DeviceAnnouncementHandler:147 - --------Calling org.alljoyn.About.GetObjectDescription method--------
2016-01-13 INFO  DeviceAnnouncementHandler:149 - ObjectDescriptions:
2016-01-13 INFO  DeviceAnnouncementHandler:151 -    ObjectPath = /About
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.alljoyn.About
2016-01-13 INFO  DeviceAnnouncementHandler:151 -    ObjectPath = /About/DeviceIcon
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.alljoyn.Icon
2016-01-13 INFO  DeviceAnnouncementHandler:151 -    ObjectPath = /org/allseen/LSF/Lamp
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.allseen.LSF.LampService
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.allseen.LSF.LampParameters
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.allseen.LSF.LampDetails
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.allseen.LSF.LampState
2016-01-13 INFO  DeviceAnnouncementHandler:151 -    ObjectPath = /Config
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.alljoyn.Config
2016-01-13 INFO  DeviceAnnouncementHandler:151 -    ObjectPath = /notificationDismisser
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.alljoyn.Notification.Dismisser
2016-01-13 INFO  DeviceAnnouncementHandler:151 -    ObjectPath = /emergency
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.alljoyn.Notification
2016-01-13 INFO  DeviceAnnouncementHandler:151 -    ObjectPath = /warning
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.alljoyn.Notification
2016-01-13 INFO  DeviceAnnouncementHandler:151 -    ObjectPath = /info
2016-01-13 INFO  DeviceAnnouncementHandler:153 -        Interface = org.alljoyn ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-01-15 07:47:02 -0800

updated 2016-01-15 08:02:32 -0800

Hello,

I have made the same kind of application in Java.

To do this I have implemented the AboutListener interface, I register it on the BusAttachment and when the announced callback is called I create the proxy on LampDetails or LampState.

You also need to generate the different java interfaces for LampDetails, LampState based on the LSF interfaces contract. To do so you can use the generator: https://wiki.allseenalliance.org/devtools/code_generator

To register the AboutListener:

bus = new BusAttachment(BUS_NAME, BusAttachment.RemoteMessage.Receive);

Status status = bus.connect();
if (status != Status.OK) {
    return;
}

bus.registerAboutListener(this);

status = bus.whoImplements(new String[] { "org.allseen.LSF.LampState" });
if (status != Status.OK) {
    return;
}

To create the proxy:

@Override
public void announced(String busName, int version, short port, AboutObjectDescription[] objectDescriptions,
        Map<String, Variant> aboutData) {

SessionOpts sessionOpts = new SessionOpts();
sessionOpts.traffic = SessionOpts.TRAFFIC_MESSAGES;
sessionOpts.isMultipoint = false;
sessionOpts.proximity = SessionOpts.PROXIMITY_ANY;
sessionOpts.transports = SessionOpts.TRANSPORT_ANY;

Mutable.IntegerValue sessionId = new Mutable.IntegerValue();

bus.enableConcurrentCallbacks();

Status status = bus.joinSession(busName, port, sessionId, sessionOpts, new SessionListener());
if (status != Status.OK) {
    return;
}
System.out.println(String.format("BusAttachement.joinSession successful sessionId = %d", sessionId.value));

ProxyBusObject proxyObj = bus.getProxyBusObject(busName, "/org/allseen/LSF/Lamp", sessionId.value, new Class<?>[] {
        LampState.class, LampDetails.class, LampParameters.class, LampService.class });

status = proxyObj.registerPropertiesChangedListener("org.allseen.LSF.LampState", new String[]{"OnOff"}, new LSFPropertyChangedListener());

LampState lampState = proxyObj.getInterface(LampState.class);


lampState.setOnOff(true);

....

Thomas

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2016-01-13 09:18:56 -0800

Seen: 141 times

Last updated: Jan 15 '16