bta_sdp.cc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /******************************************************************************
  2. *
  3. * Copyright 2014 The Android Open Source Project
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at:
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. ******************************************************************************/
  17. /******************************************************************************
  18. *
  19. * This is the main implementation file for the BTA MCE I/F
  20. *
  21. ******************************************************************************/
  22. #include <stdlib.h>
  23. #include "bta_api.h"
  24. #include "bta_sdp_api.h"
  25. #include "bta_sdp_int.h"
  26. #include "bta_sys.h"
  27. /*****************************************************************************
  28. * Constants and types
  29. ****************************************************************************/
  30. tBTA_SDP_CB bta_sdp_cb;
  31. /* state machine action enumeration list */
  32. #define BTA_SDP_NUM_ACTIONS (BTA_SDP_MAX_INT_EVT & 0x00ff)
  33. /* type for action functions */
  34. typedef void (*tBTA_SDP_ACTION)(tBTA_SDP_MSG* p_data);
  35. /* action function list */
  36. const tBTA_SDP_ACTION bta_sdp_action[] = {
  37. bta_sdp_enable, /* BTA_SDP_API_ENABLE_EVT */
  38. bta_sdp_search, /* BTA_SDP_API_SEARCH_EVT */
  39. bta_sdp_create_record, /* BTA_SDP_API_CREATE_RECORD_USER_EVT */
  40. bta_sdp_remove_record, /* BTA_SDP_API_REMOVE_RECORD_USER_EVT */
  41. };
  42. /*******************************************************************************
  43. * Function bta_sdp_sm_execute
  44. *
  45. * Description State machine event handling function for SDP search
  46. *
  47. * Returns void
  48. ******************************************************************************/
  49. bool bta_sdp_sm_execute(BT_HDR* p_msg) {
  50. if (p_msg == NULL) return false;
  51. bool ret = false;
  52. uint16_t action = (p_msg->event & 0x00ff);
  53. /* execute action functions */
  54. if (action < BTA_SDP_NUM_ACTIONS) {
  55. (*bta_sdp_action[action])((tBTA_SDP_MSG*)p_msg);
  56. ret = true;
  57. }
  58. return (ret);
  59. }