AJTCL (Arduino) to AJSCL (Android)

asked 2014-07-24 08:20:29 -0700

AllJoyner gravatar image

Hi everyone, I made a simple Android app and modified a AJ_LEDService program so I was able to send signals from the phone to Arduino. Now I am trying to send input signals from Arduino back to the phone and I am kind of stuck there. I have written an Arduino sketch for it using, digitalRead(inPin) function but I am a bit stuck on AllJoyn part. Could somebody let me know how to go about this, or even better provide a simple example.

Also, I am a bit confused about AJ_APP_MESSAGE_ID, what if i want to have two message identifiers for the same method? For example: #define APP1 AJ_APP_MESSAGE_ID(0,0,1) #define APP2 AJ_APP_MESSAGE_ID(0,0,1) ....... it gives me a "duplicate case error".

Thanks in advance! Regards.

edit retag flag offensive close merge delete


I'm trying to do control the Arduino led from Android. Is your project available? (al least the alljoyn code snippets). Best

germanviscuso ( 2014-11-08 10:25:37 -0700 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-07-24 12:39:39 -0700

cpezzee gravatar image

I'll try to answer the second part of your question first. Essentially, message identifiers are used to uniquely map an entry in an interface to executable code on the receiver. There should not be duplicate message identifers, because there is a one-to-one mapping between interface entries and message identifiers.

If you want to call the same code for two different methods, that is possible. For example: suppose you had an interface "org.whizbang.stringfunctions" that has two members "concat" and "append". They could call the same underlying code, but they are two distinct methods on an interface, and would need two different message identifiers: APP_STRING_CONCATINATE and APP_STRING_APPEND.
Then the message handling case statements would call the same underlying strncat function.

Discussing the first part of your question (reading the state of the hardware and notifying someone/something) has a number of parts to it, and each answer can alter how you approach a solution.

  • Q1: how much latency can you tolerate between your hardware event happening and AllJoyn messages being sent? There can be latencies in sending messages due to the single-task nature of the AllJoyn Thin Client Library code.
  • Q2: Is your hardware event edge-triggered or level-triggered? (If the hardware event cannot be processed at the moment, is it okay to miss it, or must it be processed always?)
  • Q3: What is the frequency of the hardware event?
  • Q4: Do you want a message set for every hardware event?
edit flag offensive delete publish link more


Hey Cpezzee, thank you for the answer. Now to answer your questions: As of now, none of it really matters that much because I am just doing experiments, I just need the simplest solution to pass input from arduino to the phone...such as temperature readings, infra-red etc

AllJoyner ( 2014-07-25 08:16:40 -0700 )edit

static AJ_Status AppHandleState(AJ_Message* msg){ AJ_Message reply; if digitalRead(input) == HIGH display "ON" on the phone if digitalRead(input) == LOW display "OFF" on the phone AJ_MarshalReplyMsg(msg, &reply); return AJ_DeliverMsg(&reply);}

AllJoyner ( 2014-07-25 08:19:46 -0700 )edit

Something simple as that above, I am just not sure which functions I use to send input back to the phone. Are AJ_MarshalReplyMsg(msg, &reply) and AJ_DeliverMsg(&reply) supposed to do that, and would i store input in "reply" variable in this case? Thanks

AllJoyner ( 2014-07-25 08:22:30 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2014-07-24 08:20:29 -0700

Seen: 294 times

Last updated: Jul 24 '14