feat: add btbonds command
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* main.cpp
|
||||||
|
* uses the bt_bonds syscall to output a list of paired (bonded) Bluetooth devices.
|
||||||
|
* Copyright (c) 2026 Daniel Hammer
|
||||||
|
*/
|
||||||
|
#include <montauk/syscall.h>
|
||||||
|
#include <libc/stdio.h>
|
||||||
|
|
||||||
|
const char* addr_to_string(char* str, uint8_t* bdAddr) {
|
||||||
|
snprintf(str, 18, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
|
bdAddr[0], bdAddr[1], bdAddr[2], bdAddr[3], bdAddr[4], bdAddr[5]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (const char*)str;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void _start() {
|
||||||
|
montauk::abi::BtBondInfo devices[64] = { };
|
||||||
|
int n = montauk::bt_bonds(devices, 64);
|
||||||
|
|
||||||
|
if (n <= 0) {
|
||||||
|
montauk::print("No paired Bluetooth devices.\n");
|
||||||
|
montauk::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
montauk::print(" MAC addr.\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
char macAddrString[18] = {};
|
||||||
|
addr_to_string(macAddrString, devices[i].bdAddr);
|
||||||
|
|
||||||
|
printf(" %-17s\n", macAddrString);
|
||||||
|
}
|
||||||
|
|
||||||
|
montauk::exit(0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user