Add support for retrieving the transport type.

With the new interface, an application can easily retrieve the
underlying transport type from the device descriptors and present a
custom user interface element to the end-user for supplying transport
specific parameters. For example the serial port for devices using
serial communcication.

For devices using a usb-serial chipset or the bluetooth Serial Port
Profile (SPP/rfcomm), the transport type is DC_TRANSPORT_SERIAL, because
internally the serial emulation layer is used for the communication.
This commit is contained in:
Jef Driesen 2013-04-16 12:32:03 +02:00
parent 6419e189a4
commit d4a8f2eb40
3 changed files with 25 additions and 0 deletions

View File

@ -29,6 +29,13 @@
extern "C" {
#endif /* __cplusplus */
typedef enum dc_transport_t {
DC_TRANSPORT_NONE,
DC_TRANSPORT_SERIAL,
DC_TRANSPORT_USB,
DC_TRANSPORT_IRDA
} dc_transport_t;
typedef struct dc_descriptor_t dc_descriptor_t;
dc_status_t
@ -49,6 +56,9 @@ dc_descriptor_get_type (dc_descriptor_t *descriptor);
unsigned int
dc_descriptor_get_model (dc_descriptor_t *descriptor);
dc_transport_t
dc_descriptor_get_transport (dc_descriptor_t *descriptor);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -280,3 +280,17 @@ dc_descriptor_get_model (dc_descriptor_t *descriptor)
return descriptor->model;
}
dc_transport_t
dc_descriptor_get_transport (dc_descriptor_t *descriptor)
{
if (descriptor == NULL)
return DC_TRANSPORT_NONE;
if (descriptor->type == DC_FAMILY_ATOMICS_COBALT)
return DC_TRANSPORT_USB;
else if (descriptor->type == DC_FAMILY_UWATEC_SMART)
return DC_TRANSPORT_IRDA;
else
return DC_TRANSPORT_SERIAL;
}

View File

@ -31,6 +31,7 @@ dc_descriptor_get_vendor
dc_descriptor_get_product
dc_descriptor_get_type
dc_descriptor_get_model
dc_descriptor_get_transport
dc_parser_new
dc_parser_get_type