]> sigrok.org Git - libsigrok.git/commitdiff
bt: drop bt_put_le16() dependency (not universally available)
authorGerhard Sittig <redacted>
Fri, 6 Sep 2019 15:43:05 +0000 (17:43 +0200)
committerGerhard Sittig <redacted>
Sun, 26 Jul 2020 08:47:59 +0000 (10:47 +0200)
Eliminate the dependency on the non-portable bt_put_le16() routine. It
isn't available in all supported BlueZ versions, and won't be available
in other platform backends. Prefer write_u16le() which is available on
all sigrok supported platforms.

configure.ac
src/bt/bt_bluez.c

index 159cf1174306a60f13687e14b45db8539ffbdba3..a8cb4f7077c838e982d571ec4b057839b0bfd07c 100644 (file)
@@ -201,15 +201,6 @@ AM_CONDITIONAL([NEED_RPC], [test "x$sr_cv_have_rpc" = xyes])
 # Check for compiler support of 128 bit integers
 AC_CHECK_TYPES([__int128_t, __uint128_t], [], [], [])
 
-# Availability of bt_put_le16() depends on the bluez library version.
-AC_CACHE_CHECK([for bt_put_le16], [sr_cv_have_btputle16],
-       [AC_LINK_IFELSE([AC_LANG_PROGRAM(
-                       [[#include <bluetooth/bluetooth.h>]],
-                       [[bt_put_le16(0, (void *)0);]])],
-               [sr_cv_have_btputle16=yes], [sr_cv_have_btputle16=no])])
-AS_IF([test "x$sr_cv_have_btputle16" = xyes],
-       [AC_DEFINE([HAVE_BT_PUT_LE16], [1], [Specifies whether we have bt_put_le16().])])
-
 ########################
 ##  Hardware drivers  ##
 ########################
index 52567f9e8b7a04d4cd1d3ca68c55960ed4b8684c..d0a3b7c847605ca2d427fb8e93f9e36eea02ded0 100644 (file)
  * the header doesn't.
  */
 
-#if !defined HAVE_BT_PUT_LE16
-static inline void bt_put_le16(uint16_t v, uint8_t *p)
-{
-       p[0] = (v >> 0) & 0xff;
-       p[1] = (v >> 8) & 0xff;
-}
-#endif
-
 /* }}} compat decls */
 /* {{{ Linux socket specific decls */
 
@@ -898,7 +890,7 @@ SR_PRIV int sr_bt_start_notify(struct sr_bt_desc *desc)
        if (sr_bt_check_socket_usable(desc) < 0)
                return -2;
 
-       bt_put_le16(desc->cccd_value, buf);
+       write_u16le(buf, desc->cccd_value);
        wrlen = sr_bt_char_write_req(desc, desc->cccd_handle, buf, sizeof(buf));
        if (wrlen != sizeof(buf))
                return -2;
@@ -1048,7 +1040,7 @@ static ssize_t sr_bt_write_type_handle_bytes(struct sr_bt_desc *desc,
                return -2;
 
        header[0] = type;
-       bt_put_le16(handle, &header[1]);
+       write_u16le(&header[1], handle);
 
        if (data && len)
                wrlen = writev(desc->fd, iov, ARRAY_SIZE(iov));