yongli3 / libgatt

GATT lib for Bluez 5.40
GNU General Public License v2.0
3 stars 0 forks source link

about the test.c #1

Open kengdehenkeng opened 8 years ago

kengdehenkeng commented 8 years ago

hello I want to write bits in the particular uuid, where should I change in the test.c? the MAC, UUID, write_data?

yongli3 commented 8 years ago

Which bits do you want to change? Could you share more information? Such as an code snippet or use-case?

kengdehenkeng commented 8 years ago

0xFFFFFF in to 0x0027

kengdehenkeng commented 8 years ago

for example gatttool -b 00:15:83:00:6B:08 --char-write-req -a 0x25 -n 0x31 like this code in test.c 0x25 is the UUID and 0x31 is the write_data, right? and where is the UUID and write_data in the test.c?

yongli3 commented 8 years ago

You can set the opt_handle = 0x25, and opt_value="0x31", then call characteristics_write_req. Or BLE_init/send API

kengdehenkeng commented 8 years ago

sorry, i am confussed. I want to write 0xFFFFFF in to 0x0027 and when I code like gatttool -b 'my MAC' --char-write-req -a 0x0027 -n 0xFFFFFF it worked, but the the type of 'opt_handle' is int, 0x0027 is larger than int so, if I want to write 0xFFFFFF in to 0x0027, what should I do? thx

yongli3 commented 8 years ago

In "-a 0x0027 -n 0xFFFFFF", the opt_handle=0x27 is an int(not larger than int), and opt_value="0xFFFFFF" is a char *

kengdehenkeng commented 8 years ago

in your code chan = gatt_connect(NULL, "00:15:83:00:6B:08s", g_strdup("public"), g_strdup("low"), 0, 0, connect_cb, &gerr); is that right? There is a 's' at the end of MAC

and I changed your code

static int opt_handle =0x27; static char *opt_value = "0xFFFFFF"; chan = gatt_connect(NULL, "my MAC s", g_strdup("public"), g_strdup("low"), 0, 0, connect_cb, &gerr);

and run test.c

it shows like this bluetoothd[10151]: +gatt_connect psm=0 bluetoothd[10151]: l2cap_connect sock=4 cid=0x4 dst_type=1 bluetoothd[10151]: -l2cap_connect bluetoothd[10151]: Connected! bluetoothd[10151]: +connect_cb connect_cb sock=4 bluetoothd[10151]: gatt_write_char value=0x0 bluetoothd[10151]: -connect_cb

and stop here.

Thx

yongli3 commented 8 years ago

Please check the BLE_init/BLE_send, the 's' as the end of MAC is a typo

kengdehenkeng commented 8 years ago

sorry, I can't get your point, I have not know the BLE a lot. I just want to connect my device and sent 0xFFFFFF to 0x0027 could you tell me what should I do?

yongli3 commented 8 years ago

Please check the BLE_init and BLE_send, change the 0x25 to 0x27, and 0x31/0x30 to 0xFFFFFF

kengdehenkeng commented 8 years ago

where is BLE_init? and I changed it but it shows like this bluetoothd[10151]: +gatt_connect psm=0 bluetoothd[10151]: l2cap_connect sock=4 cid=0x4 dst_type=1 bluetoothd[10151]: -l2cap_connect bluetoothd[10151]: Connected! bluetoothd[10151]: +connect_cb connect_cb sock=4 bluetoothd[10151]: gatt_write_char value=0x0 bluetoothd[10151]: -connect_cb

and stop here.

yongli3 commented 8 years ago

git pull to get the BLE_init, it is in the gatttool.c file

kengdehenkeng commented 8 years ago

hello no it shows like this: connect_cb error: Transport endpoint is not connected (107)

yongli3 commented 8 years ago

use the hciconfig tool to check if hci0 is okay ?

kengdehenkeng commented 8 years ago

it shows : hci0: Type: BR/EDR Bus: UART BD Address: B8:27:EB:B9:8F:44 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING RX bytes:2601 acl:19 sco:0 events:167 errors:0 TX bytes:5420 acl:19 sco:0 commands:112 errors:0