bluetooth_poll.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /****************************************************************************
  2. * net/bluetooth/bluetooth_poll.c
  3. * Poll for the availability of ougoing Bluetooth frames
  4. *
  5. * Copyright (C) 2018 Gregory Nutt. All rights reserved.
  6. * Author: Gregory Nutt <gnutt@nuttx.org>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. The name of the author may not be used to endorse or promote
  18. * products derived from this software without specific prior
  19. * written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  22. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  25. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  27. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ****************************************************************************/
  34. /****************************************************************************
  35. * Included Files
  36. ****************************************************************************/
  37. #include <nuttx/config.h>
  38. #include <assert.h>
  39. #include <debug.h>
  40. #include <nuttx/net/netconfig.h>
  41. #include <nuttx/net/radiodev.h>
  42. #include <nuttx/net/bluetooth.h>
  43. #include "devif/devif.h"
  44. #include "bluetooth/bluetooth.h"
  45. #ifdef CONFIG_NET_BLUETOOTH
  46. /****************************************************************************
  47. * Public Functions
  48. ****************************************************************************/
  49. /****************************************************************************
  50. * Name: bluetooth_poll
  51. *
  52. * Description:
  53. * Poll a packet "connection" structure for availability of TX data
  54. *
  55. * Input Parameters:
  56. * dev - The device driver structure to use in the send operation
  57. * conn - The packet "connection" to poll for TX data
  58. *
  59. * Returned Value:
  60. * None
  61. *
  62. * Assumptions:
  63. * The network is locked.
  64. *
  65. ****************************************************************************/
  66. void bluetooth_poll(FAR struct net_driver_s *dev,
  67. FAR struct bluetooth_conn_s *conn)
  68. {
  69. FAR struct radio_driver_s *radio;
  70. DEBUGASSERT(dev != NULL && conn != NULL);
  71. radio = (FAR struct radio_driver_s *)dev;
  72. /* Verify that the packet connection is valid */
  73. if (conn != NULL)
  74. {
  75. /* Setup for the application callback (NOTE: These should not be
  76. * used by PF_BLUETOOTH sockets).
  77. */
  78. radio->r_dev.d_appdata = radio->r_dev.d_buf;
  79. radio->r_dev.d_len = 0;
  80. radio->r_dev.d_sndlen = 0;
  81. /* Perform the application callback.
  82. *
  83. * REVISIT: Need to pass the meta data and the IOB through the callback
  84. */
  85. #warning Missing logic
  86. /* Perform the application callback */
  87. (void)bluetooth_callback(radio, conn, BLUETOOTH_POLL);
  88. }
  89. }
  90. #endif /* CONFIG_NET && CONFIG_NET_PKT */