#ifndef CLASSIC_BLUETOOTH_H #define CLASSIC_BLUETOOTH_H #include #include #include // C++ interface for Classic Bluetooth scanning (wraps IOBluetooth Objective-C API) namespace ClassicBluetooth { // Device class information struct DeviceClass { std::string major_class; // Computer, Phone, Audio, Peripheral, etc. std::string minor_class; // Smartphone, Laptop, Headset, etc. uint32_t class_of_device; // Raw CoD value }; // SDP service record struct SDPService { std::string uuid; // Service UUID std::string name; // Human-readable name (OBEX, SPP, HID, etc.) uint8_t rfcomm_channel; // RFCOMM channel ID (if applicable) }; // Classic Bluetooth device info struct ClassicDevice { std::string address; // MAC address (XX:XX:XX:XX:XX:XX) std::string name; // Device name int16_t rssi; // Signal strength DeviceClass device_class; // Device class info std::vector services; // SDP services bool is_connected; // Connection status bool is_paired; // Pairing status std::string last_seen; // Timestamp }; // Callback for device discovery using DeviceFoundCallback = std::function; using InquiryCompleteCallback = std::function; // Scanner interface class Scanner { public: Scanner(); ~Scanner(); // Start Classic Bluetooth inquiry bool start_inquiry(int duration_seconds = 10); // Stop inquiry void stop_inquiry(); // Check if inquiry is running bool is_scanning() const; // Set callback for when devices are found void set_device_found_callback(DeviceFoundCallback callback); // Set callback for when inquiry completes void set_inquiry_complete_callback(InquiryCompleteCallback callback); // Perform SDP query on a specific device std::vector query_sdp_services(const std::string& address); // Get device class information DeviceClass get_device_class(const std::string& address); // Get all discovered devices (synchronous, for one-shot queries) std::vector get_discovered_devices(); private: class Impl; // Forward declaration for PIMPL Impl* pImpl; // Pointer to implementation (hides Objective-C from C++ header) }; // Utility functions std::string decode_device_class_major(uint32_t cod); std::string decode_device_class_minor(uint32_t cod); std::string decode_service_uuid(const std::string& uuid); } // namespace ClassicBluetooth #endif // CLASSIC_BLUETOOTH_H