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 
15 #pragma once
16 
17 #include <protocomm.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #define PROTOCOMM_CONSOLE_DEFAULT_CONFIG() { \
24     .stack_size     = 4096,                  \
25     .task_priority  = tskIDLE_PRIORITY + 3,  \
26 }
27 
28 /**
29  * @brief   Config parameters for protocomm console
30  */
31 typedef struct {
32     size_t   stack_size;        /*!< Stack size of console task */
33     unsigned task_priority;     /*!< Priority of console task */
34 } protocomm_console_config_t;
35 
36 /**
37  * @brief   Start console based protocomm transport
38  *
39  * @note    This is a singleton. ie. Protocomm can have multiple instances, but only
40  *          one instance can be bound to a console based transport layer.
41  *
42  * @param[in] pc     Protocomm instance pointer obtained from protocomm_new()
43  * @param[in] config Config param structure for protocomm console
44  *
45  * @return
46  *  - ESP_OK : Success
47  *  - ESP_ERR_INVALID_ARG : Null arguments
48  *  - ESP_ERR_NOT_SUPPORTED : Transport layer bound to another protocomm instance
49  *  - ESP_ERR_INVALID_STATE : Transport layer already bound to this protocomm instance
50  *  - ESP_FAIL : Failed to start console thread
51  */
52 esp_err_t protocomm_console_start(protocomm_t *pc, const protocomm_console_config_t *config);
53 
54 /**
55  * @brief   Stop console protocomm transport
56  *
57  * @param[in] pc    Same protocomm instance that was passed to protocomm_console_start()
58  *
59  * @return
60  *  - ESP_OK : Success
61  *  - ESP_ERR_INVALID_ARG : Null / incorrect protocomm instance pointer
62  */
63 esp_err_t protocomm_console_stop(protocomm_t *pc);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68