btif_spp.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2016 Actions Semi Co., Inc.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief bt spp interface
  9. */
  10. #define SYS_LOG_DOMAIN "btif_spp"
  11. #include "btsrv_os_common.h"
  12. #include "btsrv_inner.h"
  13. int btif_spp_register_processer(void)
  14. {
  15. return btsrv_register_msg_processer(MSG_BTSRV_SPP, &btsrv_spp_process);
  16. }
  17. int btif_spp_reg(struct bt_spp_reg_param *param)
  18. {
  19. if (!param || !param->app_id || !param->uuid) {
  20. return -EINVAL;
  21. }
  22. return btsrv_function_call_malloc(MSG_BTSRV_SPP, MSG_BTSRV_SPP_REGISTER, (void *)param, sizeof(struct bt_spp_reg_param), 0);
  23. }
  24. int btif_spp_send_data(uint8_t app_id, uint8_t *data, uint32_t len)
  25. {
  26. return btsrv_spp_send_data(app_id, data, len);
  27. }
  28. int btif_spp_connect(struct bt_spp_connect_param *param)
  29. {
  30. if (!param->app_id || !param->uuid) {
  31. return -EINVAL;
  32. }
  33. return btsrv_function_call_malloc(MSG_BTSRV_SPP, MSG_BTSRV_SPP_CONNECT, (void *)param, sizeof(struct bt_spp_connect_param), 0);
  34. }
  35. int btif_spp_disconnect(uint8_t app_id)
  36. {
  37. int id = app_id;
  38. return btsrv_function_call(MSG_BTSRV_SPP, MSG_BTSRV_SPP_DISCONNECT, (void *)id);
  39. }
  40. int btif_spp_start(btsrv_spp_callback cb)
  41. {
  42. return btsrv_function_call(MSG_BTSRV_SPP, MSG_BTSRV_SPP_START, cb);
  43. }
  44. int btif_spp_stop(void)
  45. {
  46. return btsrv_function_call(MSG_BTSRV_SPP, MSG_BTSRV_SPP_STOP, NULL);
  47. }
  48. int btif_spp_sdp_restore(void)
  49. {
  50. return btsrv_function_call(MSG_BTSRV_SPP, MSG_BTSRV_SPP_SDP_SERVICE_RESTORE, NULL);
  51. }