bt_sock.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: Apache-2.0 */
  2. /*
  3. * Copyright (C) 2012 The Android Open Source Project
  4. *
  5. */
  6. #ifndef ANDROID_INCLUDE_BT_SOCK_H
  7. #define ANDROID_INCLUDE_BT_SOCK_H
  8. __BEGIN_DECLS
  9. #define BTSOCK_FLAG_ENCRYPT 1
  10. #define BTSOCK_FLAG_AUTH (1 << 1)
  11. typedef enum {
  12. BTSOCK_RFCOMM = 1,
  13. BTSOCK_SCO = 2,
  14. BTSOCK_L2CAP = 3
  15. } btsock_type_t;
  16. /** Represents the standard BT SOCKET interface. */
  17. typedef struct {
  18. short size;
  19. bt_bdaddr_t bd_addr;
  20. int channel;
  21. int status;
  22. } __attribute__((packed)) sock_connect_signal_t;
  23. typedef struct {
  24. /** set to size of this struct*/
  25. size_t size;
  26. /**
  27. * listen to a rfcomm uuid or channel. It returns the socket fd from which
  28. * btsock_connect_signal can be read out when a remote device connected
  29. */
  30. bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
  31. /*
  32. * connect to a rfcomm uuid channel of remote device, It returns the socket fd from which
  33. * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected
  34. */
  35. bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid, int channel, int* sock_fd, int flags);
  36. } btsock_interface_t;
  37. __END_DECLS
  38. #endif /* ANDROID_INCLUDE_BT_SOCK_H */