subrascasse

Sub Rascasse: an iPhone dive log for Subsurface cloud storage, with a pure-Swift git client (GPL-2.0)
git clone https://git.schurger.org/subrascasse.git
Log | Files | Refs | README | LICENSE

bluetooth.h (4052B)


      1 /*
      2  * libdivecomputer
      3  *
      4  * Copyright (C) 2013 Jef Driesen
      5  *
      6  * This library is free software; you can redistribute it and/or
      7  * modify it under the terms of the GNU Lesser General Public
      8  * License as published by the Free Software Foundation; either
      9  * version 2.1 of the License, or (at your option) any later version.
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU Lesser General Public
     17  * License along with this library; if not, write to the Free Software
     18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
     19  * MA 02110-1301 USA
     20  */
     21 
     22 #ifndef DC_BLUETOOTH_H
     23 #define DC_BLUETOOTH_H
     24 
     25 #include "common.h"
     26 #include "context.h"
     27 #include "iostream.h"
     28 #include "iterator.h"
     29 #include "descriptor.h"
     30 
     31 #ifdef __cplusplus
     32 extern "C" {
     33 #endif /* __cplusplus */
     34 
     35 /**
     36  * The minimum number of bytes (including the terminating null byte) for
     37  * formatting a bluetooth address as a string.
     38  */
     39 #define DC_BLUETOOTH_SIZE 18
     40 
     41 /**
     42  * Bluetooth address (48 bits).
     43  */
     44 #if defined (_WIN32) && !defined (__GNUC__)
     45 typedef unsigned __int64 dc_bluetooth_address_t;
     46 #else
     47 typedef unsigned long long dc_bluetooth_address_t;
     48 #endif
     49 
     50 /**
     51  * Convert a bluetooth address to a string.
     52  *
     53  * The bluetooth address is formatted as XX:XX:XX:XX:XX:XX, where each
     54  * XX is a hexadecimal number specifying an octet of the 48-bit address.
     55  * The minimum size for the buffer is #DC_BLUETOOTH_SIZE bytes.
     56  *
     57  * @param[in]  address  A bluetooth address.
     58  * @param[in]  str      The memory buffer to store the result.
     59  * @param[in]  size     The size of the memory buffer.
     60  * @returns The null-terminated string on success, or NULL on failure.
     61  */
     62 char *
     63 dc_bluetooth_addr2str(dc_bluetooth_address_t address, char *str, size_t size);
     64 
     65 /**
     66  * Convert a string to a bluetooth address.
     67  *
     68  * The string is expected to be in the format XX:XX:XX:XX:XX:XX, where
     69  * each XX is a hexadecimal number specifying an octet of the 48-bit
     70  * address.
     71  *
     72  * @param[in]  address  A null-terminated string.
     73  * @returns The bluetooth address on success, or zero on failure.
     74  */
     75 dc_bluetooth_address_t
     76 dc_bluetooth_str2addr(const char *address);
     77 
     78 /**
     79  * Opaque object representing a bluetooth device.
     80  */
     81 typedef struct dc_bluetooth_device_t dc_bluetooth_device_t;
     82 
     83 /**
     84  * Get the address of the bluetooth device.
     85  *
     86  * @param[in]  device  A valid bluetooth device.
     87  */
     88 dc_bluetooth_address_t
     89 dc_bluetooth_device_get_address (dc_bluetooth_device_t *device);
     90 
     91 /**
     92  * Get the name of the bluetooth device.
     93  *
     94  * @param[in]  device  A valid bluetooth device.
     95  */
     96 const char *
     97 dc_bluetooth_device_get_name (dc_bluetooth_device_t *device);
     98 
     99 /**
    100  * Destroy the bluetooth device and free all resources.
    101  *
    102  * @param[in]  device  A valid bluetooth device.
    103  */
    104 void
    105 dc_bluetooth_device_free (dc_bluetooth_device_t *device);
    106 
    107 /**
    108  * Create an iterator to enumerate the bluetooth devices.
    109  *
    110  * @param[out] iterator    A location to store the iterator.
    111  * @param[in]  context     A valid context object.
    112  * @param[in]  descriptor  A valid device descriptor or NULL.
    113  * @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
    114  * on failure.
    115  */
    116 dc_status_t
    117 dc_bluetooth_iterator_new (dc_iterator_t **iterator, dc_context_t *context, dc_descriptor_t *descriptor);
    118 
    119 /**
    120  * Open an bluetooth connection.
    121  *
    122  * @param[out]  iostream   A location to store the bluetooth connection.
    123  * @param[in]   context    A valid context object.
    124  * @param[in]   address    The bluetooth device address.
    125  * @param[in]   port       The bluetooth port number.
    126  * @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
    127  * on failure.
    128  */
    129 dc_status_t
    130 dc_bluetooth_open (dc_iostream_t **iostream, dc_context_t *context, dc_bluetooth_address_t address, unsigned int port);
    131 
    132 #ifdef __cplusplus
    133 }
    134 #endif /* __cplusplus */
    135 #endif /* DC_BLUETOOTH_H */