0

How to define objectLists for AJTC

asked 2014-08-26 00:46:58 -0800

congtam gravatar image

updated 2014-08-26 08:51:03 -0800

Hi everyone,

I'm trying to create an application with multi services for AJTC on Arduino. In fact, I want to create 2 services on Arduino ( one to turn on/off a led, another to blink the led). Since a service is presented by its object and its interface, I have two objects correspondings to two services. I created these objects in a objectLists such as:

static const AJ_Object AppObjects[] = {
{"/org/alljoyn/sample/measure/test1", testInterfaces },
{ NULL }
};

static const AJ_Object AppObjects_2[] = {
{"/org/alljoyn/sample/measure/test2", testInterfaces_2 },
{ NULL }
};

static const AJ_Object ObjectList[]={AppObjects, AppObjects_2};// there is always error

Then I called the method:

 uint8_t i = 3;// bs index has to be more than 2
AJ_RegisterObjectList(ObjectList,i);

But I couldn't arrived, there's always the error on the line ObjectList[]. Or we can define the ObjectsLists like:

static const AJ_Object AppObjects[] = {
{"/org/alljoyn/sample/measure/test1", testInterfaces },
{"/org/alljoyn/sample/measure/test2", testInterfaces_2 },
{ NULL }
};

Then we register it with:

AJ_RegisterObjects(AppObjects, NULL);

I have tried with the second way. For the first Interface(service) it works, but for the second, the command from phone to Arduino is rejected by Arduino. I would like to show the following captured packet: rejected_command.png Does anybody know to declare two objects in AJTC? Could you help me please? Thanks

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-09-03 09:13:53 -0800

alphaemmeo gravatar image

Hi congtam, the sequence (1,0,0) is correct because you used two different path.

For example, looking the definition of AJ_APP_MESSAGE_ID we have:

#define AJ_APP_MESSAGE_ID (p,i,m )

where:

  • p is the index of the object path in AppObjects (in your case you have two choices: "0" for "/org/alljoyn/sample/measure/test1" and 1 for "/org/alljoyn/sample/measure/test2" )
  • i is the interface index for each index path chosen above
  • m is the member index for each index i

I hope I was clear enough

edit flag offensive delete publish link more

Comments

Thank very much for the reply, this is very useful :)

congtam ( 2014-09-05 07:42:49 -0800 )edit

you're welcome.

alphaemmeo ( 2014-09-05 08:08:09 -0800 )edit
0

answered 2014-09-02 00:59:39 -0800

congtam gravatar image

Hi everyone, I have found my problem. For 2 services on AJTC, we use the second method above to declare the objects and the interfaces like:

static const AJ_Object AppObjects[] = {{"/org/alljoyn/sample/measure/test1", testInterfaces },{"/org/alljoy/sample/measure/test2", testInterfaces_2 },{ NULL }};

My problem is that I used the message_ID (0,1,0) for the second service's method, so it is refused. I don't know exact reason, I think that this ID is used by Alljoyn platform. I have changed it to (1,0,0), and it works now. Does anybody know the exact reason? Could you please explain it to me?

Sincerely,

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

Question Tools

Follow
1 follower

Stats

Asked: 2014-08-26 00:46:58 -0800

Seen: 93 times

Last updated: Sep 03 '14