2

The interface with two return values :

@BusInterface(name = "com.cykj.alljoyn.servicetest.MutipleRVInterface")
public interface MutipleRVInterface {
 //多返回值
 public class Values {
    @Position(0)
    public int startTime;
    @Position(1)
    public int endTime;
   }
 @BusMethod(replySignature = "ii")
 public Values  getTime() throws BusException;
}

A class implements the interface and BusObject and on the AllJoyn Service:

class ServiceTest implements MutipleRVInterface, BusObject {

    @Override
    public Values  getTime() throws BusException {
        Values  t = new Values ();
        t.startTime = 11;
        t.endTime = 22;
        return t;
    }
}

The client uses the service object:

try {
      MutipleRVInterface.Values time = mutipleRVInterface.getTime();
      logResult(time.startTime + "-" + time.endTime);
    } catch (BusException e) {
      LogResult(e.getMessage());
      Log.e(TAG, e.getMessage());
      e.printStackTrace();
      }

When I called the method of MutipleRVInterface,an exception is thrown.

02-20 14:00:17.209 20695-20954/com.cykj.alljoyn.clienttest W/System.err: org.alljoyn.bus.ErrorReplyBusException: org.alljoyn.Bus.ErStatus
02-20 14:00:17.209 20695-20954/com.cykj.alljoyn.clienttest W/System.err:     at org.alljoyn.bus.ProxyBusObject.methodCall(Native Method)
02-20 14:00:17.210 20695-20954/com.cykj.alljoyn.clienttest W/System.err:     at org.alljoyn.bus.ProxyBusObject.access$300(ProxyBusObject.java:35)
02-20 14:00:17.210 20695-20954/com.cykj.alljoyn.clienttest W/System.err:     at org.alljoyn.bus.ProxyBusObject$Handler.invoke(ProxyBusObject.java:264)
02-20 14:00:17.210 20695-20954/com.cykj.alljoyn.clienttest W/System.err:     at $Proxy1.getTime(Native Method)
02-20 14:00:17.210 20695-20954/com.cykj.alljoyn.clienttest W/System.err:     at com.cykj.alljoyn.clienttest.BusMethodTActivity$BusHandler.handleMessage(BusMethodTActivity.java:584)
02-20 14:00:17.210 20695-20954/com.cykj.alljoyn.clienttest W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:110)
02-20 14:00:17.211 20695-20954/com.cykj.alljoyn.clienttest W/System.err:     at android.os.Looper.loop(Looper.java:193)
02-20 14:00:17.211 20695-20954/com.cykj.alljoyn.clienttest W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:61)

How can I solve the problem? where is wrong in the code?

ps:This is an Android Project with using AllJoyn Framework. And I am not very good at English, the question may not be described clear.Try to be understanding.

Wing.L
  • 21
  • 2

1 Answers1

0

You can use user-defined data types in AllJoyn methods.

You need to define both positions and signatures of the custom datatype and use it with 'r' signature which stands for STRUCT.

So in your case the code should be something like;

@BusInterface(name = "com.cykj.alljoyn.servicetest.MutipleRVInterface")
public interface MutipleRVInterface {
 //多返回值
 public class Values {
    @Position(0)
    @Signature("i")
    public int startTime;
    @Position(1)
    @Signature("i")        
    public int endTime;
   }
 @BusMethod(replySignature="r")
 public Values  getTime() throws BusException;
}

| r | STRUCT | User-defined type whose fields are annotated with Positionannotation and Signature

You can find more info about Signatures in https://allseenalliance.org/docs/api/java/org/alljoyn/bus/annotation/Signature.html or just review the org/alljoyn/bus/annotation/Signature.javacode

Aksel Fatih
  • 1,419
  • 18
  • 31
  • It's not useful. When I set replySignature="r", there is a error that the return Status is "BAD_ANNOTATION" when registerBusObject. – Wing.L Feb 22 '17 at 02:45
  • @Wing.L I have edited the signature. You can also check ./alljoyn_java/test/org/alljoyn/bus/AddressBookInterface.java class for further usage. – Aksel Fatih Feb 22 '17 at 07:43