protocomm_console.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <protocomm.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #define PROTOCOMM_CONSOLE_DEFAULT_CONFIG() { \
  20. .stack_size = 4096, \
  21. .task_priority = tskIDLE_PRIORITY + 3, \
  22. }
  23. /**
  24. * @brief Config parameters for protocomm console
  25. */
  26. typedef struct {
  27. size_t stack_size; /*!< Stack size of console task */
  28. unsigned task_priority; /*!< Priority of console task */
  29. } protocomm_console_config_t;
  30. /**
  31. * @brief Start console based protocomm transport
  32. *
  33. * @note This is a singleton. ie. Protocomm can have multiple instances, but only
  34. * one instance can be bound to a console based transport layer.
  35. *
  36. * @param[in] pc Protocomm instance pointer obtained from protocomm_new()
  37. * @param[in] config Config param structure for protocomm console
  38. *
  39. * @return
  40. * - ESP_OK : Success
  41. * - ESP_ERR_INVALID_ARG : Null arguments
  42. * - ESP_ERR_NOT_SUPPORTED : Transport layer bound to another protocomm instance
  43. * - ESP_ERR_INVALID_STATE : Transport layer already bound to this protocomm instance
  44. * - ESP_FAIL : Failed to start console thread
  45. */
  46. esp_err_t protocomm_console_start(protocomm_t *pc, const protocomm_console_config_t *config);
  47. /**
  48. * @brief Stop console protocomm transport
  49. *
  50. * @param[in] pc Same protocomm instance that was passed to protocomm_console_start()
  51. *
  52. * @return
  53. * - ESP_OK : Success
  54. * - ESP_ERR_INVALID_ARG : Null / incorrect protocomm instance pointer
  55. */
  56. esp_err_t protocomm_console_stop(protocomm_t *pc);
  57. #ifdef __cplusplus
  58. }
  59. #endif