feat: add btbonds command

This commit is contained in:
2026-06-21 11:16:12 +02:00
parent c92993a16a
commit e0db67cb79
+36
View File
@@ -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);
}