mirror of
https://github.com/isometimes/rpi4-osdev
synced 2024-11-22 02:00:40 +00:00
Notifications working for ATT characteristic
This commit is contained in:
parent
8d1a7750f1
commit
b2ae702c48
3 changed files with 12 additions and 11 deletions
|
@ -194,18 +194,18 @@ void bt_getbdaddr(unsigned char *bdaddr) {
|
|||
for (int c=0;c<6;c++) bdaddr[c] = bt_waitReadByte();
|
||||
}
|
||||
|
||||
void sendACLreadreq(unsigned int handle)
|
||||
void sendACLsubscribe(unsigned int handle)
|
||||
{
|
||||
bt_writeByte(HCI_ACL_PKT);
|
||||
|
||||
bt_writeByte(lo(handle));
|
||||
bt_writeByte(hi(handle));
|
||||
|
||||
unsigned int length = 0x0007;
|
||||
unsigned int length = 0x0009;
|
||||
bt_writeByte(lo(length));
|
||||
bt_writeByte(hi(length));
|
||||
|
||||
unsigned int data_length = 0x0003;
|
||||
unsigned int data_length = 0x0005;
|
||||
bt_writeByte(lo(data_length));
|
||||
bt_writeByte(hi(data_length));
|
||||
|
||||
|
@ -213,7 +213,7 @@ void sendACLreadreq(unsigned int handle)
|
|||
bt_writeByte(lo(channel));
|
||||
bt_writeByte(hi(channel));
|
||||
|
||||
unsigned char params[] = { 0x0a, 0x2a, 0x00 };
|
||||
unsigned char params[] = { 0x12, 0x2b, 0x00, 0x01, 0x00 };
|
||||
|
||||
unsigned int c=0;
|
||||
while (c++<data_length) bt_writeByte(params[c-1]);
|
||||
|
|
|
@ -13,4 +13,4 @@ void stopScanning();
|
|||
void startActiveAdvertising();
|
||||
void connect(unsigned char *addr);
|
||||
void bt_flushrx();
|
||||
void sendACLreadreq(unsigned int handle);
|
||||
void sendACLsubscribe(unsigned int handle);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "io.h"
|
||||
#include "bt.h"
|
||||
#include "fb.h"
|
||||
|
||||
#define memcmp __builtin_memcmp
|
||||
|
||||
|
@ -176,11 +175,13 @@ void acl_poll()
|
|||
|
||||
length = data[0] | (data[1] << 8);
|
||||
|
||||
unsigned int channel = data[2] | (data[3] << 8);
|
||||
|
||||
unsigned int channel = data[2] | (data[3] << 8);
|
||||
unsigned char opcode = data[4];
|
||||
if (opcode == 0x0b) {
|
||||
for (int c=0;c<length-1;c++) uart_byte(data[5+c]);
|
||||
|
||||
if (opcode == 0x1b) {
|
||||
unsigned int from_handle = data[5] | (data[6] << 8);
|
||||
|
||||
for (int c=0;c<length-3;c++) uart_byte(data[7+c]);
|
||||
uart_writeText("\n");
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +223,7 @@ void main()
|
|||
// Get the characteristic value
|
||||
uart_writeText("Sending read request: ");
|
||||
uart_hex(connection_handle); uart_writeText("\n");
|
||||
sendACLreadreq(connection_handle);
|
||||
sendACLsubscribe(connection_handle);
|
||||
|
||||
// Into the main infinite loop
|
||||
uart_writeText("Waiting for input...\n");
|
||||
|
|
Loading…
Reference in a new issue