/* 设置About数据, 使应用能够广而告知 */
mAboutData = new AboutPropertyStoreImpl();
// 设置一个独一无人的ID, 比如说设备的Mac地址
// 为应用设置一个随机值, 这种方法在商业应用中也很常见
mAboutData->setDeviceId(getDeviceId());
mAboutData->setDeviceName("MyDeviceName");
// AllJoyn应用的全局辨识符 - recommend to use an online GUID generator to create
// use a random value for this application, this should persist in a comercial application
mAboutData->setAppId(getAppId());
std::vector languages(1);
languages[0] = "en";
mAboutData->setSupportedLangs(languages);
mAboutData->setDefaultLang("en");
mAboutData->setAppName(appName);
mAboutData->setModelNumber("Tutorial5000");
mAboutData->setDateOfManufacture("8/15/2014");
mAboutData->setSoftwareVersion("1.0 build 1");
mAboutData->setAjSoftwareVersion(ajn::GetVersion());
mAboutData->setHardwareVersion("N/A");
mAboutData->setDescription("This is the my first AllJoyn Application!", "en");
mAboutData->setManufacturer("Company", "Me");
mAboutData->setSupportUrl("http://www.allseenalliance.org");
/* Initialize the About feature Service side */
AboutServiceApi::Init(*mBusAttachment, *mAboutData);
/* Register the port with About feature that was set when BindSession called */
status = AboutServiceApi::getInstance()->Register(sp);
/* Register the About feature with AllJoyn */
status = mBusAttachment->RegisterBusObject(*AboutServiceApi::getInstance());
接下来,应用就可以开始集合了。我们已经为其他应用的寻找与互联编写好了平台
/*设置并注册开发者的总线应用*/
/**
* Here is where we add the objects we wish to expose.
* A developer would modify this section to add different BusObjects.
*/
mMyFirstBusObject = new MyFirstBusObject(*mBusAttachment);
/* Now register the object with AllJoyn and About */
QStatus status;
status = mBusAttachment->RegisterBusObject(*mMyFirstBusObject);
if (ER_OK != status) {
printf("Could not register the BusObject with the BusAttachmentn");
}
std::vector interfaces;
for( int i = 0; i < mMyFirstBusObject->getNumberOfInterfaces(); i++) {
interfaces.push_back(mMyFirstBusObject->getInterfaceName(i));
}
status = AboutServiceApi::getInstance()->AddObjectDescription(mMyFirstBusObject->GetPath(), interfaces);
if (ER_OK != status) {
printf("Error returned by AddObjectDescription (%s).n", QCC_StatusText(status));
}
BusObject与MyFirstBusObject包含了我们互相进行通讯的所有信息,并且将我们事先的所有的API集进行了开放,允许其他应用进行调用