Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rockbox bluetooth interface
/*BLUETOOTH DRIVER FUNCTIONS*/
#define BT_DEVICE_SCAN_MAX_DEVICES 5 /*(64 x 5) 320 bytes*/
#define BT_ADDR_BYTES 18 /*'xx:xx:xx:xx:xx:xx\0'*/
#define BT_NAME_BYTES 32 /*device name*/
#define BT_PIN_BYTES 5 /*0000\0*/
#define BT_RSSI_BYTES 5 /*0000\0*/
struct bluetooth_device
{
char address[BT_ADDR_BYTES];
char name[BT_NAME_BYTES];
char pin[BT_PIN_BYTES];
char rssi[BT_RSSI_BYTES];
int flags;
};
/*
/usr/bin # hcitool -i hci0 scan
Scanning ...
00:00:AB:CD:59:B3 n/a
00:22:94:5F:B6:E2 helo
* */
int bluetooth_init(void)
{
/*hciconfig hci0 up*/
return 0;
}
void bluetooth_scan(struct bluetooth_device *devices, int *ndevices)
{
memset(devices, 0, (size_t) sizeof(struct bluetooth_device) * ndevices);
/* pass an arry of bluetooth_device struct, passed to bluez as --numrsp=ndevices */
/*driver will have to enforce name limits while parsing data */
/* hcitool scan --numrsp=5, hcitool inq --numrsp=5;hcitool name <addr> */
#if 1 /*testing*/
for (int i=0;i < ndevices;i++)
{
strcpy(devices[i]->address, "00:00:00:00:00:00");
strcpy(devices[i]->name, "UNKNOWN");
}
*ndevices = ndevices - 1;
#endif
}
int bluetooth_connect(struct bluetooth_device *device)
{
/* connect perhaps flags can be used to signal auth with pin? */
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment