feat: introduce bootloader-agnostic Boot Contract, add btlist command to list connected Bluetooth devices
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* main.cpp
|
||||
* uses the bt_list syscall to output a list of connected 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::BtDevInfo devices[64] = { };
|
||||
int n = montauk::bt_list(devices, 64);
|
||||
|
||||
if (n <= 0) {
|
||||
montauk::print("No Bluetooth devices are currently connected. For a list of paired devices, use 'btbonds'.\n");
|
||||
montauk::exit(0);
|
||||
}
|
||||
|
||||
montauk::print(" MAC addr. Encrypted\n");
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
char macAddrString[18] = {};
|
||||
addr_to_string(macAddrString, devices[i].bdAddr);
|
||||
|
||||
printf(" %-17s %s\n", macAddrString, devices[i].encrypted ? "True" : "False");
|
||||
}
|
||||
|
||||
montauk::exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user