0

How to add about feature in ajtcl? [closed]

asked 2015-06-30 04:36:47 -0800

this post is marked as community wiki

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

I am able to announce about seperately. I am trying to add about feature to sessions example. When I start the service, the about data should be announced. I am not able to do it.

AJ_Initialize();
status = PropertyStore_Init();
if (status != AJ_OK)
{
    goto Exit;
}
status = About_Init(AnnounceObjects, aboutIconMimetype, aboutIconContent, aboutIconContentSize, aboutIconUrl);
if (status != AJ_OK)
{
    goto Exit;
}
status = AJServices_Init(AppObjects, ProxyObjects, AnnounceObjects, deviceManufactureName, deviceProductName);
if (status != AJ_OK)
{
    goto Exit;
}
AJ_RegisterObjects(AppObjects, ProxyObjects);
SetBusAuthPwdCallback(MyBusAuthPwdCB);
AJ_StartReadFromStdIn();

while (TRUE)
{
    AJ_Message msg;
    status = AJ_OK;

    if (!isBusConnected)
    {
        isBusConnected = AJRouter_Connect(&busAttachment, ROUTER_NAME);
        if (isBusConnected)
        {
            status = AJServices_ConnectedHandler(&busAttachment);
        }
        else
        { // Failed to connect to daemon.
            continue; // Retry establishing connection to daemon.
            //goto Exit;
        }
    }

    if (status == AJ_OK)
    {
        status = AJApp_ConnectedHandler(&busAttachment);
    }

    if (status == AJ_OK)
    {
        status = AJ_UnmarshalMsg(&busAttachment, &msg, AJAPP_UNMARSHAL_TIMEOUT);
        isUnmarshalingSuccessful = (status == AJ_OK);

        if (status == AJ_ERR_TIMEOUT)
        {
            if (AJ_ERR_LINK_TIMEOUT == AJ_BusLinkStateProc(&busAttachment))
            {
                status = AJ_ERR_READ; // something's not right. force disconnect
            }
            else
            { // nothing on bus, do our own thing
                //printf("in else before AJServices_DoWork before continue\n");
                AJServices_DoWork(&busAttachment);
                //sessionsAJ_Main();
                continue;
                //goto Exit;
            }
        }

        if (isUnmarshalingSuccessful)
        {
            serviceStatus = AJServices_MessageProcessor(&busAttachment, &msg, &status);
            if (serviceStatus == AJSVC_SERVICE_STATUS_NOT_HANDLED)
            {
                //Pass to the built-in bus message handlers
                status = AJ_BusHandleBusMessage(&msg);
            }
            AJ_NotifyLinkActive();
        }
        //Unmarshaled messages must be closed to free resources
        AJ_CloseMsg(&msg);
    }

    if (status == AJ_ERR_READ || status == AJ_ERR_RESTART || status == AJ_ERR_RESTART_APP)
    {
        if (isBusConnected)
        {
            AJApp_DisconnectHandler(&busAttachment, status != AJ_ERR_READ);
            AJServices_DisconnectHandler();
            isBusConnected = !AJRouter_Disconnect(&busAttachment, status != AJ_ERR_READ);
            if (status == AJ_ERR_RESTART_APP)
            {
                AJ_Reboot();
            }
        }
    }

} // while (TRUE)

This how I am announcing about data

            status = AJ_StartService(&bus, NULL, CONNECT_TIMEOUT, TRUE, port, name, AJ_NAME_REQ_DO_NOT_QUEUE, &opts);

            AJ_BusAddSignalRule(&bus, "Sessions", InterfaceName, AJ_BUS_SIGNAL_ALLOW);

This is how I am starting a service for chatting.

I want to announce the aboutdata when I announce the chat service.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by abhiramg94
close date 2015-07-05 23:37:08

Comments

May you provide some source code please? It is heavy to determine where the mistake is if you don't provide a code snippet.

julianbros ( 2015-07-01 04:31:15 -0800 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-07-05 02:40:24 -0800

praveenb gravatar image

AllJoyn About is a mechanism by which applications can advertise the interfaces they implement and can discover other applications.

When using Thin Core Library, the following need to be done to implement About:

  • The object + interfaces implemented that you want to advertise should be marked with flag AJ_OBJ_FLAG_ANNOUNCED
  • Using AJ_AboutRegisterPropStoreGetter, register a function (AboutData is the newer term for the older PropertyStore that has been being deprecated). This getter function is used when sending an About announcement / when responding to GetAboutData method request.
  • To send an announcement, invoke AJ_AboutInit with a session port that your application has already bound (using AJ_BusBindSessionPort api)

A couple of examples written using Thin Core Library using About are:

edit flag offensive delete publish link more

Comments

Thank you. I was missing AJ_OBJ_FLAG_ANNOUNCED.

abhiramg94 ( 2015-07-05 23:36:19 -0800 )edit

Question Tools

Follow
1 follower

Stats

Asked: 2015-06-30 04:36:47 -0800

Seen: 271 times

Last updated: Jul 05 '15