Alljoyn Thin Client(Arduino) cannot connect to the Daemon!

asked 2014-04-02 04:13:03 -0700

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I ran the sample which name is "ledctrl.exe" and "AJ_LedService.ino" and so on... It works very well. The console printed "do work".

I found that the source code, ledctrl.exe, is based on C++, so that I modify the code to Java(Android) I matched the interface name, daemon name, port number, and so on... But the arduino cannot connect to the AllJoyn Standard Client(Android)

The Arduino Serial Monitor Msg is

Hello <node name="/org/alljoyn/sample/ledcontroller"> <interface name="org.alljoyn.sample.ledcontroller"> <method name="Flash"> <arg direction="in" name="msec" type="u"> </arg></method> <method name="On"> </method> <method name="Off"> </method> </interface> </node> 000.000 ajnet.cpp:209 AJNetConnect(): connect() success: status=AJOK

001.365 ajhelper.cpp:285 AJStartService2(): connect failed: sleeping for 10 seconds

How can I do? Thanks in advance! :)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-04-02 11:35:17 -0700

bspencer gravatar image

An AllJoyn Thin Library application as you have running on the Arduino Due requires that an AllJoyn Router be in the proximal space. Running this in an Android application requires you to tell the Bundled AllJoyn Router that it should advertise so that the AllJoyn Thin Library application can find and connect to it.
The C++ code for the ledctrl.exe has the following that is most likely missing from the Android application:
From: https://git.allseenalliance.org/cgit/core/alljoyn.git/tree/alljoyn_core/test/ledctrl.cc

const char* DaemonBusName = "quiet@org.alljoyn.BusNode.Led";
PasswordManager::SetCredentials("ALLJOYN_PIN_KEYX", "1234");
if (ER_OK == status) {
        status = g_msgBus->AdvertiseName(::org::alljoyn::alljoyn_test::DaemonBusName, TRANSPORT_TCP);

You can see in this sample found for the NotificationServiceUISample:
From: https://git.allseenalliance.org/cgit/services/notification.git/tree/java/sample_applications/android/NotificationServiceUISample/src/org/alljoyn/ns/sampleapp/IoeNotificationApplication.java
Has similar code, except you will want to change the password to be 1234 instead of 00000. You are most likely missing code is contained inside the method advertiseDaemon()

edit flag offensive delete publish link more


Can I advertise an another service name like "org.alljoyn.bus.abc" below "status = g_msgBus->AdvertiseName(::org::alljoyn::alljoyn_test::DaemonBusName, TRANSPORT_TCP);" on a standard client and is the program going to crash? Why does not the "::org::alljoyn::alljoyn_test::DaemonBusName" request name on the busattachment? Last question, please, does the thin client recognize key words "quiet@org.alljoyn.BusNode." for connecting a daemon on standard client? Thanks a lot for your answer~

wanglingdeemo ( 2014-04-02 21:40:36 -0700 )edit

An AllJoyn Thin Library application will look for the wellknown name of "org.alljoyn.BusNode" so anything after BusNode is fine to change. If you make changes tot he name like "org.alljoyn.bus.abc" you would need to modify the Thin Library code to look for this specific AllJoyn Router. I would not recommend this as you then ONLY have the Thin Library application connecting to a specific AllJoyn Router and if that AllJoyn Router goes away or is not running the Thin Library application would not be able to communicate with other AllJoyn applications.
A quiet@ prefix to a wellknown name is a passive advertisement that is sent via unicast to the application that is looking for a wellknown name that matches. A quiet advertisement does not continue to advertise every 120 seconds and will only reply at the lower level over Wi-Fi to a UDP WHO-HAS packet ...(more)

bspencer ( 2014-04-03 09:40:51 -0700 )edit
Login/Signup to Answer


Asked: 2014-04-02 04:13:03 -0700

Seen: 1,550 times

Last updated: Apr 02 '14