gpt4 book ai didi

安卓 AllJoyn : Connection with second machine gives error of BusAttachement

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:48:09 27 4
gpt4 key购买 nike

我已经为两种不同的传感器开发了应用程序。它们单独工作正常,但是当我尝试将它们组合在一起并创建两个不同的总线时,Alljoyn 给出了这个异常。

org.alljoyn.services.common.BusAlreadyExistException: The object has been set previously with a BusAttachment.

下面是我的连接源代码。谁能告诉我为什么会遇到这个问题。

private void connect() 
{ org.alljoyn.bus.alljoyn.DaemonInit.PrepareDaemon(getApplicationContext());

bus = new BusAttachment("ControlPanelBrowser", BusAttachment.RemoteMessage.Receive);
bus.registerBusListener(new BusListener());


Status status = bus.registerBusObject(mControlPanelSignalInterface, Constants.SERVICE_PATH);


if (status != Status.OK) {

Log.d(TAG, "Problem while registering bus object");

}

SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
srpPassword = settings.getString(PREFS_PASSWORD, DEFAULT_SECURED_SRP_PASSWORD);

SrpAnonymousKeyListener authListener = new SrpAnonymousKeyListener(this, logger, AUTH_MECHANISMS);
Status authStatus = bus.registerAuthListener(authListener.getAuthMechanismsAsString(),
authListener, getKeyStoreFileName());

if ( authStatus != Status.OK ) {
Log.e(TAG, "Failed to register AuthListener");
}

status = bus.connect();


if (Status.OK == status){

String daemonName = Constants.DAEMON_NAME_PREFIX + ".ControlPanelBrowser.G" +
bus.getGlobalGUIDString();

int flag = BusAttachment.ALLJOYN_REQUESTNAME_FLAG_DO_NOT_QUEUE;

Status reqStatus = bus.requestName(daemonName, flag);

if (reqStatus == Status.OK) {

Status adStatus = bus.advertiseName(Constants.DAEMON_QUIET_PREFIX +
daemonName, SessionOpts.TRANSPORT_ANY);

if (adStatus != Status.OK){
bus.releaseName(daemonName);
Log.e(TAG, "Failed to advertise daemon name: '" + daemonName + "', Error: '" + status + "'");
}
else{
Log.d(TAG, "Succefully advertised daemon name: '" + daemonName + "'");
}
}
else {
Log.e(TAG, "Failed to request daemon name: '" + daemonName + "', Error: '" + status + "'");
}
}


status = bus.registerSignalHandlers(mControlPanelSignalInterface);

if (status != Status.OK) {
Log.d(TAG, "Problem while registering signal handlers");
}

// Initialize AboutService

aboutClient = AboutServiceImpl.getInstance();
aboutClient.setLogger(logger);
try {
aboutClient.startAboutClient(bus);

for (String iface : ANNOUNCE_IFACES) {


aboutClient.addAnnouncementHandler(this, new String[] {iface});

}
} catch (Exception e) {

logger.error(TAG, "Unable to start AboutService, Error: " + e.getMessage());

}


}

最佳答案

使用 registerBusObject 两次,然后你可以制作一个总线附件

关于安卓 AllJoyn : Connection with second machine gives error of BusAttachement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35627204/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com