Search form


Configuration API Guide - Objective-C

Reference code

Classes used to remotely change ConfigData

Client class Description
ConfigClient Helper class for discovering About Server that provides access to the Announcements and to the AboutService. It listens for Announcements sent using the org.alljoyn.About interface.

Obtain the Configuration service framework

See the Building iOS/OS X section for instructions on compiling the Configuration service framework.

Build an application that uses ConfigClient

The following steps provide the high-level process to build an application that will remotely manipulate ConfigData.

  1. Create the base for the AllJoyn™ application.
  2. Initialize the AboutService in client mode.
  3. Initialize the ConfigService in client mode.
  4. Create a ConfigClient to interact with an announced Config Server.

Setting up the AllJoyn framework and About feature

The steps required for this service framework are universal to all applications that use the AllJoyn framework and for any application using one or more AllJoyn service frameworks. Prior to use of the Configuration service framework as a Config Client, the About feature must be implemented and the AllJoyn framework set up.

Complete the procedures in the Building iOS/OS X section to guide you in this process.

Implementing an Application that uses Config Client

To implement an application to receive and modify ConfigData, use the ConfigClient class. The AboutClient class must be used so that your application is notified when applications with About Server and possibly Config Server instances send announcements.

Verify the BusAttachment has been created, started and connected before implementing a Config Client.

NOTE: Code in this chapter references a variable clientBusAttachment (the BusAttachment variable name).

Establish the AboutService object

For an application to discover peer applications that are ConfigService providers, it requires an instance of AJNAnnouncementReceiver.

self.announcementReceiver = ;
[self.configClient resetConfigurationsWithBus:self.annBusName languageTag:@""

Reset the peer device application to factory defaults

The peer device/application configuration can be reset to factory defaults through the ConfigClient via the FactoryReset() method call.

NOTE: This is a no-reply call, so its success cannot be determined directly.

[self.configClient factoryResetWithBus:self.annBusName

Restart the peer

The peer application can be restarted though the ConfigClient via the Restart() method call.

NOTE: This is a no-reply call, so its success cannot be determined directly.

[self.configClient factoryResetWithBus:self.annBusName

Setting a passcode on the peer

The peer application can be set to have a different passcode though the ConfigClient using the SetPasscode() method call. This revokes the current encryption keys and regenerates new ones based on the new shared secret, namely the passcode.

NOTE: The realm name is currently ignored.

NSString *pass = @"123456";
NSData *passcodeData = [pass dataUsingEncoding:NSUTF8StringEncoding];
const void *bytes = [passcodeData bytes];
int length = [passcodeData length];
[self.configClient setPasscodeWithBus:self.annBusName
   daemonRealm:self.realmBusName newPasscodeSize:length
   newPasscode:(const uint8_t
*)bytes sessionId:self.sessionId];

Delete variables and unregister listeners

Once you are done using the About feature, Configuration service framework, and the AllJoyn framework, free the variables used in the application.

The ARC takes care of releasing some objects so no need to do it explicitly.

const char* interfaces[] = { "org.alljoyn.Config" };
   [self.announcementReceiver unRegisterAnnouncementReceiverForInterfaces:interfaces withNumberOfInterfaces:1];
self.announcementReceiver = nil;
For future news and updates, please follow or visit
1 year 1 week ago