mesh_common.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /** @file
  7. * @brief Bluetooth Mesh Model Common APIs.
  8. */
  9. #ifndef _BLE_MESH_COMMON_H_
  10. #define _BLE_MESH_COMMON_H_
  11. #include <stddef.h>
  12. #include <stdlib.h>
  13. #include "esp_attr.h"
  14. #include "esp_heap_caps.h"
  15. #include "mesh_byteorder.h"
  16. #include "mesh_ffs.h"
  17. #include "mesh_trace.h"
  18. #include "mesh_mutex.h"
  19. #include "mesh_access.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. void *bt_mesh_malloc(size_t size);
  24. void *bt_mesh_calloc(size_t size);
  25. void bt_mesh_free(void *ptr);
  26. /**
  27. * @brief This function allocates memory to store outgoing message.
  28. *
  29. * @param[in] size: Length of memory allocated to store message value
  30. *
  31. * @return NULL-fail, pointer of a net_buf_simple structure-success
  32. */
  33. struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size);
  34. /**
  35. * @brief This function releases the memory allocated for the outgoing message.
  36. *
  37. * @param[in] buf: Pointer to the net_buf_simple structure to be freed
  38. *
  39. * @return none
  40. */
  41. void bt_mesh_free_buf(struct net_buf_simple *buf);
  42. /**
  43. * @brief This function gets device role for stack internal use.
  44. *
  45. * @Note Currently Provisioner only support client models, Node supports
  46. * client models and server models. Hence if srv_send is set to be
  47. * TRUE, then role NODE will be returned.
  48. *
  49. * @param[in] model: Pointer to the model structure
  50. * @param[in] srv_send: Indicate if the message is sent by a server model
  51. *
  52. * @return 0 - Node, 1 - Provisioner
  53. */
  54. uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
  55. int bt_mesh_rand(void *buf, size_t len);
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #endif /* _BLE_MESH_COMMON_H_ */