Tool/software: Linux
Hi there,
I'm currently interfacing with the TRF7970a in a C++ application using Neard. I am using the low-level dbus api for communicating with the nfc bus. As of right now I can do everything that I need to (start/stop polling, read/write from tags), with the exception of powering off the adapter (I can read the adapter power state fine and can power it on, I just can't power it off).
The adapter NFC API has a Powered property for the adapters, so I am using the Set method of the org.freedesktop.DBus interface to set the power on/off over the nfc bus.
The code used to do so is below:
int setBoolProperty(DBusConnection *connection, const char* property, const int value, DBusError *error)
{
DBusMessage *queryMessage = NULL;
DBusMessage *replyMessage = NULL;
DBusMessageIter iter;
DBusMessageIter sub;
if (value != 0 && value != 1)
{
printf("Not a valid boolean type.\n");
return -1;
}
queryMessage = dbus_message_new_method_call("org.neard",
"/org/neard/nfc0",
"org.freedesktop.DBus.Properties",
"Set");
// append arguments to the Set() method. (string interface, string property, value)
dbus_message_iter_init_append(queryMessage, &iter);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &adapterName);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &property);
dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, DBUS_TYPE_BOOLEAN_AS_STRING, &sub);
// Set the bool value.
dbus_message_iter_append_basic(&sub, DBUS_TYPE_BOOLEAN, &value);
dbus_message_iter_close_container(&iter, &sub);
replyMessage = dbus_connection_send_with_reply_and_block(connection,
queryMessage,
1000,
error);
dbus_message_unref(queryMessage);
abort_on_error(error);
dbus_message_unref(replyMessage);
return 0;
}
Whenever I attempt to power off I first stop polling (using the StopPollLoop method on the org.neard.Adapter interface). I then set the Powered property to a 0. When the message gets received I get an "Unknown error -16" back from dbus and the power state doesn't change. I'm hoping that I'm missing something simple and that someone has some insight into what might be causing this problem.
-Ben