1

I'm trying to get device discovery work using AllJoyn on Android. Following the sample apps, I'm able to get callbacks for foundAdvertisedName and able to join the session. But when calling any methods on the proxyBusObject it thorws BusBlocked Exception. BusSignals work correctly though using SignalEmitter.

mBus = new BusAttachment(context.getPackageName(), BusAttachment.RemoteMessage.Receive);
mBus.enableConcurrentCallbacks();
status = mBus.connect();
if (Status.OK != status) {
    return;
} else {
    busAttachmentState = BusAttachmentState.CONNECTED;
}

mBus.registerBusListener(new BusListener() {
@Override
public void foundAdvertisedName(String name,
   short transport,
   String namePrefix) {
      mBus.enableConcurrentCallbacks();
      short contactPort = CONTACT_PORT;
      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();

      Status status = mBus.joinSession(name,
contactPort,
sessionId,
sessionOpts,
new SessionListener());

   mProxyObj = mBus.getProxyBusObject("com.my.well.known.name",
      "/MyService",
         sessionId.value,
            new Class[] { SampleInterface.class });
   mSampleInterface = mProxyObj.getInterface(SampleInterface.class);
   mSampleInterface.Test(); // BusMethod call throws exception every time
});

I've tried calling the busMethod on a separate thread as well but getting the same error. Does anyone know what could be wrong here?

UPDATE: Edited code to add BusAttachment creation snippet.

Gunjan
  • 1,177
  • 2
  • 11
  • 22

0 Answers0