common.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. int bt_mesh_rand(void *buf, size_t len);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif /* _BLE_MESH_COMMON_H_ */