Skip to content
Snippets Groups Projects
Select Git revision
  • 0f480696246310e80c0af934602808b162ec31e9
  • master default protected
  • deny-not-pairing-fix-secure-simple-pairing
  • code-cleanup
  • v0.2
  • v0.1
6 results

api.h

Blame
  • api.h 1.04 KiB
    #ifndef API_H
    #define API_H
    
    #include <sys/types.h>
    
    #include <cstdint>
    
    namespace blue
    {
    // API result codes
    constexpr uint32_t OP_SUCCESS = 0x0000;
    constexpr uint32_t OP_FAIL    = 0x0001;
    constexpr uint32_t OP_BUSY    = 0x0002;
    
    constexpr size_t MAX_RPC_MSG_SIZE = 4096;
    
    constexpr uint32_t OP_SCAN_START = 0x0001;
    struct msg_scan_reply
    {
    	uint32_t result;
    } __attribute((packed));
    constexpr uint32_t OP_SCAN_ITEM = 0x0002;
    struct msg_scan_item
    {
    	char name[512];
    } __attribute((packed));
    constexpr uint32_t OP_SCAN_DONE = 0x0003;
    struct msg_pair_request
    {
    	char name[512];
    } __attribute((packed));
    constexpr uint32_t OP_PAIR_REQUEST = 0x0004;
    constexpr uint32_t OP_PAIR_START = 0x0005;
    constexpr uint32_t OP_PAIR_UNKNOWN = 0x0006;
    constexpr uint32_t OP_PAIR_ERROR = 0x0007;
    
    struct msg_empty_body {};
    
    struct rpc_msg
    {
    	uint32_t op;
    	union
    	{
    		msg_empty_body empty;
    		msg_scan_reply scan_reply;
    		msg_scan_item scan_item;
    		msg_pair_request pair_request;
    	} body;
    } __attribute((packed));
    static_assert(sizeof(rpc_msg) <= MAX_RPC_MSG_SIZE);
    
    }
    
    #endif // API_H