<span lang="EN">
<div>Hi All,</div>
<div> </div>
<div>  I am trying to call ConnectService API defined in connman (open source connection manager daemon). Connman has defined ConnectService with &quot;a{sv}&quot; signature.</div>
<div> </div>
<div>  When I tried to form and send message using below code, code is crashing with signal 11. Please let me know whats the issue in below code.</div>
<div> </div>
<div> </div>
<div>#include &lt;stdio.h&gt; </div>
<div>#include &lt;errno.h&gt; </div>
<div>#include &lt;stdlib.h&gt; </div>
<div>#include &lt;string.h&gt; </div>
<div>#include &lt;stdbool.h&gt;</div>
<div>#include &lt;glib.h&gt;</div>
<div>#include &lt;dbus/dbus-glib.h&gt;</div>
<div>#include &lt;dbus/dbus.h&gt;</div>
<div>#include &lt;sys/types.h&gt;</div>
<div>#include &lt;sys/stat.h&gt;</div>
<div> </div>
<div>typedef struct{</div>
<div>char type[20];</div>
<div>char mode[20];</div>
<div>char ssid[20];</div>
<div>char security[20];</div>
<div>char passphrase[20];</div>
<div>} network_connect_service_info_t;</div>
<div> </div>
<div>static int</div>
<div>network_dbus_connect_service(network_connect_service_info_t* conn_info)</div>
<div>{</div>
<blockquote style="MARGIN-RIGHT: 0px" dir="ltr">
<div>DBusError error; </div>
<div> </div>
<div>const char *prop_type = &quot;Type&quot;;</div>
<div>const char *prop_mode = &quot;Mode&quot;;</div>
<div>const char *prop_ssid = &quot;SSID&quot;;</div>
<div>const char *prop_security = &quot;Security&quot;;</div>
<div>const char *prop_passphrase = &quot;Passphrase&quot;;</div>
<p style="MARGIN-RIGHT: 0px" dir="ltr"></p>
<div style="MARGIN-RIGHT: 0px" dir="ltr">char* type = conn_info-&gt;type;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">char* mode = conn_info-&gt;mode;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">char* ssid = conn_info-&gt;ssid;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">char* security = conn_info-&gt;security;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">char* passphrase = conn_info-&gt;passphrase;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">DBusMessage *msg;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">DBusMessage *reply;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">DBusMessageIter dict, entry, array,value;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">DBusConnection* conn = NULL;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">if (conn == NULL) { </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">printf(&quot;Error!!! Can&#39;t get on system bus\n&quot;);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">return -1;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">}</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">msg = dbus_message_new_method_call(&quot;org.moblin.connman&quot;, &quot;/&quot;, &quot;org.moblin.connman.Manager&quot;, &quot;ConnectService&quot;);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">if(msg == NULL)</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">{</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">printf(&quot;Error!!! dbus_message_new_method_call() failed\n&quot;);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">return -1;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">}</div>
<p style="MARGIN-RIGHT: 0px" dir="ltr"> </p>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_init_append(msg, &amp;array);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;array, DBUS_TYPE_ARRAY, </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">DBUS_TYPE_STRING_AS_STRING </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">DBUS_TYPE_VARIANT_AS_STRING</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">DBUS_DICT_ENTRY_END_CHAR_AS_STRING,</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">&amp;dict);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;dict, DBUS_TYPE_DICT_ENTRY, 0, &amp;entry);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;entry, DBUS_TYPE_STRING, &amp;prop_type);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &amp;value); </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;value, DBUS_TYPE_STRING, type);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;entry, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;dict, &amp;entry);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;dict, DBUS_TYPE_DICT_ENTRY, 0, &amp;entry);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;entry, DBUS_TYPE_STRING, &amp;prop_mode);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;value, DBUS_TYPE_STRING, mode);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;entry, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;dict, &amp;entry); </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;dict, DBUS_TYPE_DICT_ENTRY, 0, &amp;entry);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;entry, DBUS_TYPE_STRING, &amp;prop_ssid);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;value, DBUS_TYPE_STRING, ssid);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;entry, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;dict, &amp;entry); </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;dict, DBUS_TYPE_DICT_ENTRY, 0, &amp;entry);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;entry, DBUS_TYPE_STRING, &amp;prop_security);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;value, DBUS_TYPE_STRING, security);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;entry, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;dict, &amp;entry); </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;dict, DBUS_TYPE_DICT_ENTRY, 0, &amp;entry);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;entry, DBUS_TYPE_STRING, &amp;prop_passphrase);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_open_container(&amp;entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_append_basic(&amp;value, DBUS_TYPE_STRING, passphrase);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;entry, &amp;value);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;dict, &amp;entry);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_iter_close_container(&amp;array, &amp;dict);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_error_init (&amp;error);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">reply = dbus_connection_send_with_reply_and_block (conn, msg, -1, &amp;error);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">if (dbus_error_is_set (&amp;error))</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">{</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">printf(&quot;Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n&quot;, <a href="http://error.name">error.name</a>, error.message);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">return -1;</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">}</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr"> </div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_unref(reply);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_message_unref(msg);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">printf(&quot;Successfully configured\n&quot;);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">dbus_connection_unref(conn);</div>
<div style="MARGIN-RIGHT: 0px" dir="ltr">return 0;</div></blockquote>
<div>}</div>
<div> </div>
<div>int main()</div>
<div>{</div>
<p>network_connect_service_info_t connection_info = {&quot;wifi&quot;,&quot;managed&quot;,&quot;datanet&quot;,&quot;psk&quot;,&quot;datanettest&quot;};</p>
<p>network_dbus_connect_service(&amp;connection_info);</p>
<p>return 0;</p>
<p>}</p></span><br clear="all"><br>-- <br>Regards &amp; Thanks<br>Raghavendra. S<br>9880329621<br>