Planned changes to the I/O layer

Jef Driesen jef at libdivecomputer.org
Mon Jan 6 23:52:09 CET 2020


On 3/01/2020 19:45, Jef Driesen wrote:
> In the next few days, I'm planning to commit some non-backwards compatible
> changes to the I/O layer:
> 
> 
> A new dc_iostream_ioctl function will be introduced to perform I/O specific
> requests. This allows to extend the I/O layer with some driver specific
> features, without having to modify the api. The first candidate to use this
> feature will be the Oceanic BLE communication.
> 
> The dc_iostream_set_latency function will be removed, and re-implemented as an
> ioctl. This function isn't used anywhere in libdivecomputer, and is only
> relevant for the serial communication. Hence it's a perfect example of a feature
> than can be implemented as an ioctl.
> 
> A new dc_iostream_poll function will be added. This provides a more efficient
> alternative to using using a combination of the dc_iostream_get_available and
> dc_iostream_sleep functions.
> 
> 
> For all the built-in I/O transports, these changes will be completely
> transparent. But users of the custom I/O will need to update their code because
> the corresponding function pointers will be added/removed to/from the
> dc_custom_cbs_t structure.
The above changes have been committed to the master branch, along with support 
for Oceanic BLE communication (which is based on work by Linus Torvalds).

The Oceanic BLE support requires a custom I/O with an implementation for the 
DC_IOCTL_BLE_GET_NAME ioctl to retrieve the bluetooth device name. Something 
like in the following example:

app_ioctl (void *userdata, unsigned int request, void *data, size_t size)
{
     const char name[] = "FQ005535"; /* The actual bluetooth device name. */

     switch (request) {
     case DC_IOCTL_BLE_GET_NAME:
         strncpy(data, name, size);
         return DC_STATUS_SUCCESS;
     default:
         return DC_STATUS_UNSUPPORTED;
     }
}

Jef


More information about the devel mailing list