0

Can`t find Service Name in Arduino YUN.

asked 2015-03-31 22:19:51 -0800

BEOM gravatar image

updated 2015-04-23 17:10:09 -0800


<<< Server Side >>>
- Device : Android
- Language : JAVA
- Source Code : I have adjusted code in 'SimpleService' Android Example Project like below.

( In "Service.java" )
private static final String SERVICE_NAME = "org.alljoyn.test";
private static final short CONTACT_PORT = 2;

( In "SimpleInterface.java" )
@BusInterface(name = "org.alljoyn.test")
public interface SimpleInterface {
@BusSignal
public void Chat(String inStr) throws BusException;
}


<<< Client Side >>>
- Device : Arduino YUN
- Language : Alljoyn.js
- Source Code : below

var AJ = require('AllJoyn');

AJ.interfaceDefinition["org.alljoyn.test"] = { Chat:{ type:AJ.SIGNAL, args:["s"] }, };

AJ.objectDefinition['/Chat'] = { interfaces:['org.alljoyn.test'] };

function test(svc){
var testSignal = AJ.signal('/Chat', {Chat:'org.alljoyn.test'});
testSignal.send("hello");
}

AJ.onAttach = function(){
print("AJ.onAttach");
AJ.findService("org.alljoyn.test", test);
}

AJ.onDetach = function() { print("AJ.onDetach"); }


I want to communicate between Arduino and Android using signal interface. They are connected same wifi network. But, Arduino YUN can`t find any service name. How can I solve this problem? Thank you.

edit retag flag offensive close merge delete

Comments

Could you give more detail, like the entire script your using for AllJoyn.js? As well as relevant code for the Android App? Its probably not as simple as one API not working but rather your setup before/after that could be causing the problem.

jprestwo ( 2015-04-01 10:21:27 -0800 )edit

I have posted code above. Thank you.

BEOM ( 2015-04-01 17:35:36 -0800 )edit

Thank you so much jprestwo!!!! It's working fine now thanks again.

BEOM ( 2015-04-02 17:12:02 -0800 )edit

I have converted my comment to an answer, could you please mark it as correct if others have the same problem. Thank you, glad it is working for you.

jprestwo ( 2015-04-03 09:41:05 -0800 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-04-02 09:18:05 -0800

jprestwo gravatar image

updated 2015-04-03 09:40:13 -0800

Thank you for posting the code. When you call AJ.findService() in AllJoyn.js it registers for an About announcement to find the service. Unfortunately the android samples do not use About because they were written before About existed and have yet to be updated. You are going to have to use name based discovery in AllJoyn.js or write the code to make an About announcement in the Android samples. To do name based discovery in AllJoyn.js use:

AJ.findServiceByName( name, (iface,path,port object), callback).

For your example the name would be "org.alljoyn.test", the second argument should be an object containing the interface, path and port like:

{interfaces:["org.alljoyn.test"], path:"/Chat", port:2}.

The final argument is the callback function. Also when your callback function is called you must save the service parameter as a global or else you will lost reference to it and not receive any chat signals.

edit flag offensive delete publish link more

Comments

Is there anything else that needs to be changed in SimpleClient android app aside from what BEOM did? I am trying to do the same thing and I have set this on Arduino Yun: AJ.findServiceByName("org.alljoyn.test", {interfaces:["org.alljoyn.test"], path:"/Chat", port:2}, test); but they don't connect?

AllJoyner ( 2015-04-23 12:48:19 -0800 )edit
1

I am not sure, he could have changed more than what he posted. If you look at the alljoyn-js git repository now there is chat.js which will connect to the SCL chat.cc sample. This I have tried (AllJoyn.js -> SCL) but not to android. If the Android chat sample was meant to work with the SCL chat sample then I see no reason why it wouldn't work with AllJoyn.js. Give the chat.js sample a try without any modifications and see if that works. https://git.allseenalliance.org/cgit/core/alljoyn-js.git/tree/js/chat.js

jprestwo ( 2015-04-23 15:02:59 -0800 )edit

Hi, AllJoyner. You have to run "SimpleService.java" android Application. It is my mistake. In SimpleService.java, You can see the code line like "mBus.advertiseName(SERVICE_NAME, sessionOpts.transports);". Android Application advertise ServiceName, and Arduino Yun discovery ServiceName. Then, they will connect each other.

BEOM ( 2015-04-23 17:05:15 -0800 )edit

@jprestwo thanks, that a was great example, it works both with chat.cc and android chat sample. @BEOM i tried changing the service_name and port number and modifying the interface but they dont connect, thats why i was asking if you have changed anything else

AllJoyner ( 2015-04-27 10:45:04 -0800 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2015-03-31 22:19:51 -0800

Seen: 167 times

Last updated: Apr 23 '15