mirror of https://github.com/labapart/gattlib
include/gattlib.h: Remove dependency on glib.h
parent
ebe4e57591
commit
076067a2d7
|
@ -282,7 +282,7 @@ static BtIOSecLevel get_bt_io_sec_level(gattlib_bt_sec_level_t sec_level) {
|
|||
}
|
||||
}
|
||||
|
||||
gatt_connection_t *gattlib_connect_async(const gchar *src, const gchar *dst,
|
||||
gatt_connection_t *gattlib_connect_async(const char *src, const char *dst,
|
||||
uint8_t dest_type, gattlib_bt_sec_level_t sec_level, int psm, int mtu,
|
||||
gatt_connect_cb_t connect_cb)
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ static gboolean connection_timeout(gpointer user_data) {
|
|||
* @param psm Specify the PSM for GATT/ATT over BR/EDR
|
||||
* @param mtu Specify the MTU size
|
||||
*/
|
||||
gatt_connection_t *gattlib_connect(const gchar *src, const gchar *dst,
|
||||
gatt_connection_t *gattlib_connect(const char *src, const char *dst,
|
||||
uint8_t dest_type, gattlib_bt_sec_level_t sec_level, int psm, int mtu)
|
||||
{
|
||||
BtIOSecLevel bt_io_sec_level = get_bt_io_sec_level(sec_level);
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#ifndef __GATTLIB_INTERNAL_H__
|
||||
#define __GATTLIB_INTERNAL_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#define BLUEZ_VERSIONS(major, minor) (((major) << 8) | (minor))
|
||||
#define BLUEZ_VERSION BLUEZ_VERSIONS(BLUEZ_VERSION_MAJOR, BLUEZ_VERSION_MINOR)
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#
|
||||
#
|
||||
# GattLib - GATT Library
|
||||
#
|
||||
# Copyright (C) 2016-2017 Olivier Martin <olivier@labapart.org>
|
||||
|
@ -25,8 +24,31 @@ cmake_minimum_required(VERSION 2.6)
|
|||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_search_module(GATTLIB REQUIRED gattlib)
|
||||
pkg_search_module(GLIB REQUIRED glib-2.0)
|
||||
|
||||
include_directories(${GLIB_INCLUDE_DIRS})
|
||||
|
||||
#
|
||||
# Add Bluetooth support: Workaround as the current 'gatttool' example
|
||||
# is still based on 'bluez' code
|
||||
#
|
||||
pkg_search_module(BLUEZ REQUIRED bluez)
|
||||
|
||||
# Extract Bluez version
|
||||
string(REPLACE "." ";" BLUEZ_VERSIONS "${BLUEZ_VERSION}")
|
||||
list(GET BLUEZ_VERSIONS 0 BLUEZ_VERSION_MAJOR)
|
||||
list(GET BLUEZ_VERSIONS 1 BLUEZ_VERSION_MINOR)
|
||||
add_definitions(-DBLUEZ_VERSION_MAJOR=${BLUEZ_VERSION_MAJOR} -DBLUEZ_VERSION_MINOR=${BLUEZ_VERSION_MINOR})
|
||||
|
||||
if(BLUEZ_VERSION_MAJOR STREQUAL "4")
|
||||
set(bluez4_DIR ${CMAKE_SOURCE_DIR}/bluez/bluez4)
|
||||
include_directories(${bluez4_DIR}/attrib ${bluez4_DIR}/btio ${bluez4_DIR}/src ${bluez4_DIR}/lib)
|
||||
else()
|
||||
set(bluez5_DIR ${CMAKE_SOURCE_DIR}/bluez/bluez5)
|
||||
include_directories(${bluez5_DIR} ${bluez5_DIR}/attrib ${bluez5_DIR}/btio ${bluez5_DIR}/lib)
|
||||
endif()
|
||||
|
||||
set(gatttool_SRCS gatttool.c interactive.c utils.c)
|
||||
|
||||
add_executable(gatttool ${gatttool_SRCS})
|
||||
target_link_libraries(gatttool ${GATTLIB_LIBRARIES} readline)
|
||||
target_link_libraries(gatttool ${GATTLIB_LIBRARIES} ${GLIB_LIBRARIES} readline)
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "gattlib.h"
|
||||
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
#define NUS_CHARACTERISTIC_TX_UUID "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
|
||||
#define NUS_CHARACTERISTIC_RX_UUID "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
|
@ -61,7 +60,7 @@ typedef struct _GAttrib GAttrib;
|
|||
typedef void (*gattlib_event_handler_t)(uint16_t handle, const uint8_t* data, size_t data_length, void* user_data);
|
||||
|
||||
typedef struct _gatt_connection_t {
|
||||
GIOChannel *io;
|
||||
void *io; // Mapped to 'GIOChannel*' when using Glib
|
||||
|
||||
GAttrib *attrib;
|
||||
|
||||
|
@ -83,10 +82,10 @@ typedef void* (*gatt_read_cb_t)(void* buffer, size_t buffer_len);
|
|||
* @param psm Specify the PSM for GATT/ATT over BR/EDR
|
||||
* @param mtu Specify the MTU size
|
||||
*/
|
||||
gatt_connection_t *gattlib_connect(const gchar *src, const gchar *dst,
|
||||
gatt_connection_t *gattlib_connect(const char *src, const char *dst,
|
||||
uint8_t dest_type, gattlib_bt_sec_level_t sec_level, int psm, int mtu);
|
||||
|
||||
gatt_connection_t *gattlib_connect_async(const gchar *src, const gchar *dst,
|
||||
gatt_connection_t *gattlib_connect_async(const char *src, const char *dst,
|
||||
uint8_t dest_type, gattlib_bt_sec_level_t sec_level, int psm, int mtu,
|
||||
gatt_connect_cb_t connect_cb);
|
||||
|
||||
|
|
Loading…
Reference in New Issue