Skip to content

Commit

Permalink
mobileOS: kernel[bluetooth(device)]
Browse files Browse the repository at this point in the history
  • Loading branch information
krishpranav committed Nov 2, 2023
1 parent d338eb9 commit 83e3954
Showing 1 changed file with 76 additions and 1 deletion.
77 changes: 76 additions & 1 deletion mobileOS/kernel/bluetooth/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,80 @@ struct Device
*/
void setName(const std::string& name)
{
if(name.size() > NameBufferSize)
{
throw std::runtime_error("Requested name is bigger than buffer size");
}

strcpy(this->name.data(), name.c_str());
}
};

enum DEVICE_STATE
{
REMOTE_NAME_REQUEST,
REMOTE_NAME_INQUIRED,
REMOTE_NAME_FETCHED,
REMOTE_NAME_FAILURE,
};

namespace TYPE_OF_SERVICE
{
inline constexpr uint32_t POSITIONING = 0x00010000;
inline constexpr uint32_t NETWORKING = 0x00020000;
inline constexpr uint32_t RENDERING = 0x00040000;
inline constexpr uint32_t CAPTURING = 0x00080000;
inline constexpr uint32_t OBJECT_TRANSFER = 0x00100000;
inline constexpr uint32_t AUDIO = 0x00200000;
inline constexpr uint32_t TELEPHONY = 0x00400000;
inline constexpr uint32_t INFORMATION = 0x00800000;

inline constexpr uint32_t REMOTE_SUPPORTED_SERVICES = (AUDIO | POSITIONING | RENDERING);
} // namespace TYPE_OF_SERVICE

/**
* @param cod
* @return std::string
*/
static inline std::string getListOfSupportedServicesInString(uint32_t cod)
{
std::string res = "|";

if(cod & TYPE_OF_SERVICE::POSITIONING)
{
res += "POSITIONING|";
}
if(cod & TYPE_OF_SERVICE::NETWORKING)
{
res += "NETWORKING|";
}
if(cod & TYPE_OF_SERVICE::RENDERING)
{
res += "RENDERING|";
}
if(cod & TYPE_OF_SERVICE::CAPTURING)
{
res += "CAPTURING|";
}
if(cod & TYPE_OF_SERVICE::OBJECT_TRANSFER)
{
res += "OBJECT_TRANSFER|";
}
if(cod & TYPE_OF_SERVICE::AUDIO)
{
res += "AUDIO|";
}
if(cod & TYPE_OF_SERVICE::TELEPHONY)
{
res += "TELEPHONY|";
}
if(cod & TYPE_OF_SERVICE::INFORMATION)
{
res += "INFORMATION|";
}
if(res == std::string("|"))
{
res += "NONE|";
}
};
return res;
}

0 comments on commit 83e3954

Please sign in to comment.