- Created an experimental(more c++ & templatized) way to create bluetooth commands

- Add strings for all bluetooth manufacturers
- Add a bunch of strings for each command
- Add methods to get string given a manufacturer code or a command code



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29526 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2009-03-14 17:54:42 +00:00
parent 83458e6d82
commit a7c3c46562
2 changed files with 389 additions and 10 deletions
@@ -7,6 +7,55 @@
#define _COMMAND_MANAGER_H
#include <bluetooth/bluetooth.h>
#include <bluetooth/HCI/btHCI_command.h>
#include <malloc.h>
#include <string.h>
#define typed_command(type) type,sizeof(type)
/* Experimental stack allocated alternative to build commands */
template <typename Type = void, int paramSize = 0, int HeaderSize = HCI_COMMAND_HDR_SIZE>
class BluetoothCommand {
public:
BluetoothCommand(uint8 ogf, uint8 ocf, size_t* outsize)
{
fHeader = (struct hci_command_header*) fBuffer;
if (paramSize != 0)
fContent = (Type*)(fHeader + 1);
else
fContent = (Type*)fHeader; // avoid pointing outside in case of not having parameters
fHeader->opcode = B_HOST_TO_LENDIAN_INT16(PACK_OPCODE(ogf, ocf));
fHeader->clen = paramSize;
*outsize = HeaderSize + paramSize;
}
Type*
operator->() const
{
return fContent;
}
void*
Data() const
{
return (void*)fBuffer;
}
private:
char fBuffer[paramSize + HeaderSize];
Type* fContent;
struct hci_command_header* fHeader;
};
const char* GetCommand(uint16 command);
const char* GetManufacturer(uint16 manufacturer);
/* CONTROL BASEBAND */
void* buildReset(size_t* outsize);