* @brief Create a new protocomm instance
*
* This API will return a new dynamically allocated protocomm instance
- * with all elements of the protocomm_t structure initialised to NULL.
+ * with all elements of the protocomm_t structure initialized to NULL.
*
* @return
* - protocomm_t* : On success
* - An endpoint must be bound to a valid protocomm instance,
* created using `protocomm_new()`.
* - This function internally calls the registered `add_endpoint()`
- * function which is a member of the protocomm_t instance structure.
+ * function of the selected transport which is a member of the
+ * protocomm_t instance structure.
*
* @param[in] pc Pointer to the protocomm instance
* @param[in] ep_name Endpoint identifier(name) string
* Pass NULL if not needed.
*
* @return
- * - ESP_OK : Added new endpoint succesfully
+ * - ESP_OK : Success
* - ESP_FAIL : Error adding endpoint / Endpoint with this name already exists
* - ESP_ERR_NO_MEM : Error allocating endpoint resource
* - ESP_ERR_INVALID_ARG : Null instance/name/handler arguments
* @param[in] ep_name Endpoint identifier(name) string
*
* @return
- * - ESP_OK : Added new endpoint succesfully
+ * - ESP_OK : Success
* - ESP_ERR_NOT_FOUND : Endpoint with specified name doesn't exist
* - ESP_ERR_INVALID_ARG : Null instance/name arguments
*/
/**
* @brief Calls the registered handler of an endpoint session
- * for processing incoming data and giving the output
+ * for processing incoming data and generating the response
*
* @note
* - An endpoint must be bound to a valid protocomm instance,
* created using `protocomm_new()`.
- * - Resulting output buffer must be deallocated by the user.
+ * - Resulting output buffer must be deallocated by the caller.
*
* @param[in] pc Pointer to the protocomm instance
* @param[in] ep_name Endpoint identifier(name) string
* @param[out] outlen Buffer length of the allocated output buffer
*
* @return
- * - ESP_OK : Request handled succesfully
+ * - ESP_OK : Request handled successfully
* - ESP_FAIL : Internal error in execution of registered handler
* - ESP_ERR_NO_MEM : Error allocating internal resource
* - ESP_ERR_NOT_FOUND : Endpoint with specified name doesn't exist
* @param[in] pop Pointer to proof of possession for authenticating a client
*
* @return
- * - ESP_OK : Added new security endpoint succesfully
+ * - ESP_OK : Success
* - ESP_FAIL : Error adding endpoint / Endpoint with this name already exists
* - ESP_ERR_INVALID_STATE : Security endpoint already set
* - ESP_ERR_NO_MEM : Error allocating endpoint resource
* @param[in] ep_name Endpoint identifier(name) string
*
* @return
- * - ESP_OK : Added new endpoint succesfully
+ * - ESP_OK : Success
* - ESP_ERR_NOT_FOUND : Endpoint with specified name doesn't exist
* - ESP_ERR_INVALID_ARG : Null instance/name arguments
*/
* @brief Set endpoint for version verification
*
* This API can be used for setting an application specific protocol
- * version which can be verfied by clients through the endpoint.
+ * version which can be verified by clients through the endpoint.
*
* @note
* - An endpoint must be bound to a valid protocomm instance,
* @param[in] version Version identifier(name) string
*
* @return
- * - ESP_OK : Added new security endpoint succesfully
+ * - ESP_OK : Success
* - ESP_FAIL : Error adding endpoint / Endpoint with this name already exists
* - ESP_ERR_INVALID_STATE : Version endpoint already set
* - ESP_ERR_NO_MEM : Error allocating endpoint resource
* @param[in] ep_name Endpoint identifier(name) string
*
* @return
- * - ESP_OK : Added new endpoint succesfully
+ * - ESP_OK : Success
* - ESP_ERR_NOT_FOUND : Endpoint with specified name doesn't exist
* - ESP_ERR_INVALID_ARG : Null instance/name arguments
*/
*/
typedef struct protocomm_security {
/**
- * Unique version number of security implmentation
+ * Unique version number of security implementation
*/
int ver;
/**
- * Function for initialising/allocating security
+ * Function for initializing/allocating security
* infrastructure
*/
esp_err_t (*init)();
/**
* @brief Protocomm security version 1 implementation
*
- * This is a full fledged security implmentation using
+ * This is a full fledged security implementation using
* Curve25519 key exchange and AES-256-CTR encryption
*/
extern const protocomm_security_t protocomm_security1;
* the initialization for characteristics/service for BLE.
*
* @param[in] pc Protocomm instance pointer obtained from protocomm_new()
- * @param[in] config Pointer to config structure for initialising BLE
+ * @param[in] config Pointer to config structure for initializing BLE
*
* @return
- * - ESP_OK : if successful
+ * - ESP_OK : Success
* - ESP_FAIL : Simple BLE start error
* - ESP_ERR_NO_MEM : Error allocating memory for internal resources
* - ESP_ERR_INVALID_STATE : Error in ble config
* @param[in] pc Same protocomm instance that was passed to protocomm_ble_start()
*
* @return
- * - ESP_OK : For success or appropriate error code
+ * - ESP_OK : Success
* - ESP_FAIL : Simple BLE stop error
* - ESP_ERR_INVALID_ARG : Null / incorrect protocomm instance
*/
* @brief Config parameters for protocomm console
*/
typedef struct {
- size_t stack_size; /*!< Stack size of console taks */
+ size_t stack_size; /*!< Stack size of console task */
unsigned task_priority; /*!< Priority of console task */
} protocomm_console_config_t;
* @param[in] config Config param structure for protocomm console
*
* @return
- * - ESP_OK : Server started succefully
+ * - ESP_OK : Success
* - ESP_ERR_INVALID_ARG : Null arguments
* - ESP_ERR_NOT_SUPPORTED : Transport layer bound to another protocomm instance
* - ESP_ERR_INVALID_STATE : Transport layer already bound to this protocomm instance
* @param[in] pc Same protocomm instance that was passed to protocomm_console_start()
*
* @return
- * - ESP_OK : Server stopped succefully
+ * - ESP_OK : Success
* - ESP_ERR_INVALID_ARG : Null / incorrect protocomm instance pointer
*/
esp_err_t protocomm_console_stop(protocomm_t *pc);
*/
typedef struct {
- uint16_t port; /*!< Port on which the http server will listen */
+ uint16_t port; /*!< Port on which the HTTP server will listen */
/**
* Stack size of server task, adjusted depending
unsigned task_priority; /*!< Priority of server task */
} protocomm_http_server_config_t; /*!< HTTP Server Configuration, if HTTP Server has not been started already */
-/** Protocomm HTTPD Configuration Data */
+/** Protocomm HTTPD Configuration Data
+ */
typedef union {
- /** HTTP Server Handle, if ext_handle_provided is set to true */
+ /** HTTP Server Handle, if ext_handle_provided is set to true
+ */
void *handle;
- /** HTTP Server Configuration, if a server is not already active */
+
+ /** HTTP Server Configuration, if a server is not already active
+ */
protocomm_http_server_config_t config;
} protocomm_httpd_config_data_t;
* one instance can be bound to an HTTP transport layer.
*
* @param[in] pc Protocomm instance pointer obtained from protocomm_new()
- * @param[in] config Pointer to config structure for initialising HTTP server
+ * @param[in] config Pointer to config structure for initializing HTTP server
*
* @return
- * - ESP_OK : Server started succefully
+ * - ESP_OK : Success
* - ESP_ERR_INVALID_ARG : Null arguments
* - ESP_ERR_NOT_SUPPORTED : Transport layer bound to another protocomm instance
* - ESP_ERR_INVALID_STATE : Transport layer already bound to this protocomm instance
* @param[in] pc Same protocomm instance that was passed to protocomm_httpd_start()
*
* @return
- * - ESP_OK : Server stopped succefully
+ * - ESP_OK : Success
* - ESP_ERR_INVALID_ARG : Null / incorrect protocomm instance pointer
*/
esp_err_t protocomm_httpd_stop(protocomm_t *pc);
if (sec->init) {
ret = sec->init();
if (ret != ESP_OK) {
- ESP_LOGE(TAG, "Error initialising security");
+ ESP_LOGE(TAG, "Error initializing security");
protocomm_remove_endpoint(pc, ep_name);
return ret;
}
int (*remove_endpoint)(const char *ep_name);
/* Pointer to security layer instance to be used internally for
- * establising secure sessions */
+ * establishing secure sessions */
const protocomm_security_t *sec;
/* Pointer to proof of possession object */
g_ble_cfg_p->exec_write_fn(event, gatts_if, param);
break;
case ESP_GATTS_MTU_EVT:
- ESP_LOGV(TAG, "ESP_GATTS_MTU_EVT, MTU %d", param->mtu.mtu);
+ ESP_LOGD(TAG, "ESP_GATTS_MTU_EVT, MTU %d", param->mtu.mtu);
if (g_ble_cfg_p->set_mtu_fn) {
g_ble_cfg_p->set_mtu_fn(event, gatts_if, param);
}
} simple_ble_cfg_t;
-/** Initialise a simple ble connection
+/** Initialize a simple ble connection
*
* This function allocates memory and returns a pointer to the
* configuration structure.
static void transport_simple_ble_disconnect(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
{
esp_err_t ret;
- ESP_LOGV(TAG, "Inside disconnect w/ session - %d", param->disconnect.conn_id);
+ ESP_LOGD(TAG, "Inside disconnect w/ session - %d", param->disconnect.conn_id);
if (protoble_internal->pc_ble->sec &&
protoble_internal->pc_ble->sec->close_transport_session) {
ret = protoble_internal->pc_ble->sec->close_transport_session(param->disconnect.conn_id);
static void transport_simple_ble_connect(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
{
esp_err_t ret;
- ESP_LOGV(TAG, "Inside BLE connect w/ conn_id - %d", param->connect.conn_id);
+ ESP_LOGD(TAG, "Inside BLE connect w/ conn_id - %d", param->connect.conn_id);
if (protoble_internal->pc_ble->sec &&
protoble_internal->pc_ble->sec->new_transport_session) {
ret = protoble_internal->pc_ble->sec->new_transport_session(param->connect.conn_id);
}
prepare_write_env.prepare_buf = NULL;
- ESP_LOGV(TAG, "Waiting for client to connect ......");
+ ESP_LOGD(TAG, "Waiting for client to connect ......");
return ESP_OK;
}
QueueHandle_t uart_queue;
uart_event_t event;
- ESP_LOGV(TAG, "Initialising UART on port %d", uart_num);
+ ESP_LOGD(TAG, "Initializing UART on port %d", uart_num);
uart_driver_install(uart_num, 256, 0, 8, &uart_queue, 0);
/* Initialize the console */
esp_console_config_t console_config = {
static const char *TAG = "protocomm_httpd";
static protocomm_t *pc_httpd; /* The global protocomm instance for HTTPD */
-static bool pc_ext_httpd_handle_provided;
+static bool pc_ext_httpd_handle_provided = false;
static uint32_t session_id = PROTOCOMM_NO_SESSION_ID;
#define MAX_REQ_BODY_LEN 4096
int cur_session_id = httpd_req_to_sockfd(req);
if (cur_session_id != session_id) {
- /* Initialise new security session */
+ /* Initialize new security session */
if (session_id != PROTOCOMM_NO_SESSION_ID) {
- ESP_LOGV(TAG, "Closing session with ID: %d", session_id);
+ ESP_LOGD(TAG, "Closing session with ID: %d", session_id);
/* Presently HTTP server doesn't support callback on socket closure so
* previous session can only be closed when new session is requested */
if (pc_httpd->sec && pc_httpd->sec->close_transport_session) {
}
}
session_id = cur_session_id;
- ESP_LOGV(TAG, "New session with ID: %d", cur_session_id);
+ ESP_LOGD(TAG, "New session with ID: %d", cur_session_id);
}
if (req->content_len <= 0) {
return ESP_ERR_INVALID_STATE;
}
- ESP_LOGV(TAG, "Adding endpoint : %s", ep_name);
+ ESP_LOGD(TAG, "Adding endpoint : %s", ep_name);
/* Construct URI name by prepending '/' to ep_name */
char* ep_uri = calloc(1, strlen(ep_name) + 2);
return ESP_ERR_INVALID_STATE;
}
- ESP_LOGV(TAG, "Removing endpoint : %s", ep_name);
+ ESP_LOGD(TAG, "Removing endpoint : %s", ep_name);
/* Construct URI name by prepending '/' to ep_name */
char* ep_uri = calloc(1, strlen(ep_name) + 2);