#include #include #include #include "Bluetooth.h" namespace trygvis { using namespace std; // ----------------------------------------------------------------------- // Mac // ----------------------------------------------------------------------- string Mac::str() const { std::ostringstream buf; buf << setw(2) << hex << setfill('0') << (int)bytes[5] << ":" << setw(2) << hex << setfill('0') << (int)bytes[4] << ":" << setw(2) << hex << setfill('0') << (int)bytes[3] << ":" << setw(2) << hex << setfill('0') << (int)bytes[2] << ":" << setw(2) << hex << setfill('0') << (int)bytes[1] << ":" << setw(2) << hex << setfill('0') << (int)bytes[0]; return buf.str(); } bool Mac::operator==(Mac &other) const { return memcmp(bytes, other.bytes, sizeof(bytes)) == 0; } void Mac::copy(uint8_t &_0, uint8_t &_1, uint8_t &_2, uint8_t &_3, uint8_t &_4, uint8_t &_5) const { _0 = bytes[0]; _1 = bytes[1]; _2 = bytes[2]; _3 = bytes[3]; _4 = bytes[4]; _5 = bytes[5]; } Mac *Mac::parseMac(string s) { uint8_t bytes[6]; sscanf("%02x:%02x:%02x:%02x:%02x:%02x", s.c_str(), &bytes[0], &bytes[1], &bytes[2], &bytes[3], &bytes[4], &bytes[5]); return new Mac(bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5]); } // ----------------------------------------------------------------------- // Adapter // ----------------------------------------------------------------------- BluetoothAdapter::~BluetoothAdapter() { } };