91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 29.87MB
    文件類型: .gz
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-07-16
  • 語(yǔ)言: C/C++
  • 標(biāo)簽: ble??c語(yǔ)言??

資源簡(jiǎn)介

由于bluez并沒(méi)有提供官方可用的C語(yǔ)言 gatt庫(kù),所以我對(duì)源碼結(jié)構(gòu)做了些修改,把用到的ap編譯成靜態(tài)庫(kù),使用前閱讀readme.txt 詳情參考https://blog.csdn.net/u010659887/article/details/85329276

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?


#include?“bluetooth/bluetooth.h“
#include?“bluetooth/l2cap.h“
#include?“bluetooth/hci.h“
#include?“bluetooth/hci_lib.h“
#include?“bluetooth/sdp.h“

#include?“uuid.h“
#include?“src/shared/mainloop.h“
#include?“src/shared/util.h“
#include?“src/shared/att.h“
#include?“src/shared/queue.h“
#include?“src/shared/gatt-db.h“
#include?“src/shared/gatt-client.h“


#define?COLOR_OFF “\x1B[0m“
#define?COLOR_RED “\x1B[0;91m“
#define?COLOR_GREEN “\x1B[0;92m“
#define?COLOR_YELLOW “\x1B[0;93m“
#define?COLOR_BLUE “\x1B[0;94m“
#define?COLOR_MAGENTA “\x1B[0;95m“
#define?COLOR_BOLDGRAY “\x1B[1;30m“
#define?COLOR_BOLDWHITE “\x1B[1;37m“

#define?ATT_CID?4

struct?client?{
int?fd;
struct?bt_att?*att;
struct?gatt_db?*db;
struct?bt_gatt_client?*gatt;

unsigned?int?reliable_session_id;
};
//打印UUID
static?void?print_uuid(const?bt_uuid_t?*uuid)
{
char?uuid_str[MAX_LEN_UUID_STR];
bt_uuid_t?uuid128;

bt_uuid_to_uuid128(uuid?&uuid128);
bt_uuid_to_string(&uuid128?uuid_str?sizeof(uuid_str));

printf(“%s\n“?uuid_str);
}

static?void?print_prompt(void)
{
printf(COLOR_BLUE?“[GATT?client]“?COLOR_OFF?“#?“);
fflush(stdout);
}
static?void?print_incl(struct?gatt_db_attribute?*attr?void?*user_data)
{
struct?client?*cli?=?user_data;
uint16_t?handle?start?end;
struct?gatt_db_attribute?*service;
bt_uuid_t?uuid;

if?(!gatt_db_attribute_get_incl_data(attr?&handle?&start?&end))
return;

service?=?gatt_db_get_attribute(cli->db?start);
if?(!service)
return;

gatt_db_attribute_get_service_uuid(service?&uuid);

printf(“\t??“?COLOR_GREEN?“include“?COLOR_OFF?“?-?handle:?“
“0x%04x?-?start:?0x%04x?end:?0x%04x“
“uuid:?“?handle?start?end);
print_uuid(&uuid);
}
static?void?print_desc(struct?gatt_db_attribute?*attr?void?*user_data)
{
printf(“\t\t??“?COLOR_MAGENTA?“descr“?COLOR_OFF
“?-?handle:?0x%04x?uuid:?“
gatt_db_attribute_get_handle(attr));
print_uuid(gatt_db_attribute_get_type(attr));
}
static?void?print_chrc(struct?gatt_db_attribute?*attr?void?*user_data)
{
uint16_t?handle?value_handle;
uint8_t?properties;
uint16_t?ext_prop;
bt_uuid_t?uuid;

if?(!gatt_db_attribute_get_char_data(attr?&handle
&value_handle
&properties
&ext_prop
&uuid))
return;

printf(“\t??“?COLOR_YELLOW?“charac“?COLOR_OFF
“?-?start:?0x%04x?value:?0x%04x?“
“props:?0x%02x?ext_props:?0x%04x?uuid:?“
handle?value_handle?properties?ext_prop);
print_uuid(&uuid);

gatt_db_service_foreach_desc(attr?print_desc?NULL);
}
//打印改變的service
static?void?print_service(struct?gatt_db_attribute?*attr?void?*user_data)
{
struct?client?*cli?=?user_data;
uint16_t?start?end;
bool?primary;
bt_uuid_t?uuid;

if?(!gatt_db

評(píng)論

共有 條評(píng)論

相關(guān)資源