How to get the value of the property

asked 2015-04-15 02:32:32 -0700

bling gravatar image

I know how to call method from the sample code,basic_service and basic_client.
How, now I want to get the value of the property.
The value of the property I want to get is "Value".
My Code is :

static const char ucVolServicePath[] = "/ControlPanel/SmartPlug/rootContainer/en/MeasureContainer/VoltageProperty";
static const char* const VolInterface[] = {"org.alljoyn.ControlPanel.Property","@Value=v",NULL};   
static const AJ_InterfaceDescription VolInterfaces[] = {

static const AJ_Object AppObjects[] = {
{ ucOnServicePath, OnInterfaces },
{ ucOffServicePath, OffInterfaces },
{ ucVolServicePath, VolInterfaces },
{ NULL }};

After BusAttaching and JoinSession :

AJ_Status status;
AJ_Message msg;
status = AJ_MarshalMethodCall(bus, &msg, AJ_PRX_MESSAGE_ID(2, 0, 0), g_peerServiceName, sessionId, 0, METHOD_TIMEOUT);                               
if (status == AJ_OK) 
    status = AJ_DeliverMsg(&msg);            
status = AJ_UnmarshalMsg(&bus, &msg, UNMARSHAL_TIMEOUT);
if (status == AJ_OK) 
    const char* sig;
    unsigned long Vol;
    status = AJ_UnmarshalVariant(&msg, &sig);
    if (status == AJ_OK) 
        status = AJ_UnmarshalArgs(&msg, sig, &Vol);
        AJ_AlwaysPrintf(("Get prop reply %d\r\n", Vol));                 
         AJ_AlwaysPrintf(("Fail: AJ_UnmarshalVariant: %X\r\n",status));

The result will be:

Fail: AJ_UnmarshalVariant: A

The Interface is as below:

<node name="/ControlPanel/SmartPlug/rootContainer/en/MeasureContainer/VoltageProperty">
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg type="s" direction="in"/>
<arg type="s" direction="in"/>
<arg type="v" direction="out"/>
<method name="Set">
<arg type="s" direction="in"/>
<arg type="s" direction="in"/>
<arg type="v" direction="in"/>
<method name="GetAll">
<arg type="s" direction="in"/>
<arg type="a{sv}" direction="out"/>
<interface name="org.alljoyn.ControlPanel.Property">
    <property name="Version" type="q" access="read"/>
    <property name="States" type="u" access="read"/>
    <property name="OptParams" type="a{qv}" access="read"/>
    <signal name="MetadataChanged">
<property name="Value" type="v" access="readwrite"/>
<signal name="ValueChanged">
<arg type="v"/>

Can anyone give me an advice? Thank you a lot!!

edit retag flag offensive close merge delete


I found that I can get the property from the method "GetAll". But I get the Arg of Array type. Is there any function that can separate the content in the array? For example, I get an array of Version in type "p", States in type "u",OptParams in type "a" and Value in type "v". I want to get the Value in type "v" only. Thank you!

bling ( 2015-04-16 06:46:06 -0700 )edit

you might get a better response over on the mailing list.

ry.jones ( 2015-09-10 09:08:18 -0700 )edit