summaryrefslogtreecommitdiff
path: root/src/adapter.c
AgeCommit message (Collapse)AuthorFilesLines
2013-11-21adapter: Remove near_adapter_listSamuel Ortiz1-19/+0
This routine is no longer called.
2013-11-20adapter: Make the power cycle upon driver error configurableSamuel Ortiz1-6/+7
The default behaviour is to power cycle the adapter when receiving a driver error.
2013-11-18adapter: Catch polling errorsSamuel Ortiz1-0/+44
Receiving a NFC_EVENT_TARGETS_FOUND with a NULL payload means the driver entered an error state. This is handled by checking if the devices and targets arrays are empty from the GET_TARGET finish handler. In the polling error case, neard resets the adapter and starts polling again. The polling error handler runs asynchrounously for the D-Bus properties toggle to be exported properly.
2013-11-11device: Create the Device D-Bus interface only when the DEP link is upSamuel Ortiz1-1/+10
In Initiator mode, this is when we get a DEP_LINK_UP event. In target mode, DEP link is up as soon as we see a new device. This fix avoids racy situations where a Device interface is available although the DEP link is still not up.
2013-11-10tag: ObjectManager conversionSamuel Ortiz1-111/+2
Set and GetProperties are no longer relevant. Also, there is no longer any need to update the Tags and Records Adapter properties.
2013-11-10adapter: Initial transition to managed objectsSamuel Ortiz1-125/+126
The manager Adapters property is removed. And so are the adapter Tags and Devices properties. All of them become managed objects and thus no longer need to be explicit parent object properties. Since the only methods left to the Manager interface were agent registration ones, the Manager interface becomes the AgentManager one.
2013-10-14adapter: Implement TagFound signalSamuel Ortiz1-2/+11
And TagLost as well. Those signals fix the current racy behaviour where apps get a Tags property change notification and then ask for the tag properties. The tag may have disappeared in the meantime. Eventually, the Tags property should disappear.
2013-10-11adapter: Do not send a poll command when adapter is downSamuel Ortiz1-0/+5
No need to go through the kernel netlink NFC API if the adapter is known to be down.
2013-08-20core: Do not compare expression against NULLDaniel Wagner1-42/+42
This patch generate via coccinelle with: @ disable is_null,isnt_null1 @ expression E; @@ ( - E == NULL + !E | - E != NULL + E )
2013-08-20core: Use stdbool instead gboolean or near_bool_tDaniel Wagner1-35/+34
This patch has been created via coccinelle: // Rule set 1 f(es, ( - FALSE + false | - TRUE + true ) ,...) @r2@ type T; identifier f; parameter list[n] ps; identifier i; @@ T f(ps, near_bool_t i, ...); @@ identifier r2.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) @@ typedef bool; @@ - near_bool_t + bool // Rule set 2 // This is not a beautiful script but it does the job. // Improvemtents are welcome. // Fix all assigments but do not convert yet the type @@ gboolean x; @@ x = ( - TRUE + true | - FALSE + false ) // Figure out which function signature will to be fixed... // when we have the defitition @r@ identifier f; parameter list[n] ps; identifier i; @@ f(ps, gboolean i, ...) { ... } // ... and now convert all call sites @@ identifier r.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) // Figure out which function signature will to be fixed... // when we have the declaration only @r2@ type T; identifier f; parameter list[n] ps; identifier i; @@ T f(ps, gboolean i, ...); // ... and now convert all call sites @@ identifier r2.f; expression list [r.n] es; @@ f(es, ( - FALSE + false | - TRUE + true ) ,...) // A handfull of the GLib hooks we can't change. Let's remember // all ther positions. // 1. timeouts @k1@ identifier f; position p; typedef gpointer; identifier ptr; @@ static gboolean@p f(gpointer ptr); @k2@ identifier f; position p; identifier ptr; @@ static gboolean@p f(gpointer ptr) { ... } // hash map iterator functions @k3@ identifier f; position p; identifier p1, p2, p3; @@ static gboolean@p f(gpointer p1, gpointer p2, gpointer p3) { ... } // 2. GIOChannel @k4@ identifier f; position p; typedef GIOChannel, GIOCondition; identifier ptr; identifier ch, cn; @@ static gboolean@p f(GIOChannel *ch, GIOCondition cn, gpointer ptr); @k5@ identifier f; position p; identifier ptr; identifier ch, cn; @@ static gboolean@p f(GIOChannel *ch, GIOCondition cn, gpointer ptr) { ... } // 3. GSourceFuncs @k6@ identifier f; position p; typedef GSource; identifier src; @@ static gboolean@p f(GSource *src, ...) { ... } // gdbus functions @k7@ identifier f; position p; typedef DBusConnection; identifier con; @@ static gboolean@p f(DBusConnection *con, ...) { ... } // Now convert all gboolean which are are not used for interactin // with GLib // Note here happens the magic! @@ typedef bool; position p != {k1.p,k2.p,k3.p,k4.p,k5.p,k6.p,k7.p}; @@ - gboolean@p + bool // Update all return types @@ identifier f; @@ bool f(...) { <... - return TRUE; + return true; ...> } @@ identifier f; @@ bool f(...) { <... - return FALSE; + return false; ...> } // Rule set 3 @@ expression E; symbol TRUE; symbol FALSE; @@ ( E - == TRUE | - TRUE == E + E | - E != TRUE + !E | - TRUE != E + !E | - E == FALSE + !E | - FALSE == E + !E | E - != FALSE | - FALSE != E + E )
2013-08-20adapter: Use dbus_bool_t for D-Bus functionsDaniel Wagner1-4/+9
2013-07-03adapter: Restart polling when failing to connect to a new targetSamuel Ortiz1-2/+8
If a newly detected target failed to be connected then a new polling loop is started if constant poll is enabled. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-06-28adapter: Add a DEP link establishment timerSamuel Ortiz1-0/+25
Once a device in target mode is found, the polling loop restarts after 1 second if the dep_link_is_up is not received.
2013-06-10adapter: Pass the right adapter index when auto powering adaptersSamuel Ortiz1-1/+1
When calling __near_netlink_adapter_enable(), adapter->idx is not yet set. The right adapter index to pass is the __near_adapter_create() argument.
2013-04-11main.conf: Add DefaultPowered configurationSamuel Ortiz1-0/+9
DefaultPowered is a boolean and will force neard into turning any detected adapter on when set to TRUE.
2013-02-06adapter: Disconnect from the target when data read fails to startSamuel Ortiz1-1/+9
2013-01-08adapter: Fix memory leaks on adapter freeSzymon Janc1-0/+2
Destroy hash tables when removing adapter. 184 (88 direct, 96 indirect) bytes in 1 blocks are definitely lost in loss record 132 of 156 at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x4E69A02: g_hash_table_new_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x418AD7: __near_adapter_create (adapter.c:613) by 0x41790F: __near_manager_adapter_add (manager.c:79) by 0x41D1CB: get_devices_handler (netlink.c:173) by 0x579A4A9: nl_recvmsgs (in /lib/libnl-3.so.200.3.0) by 0x41C562: nl_send_msg (netlink.c:136) by 0x41D38A: __near_netlink_get_adapters (netlink.c:200) by 0x4084F1: main (main.c:210) 184 (88 direct, 96 indirect) bytes in 1 blocks are definitely lost in loss record 133 of 156 at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x4E69A02: g_hash_table_new_full (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3) by 0x418AF8: __near_adapter_create (adapter.c:617) by 0x41790F: __near_manager_adapter_add (manager.c:79) by 0x41D1CB: get_devices_handler (netlink.c:173) by 0x579A4A9: nl_recvmsgs (in /lib/libnl-3.so.200.3.0) by 0x41C562: nl_send_msg (netlink.c:136) by 0x41D38A: __near_netlink_get_adapters (netlink.c:200) by 0x4084F1: main (main.c:210)
2012-12-06Fix coding style errors through the codeSzymon Janc1-1/+1
This fix some style errors reported by checkpatch and found while working with code.
2012-11-29adapter: Update the Devices array before emitting the D-Bus signalSamuel Ortiz1-1/+6
2012-11-26adapter: Update the RF mode D-Bus propertySamuel Ortiz1-0/+22
When detecting a tag, or a device, the RF mode changes. When the link is down, RF mode goes to Idle.
2012-11-26adapter: Expose the adapter radio mode through D-BusSamuel Ortiz1-1/+27
2012-10-09adapter: Refactor function near_adapter_sendWiktor Lawski1-7/+16
Now this function will release allocated data using callback, so it will be unnecessary to check its returned error code (if callback was passed). Main reasons to prepare this change were improvement of code readability and removing error prone code paths.
2012-10-08tag: Don't check presence while busyDorota Moskal1-0/+33
When reading, writing or formating is in progress, no check presence should be done.
2012-09-21adapter: Fix error message for StopPollLoopWiktor Lawski1-0/+3
Now when adapter is not polling and StopPollLoop is called, correct error message will be returned.
2012-09-17adapter: Remove the linked device when DEP goes downSamuel Ortiz1-1/+7
2012-09-13tag: Remove redundant __near_tag_get_idx functionDorota Moskal1-2/+2
__near_tag_get_idx function wasn't needed as the same action was performed by near_tag_get_target_idx.
2012-09-13adapter: Send the Devices property changed earlierSamuel Ortiz1-2/+5
As opposed to a tag, a device should be accessible before the first read (That could potentially never happen) so the Adapter Devices property change should be sent when the DEP link is up.
2012-09-07adapter: Fix SetProperty error messageWiktor Lawski1-2/+6
Now when adapter is disabled and an attempt is made to disable it, correct error message will be returned.
2012-08-14Fix some whitespace issuesSzymon Janc1-31/+21
2012-08-07adapter: Add a DEP state accessorSamuel Ortiz1-0/+13
2012-06-28adapter: Return a better error when powering an already powered adapterSamuel Ortiz1-1/+5
2012-06-22adapter: Early p2p bindingSamuel Ortiz1-0/+19
The LLCP wks array will be properly built before the MAC link is up by binding to p2p services as soon as a p2p driver is registered. The bound will also happen when the MAC link is up for supporting kernels where the bound LLCP sockets will be closed when the MAC is brought down. For more recent kernels, the bind operation will happen only once.
2012-06-01adapter: Default polling loop mode is InitiatorSamuel Ortiz1-1/+3
Until the kernel target mode gets more testing, the default polling loop mode should be Initiator, as it used to be.
2012-05-31adapter: Set the DEP flag to false when a device is removedSamuel Ortiz1-4/+3
2012-05-26adapter: Add device addition APISamuel Ortiz1-0/+43
This API will be used for adding new devices when running in target mode.
2012-05-26adapter: Implement new polling loop D-Bus APISamuel Ortiz1-5/+36
The simple StartPoll is replaced with a polling loop method, where polling mode is specified. It can be Initiator, Target or both. When starting the polling loop in Target mode an NFC device could eventually activate us.
2012-05-25adapter: Fix GIOChannel leakVinicius Costa Gomes1-1/+1
As we are not using channel anymore we may drop this reference, and let GLib clean it up, closing the file descriptor.
2012-05-23Do not set signature and reply in GDBus tablesHenrique Dante de Almeida1-7/+7
Use GDBUS_* macros, so signature and reply fields are not set in each method/signal.
2012-05-23Convert GDBus methods and signals to use macro helpersHenrique Dante de Almeida1-7/+12
With these macro helpers we can separate in/out arguments and use their own vector.
2012-05-23Constify GDBus signal tablesHenrique Dante de Almeida1-1/+1
Constify signal tables with the following command: find . -name '*.[ch]' -exec \ sed -i 's/\(GDBusSignalTable .* =\)/const \1/g' {} \;
2012-05-23Constify GDBus method tablesHenrique Dante de Almeida1-1/+1
Constify method tables with the following command: find . -name '*.[ch]' -exec \ sed -i 's/\(GDBusMethodTable .* =\)/const \1/g' {} \;
2012-05-04adapter: Disconnect and check for presence when getting an I/O errorSamuel Ortiz1-5/+15
Without doing so, the automatic polling won't start.
2012-04-24adapter: Restart polling when devices link goes downSamuel Ortiz1-0/+10
No need for a check presence implementation as the MAC link status will be updated over netlink.
2012-04-20adapter: Remove the Publish methodSamuel Ortiz1-378/+4
NDEF queueing should be done by upper layers with a more accurate application status knowledge. NDEF are now written to tags with the Tag.Write method. A Device.Push one will also be implemented.
2012-04-20adapter: Call devices changes from the device reader callbackSamuel Ortiz1-1/+1
2012-04-20adapter: Make adapter_set_dep_state private to neard coreSamuel Ortiz1-14/+1
Plugins don't need to call thsi routine.
2012-04-20tag: Change tag driver ops namingSamuel Ortiz1-2/+2
read and write sounds more like what those drivers do.
2012-04-19device: Add device listening code pathSamuel Ortiz1-15/+45
2012-04-19device: Add D-Bus interfaceSamuel Ortiz1-9/+90
2012-04-19adapter: Bypass the target layerSamuel Ortiz1-111/+110
Adapters talk to tags or device directly. The target vs initiator idea will be removed from the code base. This commit temporarily breaks p2p.