add some code
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "sscma_client_io.h"
|
||||
#include "sscma_client_flasher.h"
|
||||
#include "sscma_client_ops.h"
|
||||
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#define RESPONSE_PREFIX "\r{"
|
||||
#define RESPONSE_SUFFIX "}\n"
|
||||
|
||||
#define RESPONSE_PREFIX_LEN (sizeof(RESPONSE_PREFIX) - 1)
|
||||
#define RESPONSE_SUFFIX_LEN (sizeof(RESPONSE_SUFFIX) - 1)
|
||||
|
||||
#define CMD_TYPE_RESPONSE 0
|
||||
#define CMD_TYPE_EVENT 1
|
||||
#define CMD_TYPE_LOG 2
|
||||
|
||||
#define CMD_PREFIX "AT+"
|
||||
#define CMD_QUERY "?"
|
||||
#define CMD_SET "="
|
||||
#define CMD_SUFFIX "\r\n"
|
||||
|
||||
#define CMD_PREFIX_LEN (sizeof(CMD_PREFIX) - 1)
|
||||
#define CMD_SUFFIX_LEN (sizeof(CMD_SUFFIX) - 1)
|
||||
|
||||
#define CMD_WAIT_DELAY 2000 // ms
|
||||
|
||||
#define CMD_AT_ID "ID"
|
||||
#define CMD_AT_NAME "NAME"
|
||||
#define CMD_AT_VERSION "VER"
|
||||
#define CMD_AT_STATS "STAT"
|
||||
#define CMD_AT_BREAK "BREAK"
|
||||
#define CMD_AT_RESET "RST"
|
||||
#define CMD_AT_WIFI "WIFI"
|
||||
#define CMD_AT_MQTTSERVER "MQTTSERVER"
|
||||
#define CMD_AT_MQTTPUBSUB "MQTTPUBSUB"
|
||||
#define CMD_AT_INVOKE "INVOKE"
|
||||
#define CMD_AT_SAMPLE "SAMPLE"
|
||||
#define CMD_AT_INFO "INFO"
|
||||
#define CMD_AT_TSCORE "TSCORE"
|
||||
#define CMD_AT_TIOU "TIOU"
|
||||
#define CMD_AT_ALGOS "ALGOS"
|
||||
#define CMD_AT_MODELS "MODELS"
|
||||
#define CMD_AT_MODEL "MODEL"
|
||||
#define CMD_AT_SENSORS "SENSORS"
|
||||
#define CMD_AT_SENSOR "SENSOR"
|
||||
#define CMD_AT_ACTION "ACTION"
|
||||
#define CMD_AT_LED "LED"
|
||||
#define CMD_AT_OTA "OTA"
|
||||
|
||||
#define EVENT_INVOKE "INVOKE"
|
||||
#define EVENT_SAMPLE "SAMPLE"
|
||||
#define EVENT_WIFI "WIFI"
|
||||
#define EVENT_MQTT "MQTT"
|
||||
#define EVENT_SUPERVISOR "SUPERVISOR"
|
||||
#define EVENT_INIT "INIT@STAT"
|
||||
|
||||
#define LOG_AT "AT"
|
||||
#define LOG_LOG "LOG"
|
||||
|
||||
typedef enum {
|
||||
CMD_OK = 0,
|
||||
CMD_AGAIN = 1,
|
||||
CMD_ELOG = 2,
|
||||
CMD_ETIMEDOUT = 3,
|
||||
CMD_EIO = 4,
|
||||
CMD_EINVAL = 5,
|
||||
CMD_ENOMEM = 6,
|
||||
CMD_EBUSY = 7,
|
||||
CMD_ENOTSUP = 8,
|
||||
CMD_EPERM = 9,
|
||||
CMD_EUNKNOWN = 10
|
||||
} sscma_client_error_t;
|
||||
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_io_expander.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "sscma_client_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *sscma_client_flasher_we2_handle_t; /*!< Type of SSCMA flasher WE2 handle */
|
||||
|
||||
/**
|
||||
* @brief Flasher configuration structure, for WE2
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int reset_gpio_num; /* !< GPIO number of reset pin */
|
||||
void *user_ctx; /*!< User private data */
|
||||
esp_io_expander_handle_t io_expander; /*!< IO expander handle */
|
||||
struct
|
||||
{
|
||||
unsigned int reset_high_active : 1; /*!< Reset line is high active */
|
||||
unsigned int reset_use_expander : 1; /*!< Reset line use IO expander */
|
||||
} flags;
|
||||
} sscma_client_flasher_we2_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create SSCMA flasher, for WE2
|
||||
*
|
||||
* @param[in] io IO handle
|
||||
* @param[in] flasher_config Flasher configuration, for WE2
|
||||
* @param[out] ret_io Returned flasher handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
|
||||
esp_err_t sscma_client_new_flasher_we2_uart(const sscma_client_io_handle_t io, const sscma_client_flasher_we2_config_t *flasher_config, sscma_client_flasher_handle_t *ret_flasher);
|
||||
|
||||
/**
|
||||
* @brief Create SSCMA flasher, for WE2
|
||||
*
|
||||
* @param[in] io IO handle
|
||||
* @param[in] flasher_config Flasher configuration, for WE2
|
||||
* @param[out] ret_io Returned flasher handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_new_flasher_we2_spi(const sscma_client_io_handle_t io, const sscma_client_flasher_we2_config_t *config, sscma_client_flasher_handle_t *ret_flasher);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,157 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "soc/soc_caps.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_io_expander.h"
|
||||
|
||||
#include "sscma_client_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *sscma_client_spi_bus_handle_t; /*!< Type of SSCMA SPI bus handle */
|
||||
typedef void *sscma_client_i2c_bus_handle_t; /*!< Type of SSCMA I2C bus handle */
|
||||
typedef void *sscma_client_uart_bus_handle_t; /*!< Type of SSCMA UART bus handle */
|
||||
|
||||
/**
|
||||
* @brief Client IO configuration structure, for SPI interface
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int cs_gpio_num; /*!< GPIO used for CS line */
|
||||
int sync_gpio_num; /*!< GPIO used for SYNC line */
|
||||
int spi_mode;
|
||||
int wait_delay; /*!< Traditional SPI mode (0~3) */
|
||||
unsigned int pclk_hz; /*!< Frequency of pixel clock */
|
||||
size_t trans_queue_depth; /*!< Size of internal transaction queue */
|
||||
void *user_ctx; /*!< User private data, passed directly to on_color_trans_done's user_ctx */
|
||||
esp_io_expander_handle_t io_expander; /*!< IO expander handle */
|
||||
struct
|
||||
{
|
||||
unsigned int octal_mode : 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */
|
||||
unsigned int sio_mode : 1; /*!< Read and write through a single data line (MOSI) */
|
||||
unsigned int lsb_first : 1; /*!< transmit LSB bit first */
|
||||
unsigned int cs_high_active : 1; /*!< CS line is high active */
|
||||
unsigned int sync_high_active : 1; /*!< SYNC line is high active */
|
||||
unsigned int sync_use_expander : 1; /*!< SYNC line use IO expander */
|
||||
} flags;
|
||||
} sscma_client_io_spi_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create SSCMA client IO handle, for SPI interface
|
||||
*
|
||||
* @param[in] bus SPI bus handle
|
||||
* @param[in] io_config IO configuration, for SPI interface
|
||||
* @param[out] ret_io Returned IO handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
|
||||
esp_err_t sscma_client_new_io_spi_bus(sscma_client_spi_bus_handle_t bus, const sscma_client_io_spi_config_t *io_config, sscma_client_io_handle_t *ret_io);
|
||||
|
||||
/**
|
||||
* @brief Client IO configuration structure, for I2C interface
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t dev_addr; /*!< I2C device address */
|
||||
int wait_delay;
|
||||
void *user_ctx; /*!< User private data, passed directly to user_ctx */
|
||||
} sscma_client_io_i2c_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create SSCMA client IO handle, for I2C interface
|
||||
*
|
||||
* @param[in] bus I2C bus handle
|
||||
* @param[in] io_config IO configuration, for I2C interface
|
||||
* @param[out] ret_io Returned IO handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_new_io_i2c_bus(sscma_client_i2c_bus_handle_t bus, const sscma_client_io_i2c_config_t *io_config, sscma_client_io_handle_t *ret_io);
|
||||
|
||||
/**
|
||||
* @brief Client IO configuration structure, for uart interface
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void *user_ctx; /*!< User private data, passed directly to user_ctx */
|
||||
} sscma_client_io_uart_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create SSCMA client IO handle, for uart interface
|
||||
*
|
||||
* @param[in] bus UART bus handle
|
||||
* @param[in] io_config IO configuration, for uart interface
|
||||
* @param[out] ret_io Returned IO handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_new_io_uart_bus(sscma_client_uart_bus_handle_t bus, const sscma_client_io_uart_config_t *io_config, sscma_client_io_handle_t *ret_io);
|
||||
|
||||
/**
|
||||
* @brief Destory SSCMA client IO handle
|
||||
*
|
||||
* @param[in] io IO handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_del_io(sscma_client_io_handle_t io);
|
||||
|
||||
/**
|
||||
* @brief Write data to SSCMA client IO
|
||||
*
|
||||
* @param[in] io IO handle
|
||||
* @param[in] data Data to be written
|
||||
* @param[in] size Size of data
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_io_write(sscma_client_io_handle_t io, const void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Read data from SSCMA client IO
|
||||
*
|
||||
* @param[in] io IO handle
|
||||
* @param[in] data Data to be read
|
||||
* @param[in] size Size of data
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_io_read(sscma_client_io_handle_t io, void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Get available size of data
|
||||
*
|
||||
* @param[in] io IO handle
|
||||
* @param[out] len Available size
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_client_io_available(sscma_client_io_handle_t io, size_t *len);
|
||||
|
||||
/**
|
||||
* @brief Flush data
|
||||
*
|
||||
* @param[in] io IO handle
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_client_io_flush(sscma_client_io_handle_t io);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,424 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_io_expander.h"
|
||||
#include "sscma_client_types.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configuration of SCCMA client
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int reset_gpio_num; /*!< GPIO number of reset pin */
|
||||
int tx_buffer_size; /*!< Size of TX buffer */
|
||||
int rx_buffer_size; /*!< Size of RX buffer */
|
||||
int process_task_priority; /* SSCMA process task priority */
|
||||
int process_task_stack; /* SSCMA process task stack size */
|
||||
int process_task_affinity; /* SSCMA process task pinned to core (-1 is no
|
||||
affinity) */
|
||||
int monitor_task_priority; /* SSCMA monitor task priority */
|
||||
int monitor_task_stack; /* SSCMA monitor task stack size */
|
||||
int monitor_task_affinity; /* SSCMA monitor task pinned to core (-1 is no
|
||||
affinity) */
|
||||
int event_queue_size; /* Event queue size */
|
||||
void *user_ctx; /* User context */
|
||||
esp_io_expander_handle_t io_expander; /*!< IO expander handle */
|
||||
struct
|
||||
{
|
||||
unsigned int reset_active_high : 1; /*!< Setting this if the panel reset is
|
||||
high level active */
|
||||
unsigned int reset_use_expander : 1; /*!< Reset line use IO expander */
|
||||
} flags; /*!< SSCMA client config flags */
|
||||
} sscma_client_config_t;
|
||||
|
||||
#define SSCMA_CLIENT_CONFIG_DEFAULT() \
|
||||
{ \
|
||||
.reset_gpio_num = -1, .tx_buffer_size = 4096, .rx_buffer_size = 65536, .process_task_priority = 5, .process_task_stack = 4096, .process_task_affinity = -1, .monitor_task_priority = 4, \
|
||||
.monitor_task_stack = 10240, .monitor_task_affinity = -1, .event_queue_size = 2, .user_ctx = NULL, \
|
||||
.flags = { \
|
||||
.reset_active_high = false, \
|
||||
}, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create new SCCMA client
|
||||
*
|
||||
* @param[in] io IO handle
|
||||
* @param[in] config SCCMA client config
|
||||
* @param[out] ret_client SCCMA client handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
*/
|
||||
esp_err_t sscma_client_new(const sscma_client_io_handle_t io, const sscma_client_config_t *config, sscma_client_handle_t *ret_client);
|
||||
|
||||
/**
|
||||
* @brief Destroy SCCMA client
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_del(sscma_client_handle_t client);
|
||||
|
||||
/**
|
||||
* @brief Initialize SCCMA client
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_init(sscma_client_handle_t client);
|
||||
|
||||
/**
|
||||
* @brief Reset SCCMA client
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_reset(sscma_client_handle_t client);
|
||||
/**
|
||||
* @brief Read data from SCCMA client
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[out] data Data to be read
|
||||
* @param[in] size Size of data
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NOT_SUPPORTED if read is not supported by transport
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_read(sscma_client_handle_t client, void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Write data to SCCMA client
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] data Data to be written
|
||||
* @param[in] size Size of data
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_NOT_SUPPORTED if read is not supported by transport
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_write(sscma_client_handle_t client, const void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Get available data
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[out] ret_avail Available data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_available(sscma_client_handle_t client, size_t *ret_avail);
|
||||
|
||||
/**
|
||||
* @brief Register callback
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] callback SCCMA client callback
|
||||
* @param[in] user_ctx User context
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_register_callback(sscma_client_handle_t client, const sscma_client_callback_t *callback, void *user_ctx);
|
||||
|
||||
/**
|
||||
* @brief Clear reply
|
||||
*
|
||||
* @param[in] reply Reply
|
||||
* @return void
|
||||
*/
|
||||
void sscma_client_reply_clear(sscma_client_reply_t *reply);
|
||||
|
||||
/**
|
||||
* @brief Send request to SCCMA client
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_request(sscma_client_handle_t client, const char *cmd, sscma_client_reply_t *reply, bool wait, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Get SCCMA client info
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] info Copyer to sscma_client_info_t
|
||||
* @param[in] cached true if info is cached
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_get_info(sscma_client_handle_t client, sscma_client_info_t **info, bool cached);
|
||||
|
||||
/**
|
||||
* @brief Send request to SCCMA clien
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] model Copyer to sscma_client_model_t
|
||||
* @param[in] cached true if model is cached
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_get_model(sscma_client_handle_t client, sscma_client_model_t **model, bool cached);
|
||||
|
||||
/**
|
||||
* @brief Set model
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] model Copyer to sscma_client_model_t
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_set_model(sscma_client_handle_t client, int model);
|
||||
|
||||
/**
|
||||
* @brief Set sensor
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] id sensor id
|
||||
* @param[in] opt_id sensor config
|
||||
* @param[in] bool true if enable
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_set_sensor(sscma_client_handle_t client, int id, int opt_id, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Get sensor
|
||||
*
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] sensor Copyer to sscma_client_sensor_t
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_get_sensor(sscma_client_handle_t client, sscma_client_sensor_t *sensor);
|
||||
|
||||
/**
|
||||
* @brief SSCMA client sample
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] times Number of times
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_sample(sscma_client_handle_t client, int times);
|
||||
|
||||
/**
|
||||
* @brief SSCMA client invoke
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] times Number of times
|
||||
* @param[in] fliter true if fliter
|
||||
* @param[in] show true if show
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_invoke(sscma_client_handle_t client, int times, bool fliter, bool show);
|
||||
|
||||
/**
|
||||
* @brief SSCMA client break
|
||||
* @param[in] client SCCMA client handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
|
||||
esp_err_t sscma_client_break(sscma_client_handle_t client);
|
||||
|
||||
/**
|
||||
* @brief Set iou threshold
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] threshold iou threshold
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_set_iou_threshold(sscma_client_handle_t client, int threshold);
|
||||
|
||||
/**
|
||||
* @brief Get iou threshold
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[out] threshold iou threshold
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_get_iou_threshold(sscma_client_handle_t client, int *threshold);
|
||||
|
||||
/**
|
||||
* @brief Set confidence threshold
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] threshold confidence threshold
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_set_confidence_threshold(sscma_client_handle_t client, int threshold);
|
||||
|
||||
/**
|
||||
* @brief Get confidence threshold
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[out] threshold confidence threshold
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_get_confidence_threshold(sscma_client_handle_t client, int *threshold);
|
||||
|
||||
/**
|
||||
* @brief Set model info
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] model_info model info
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_set_model_info(sscma_client_handle_t client, const char *model_info);
|
||||
|
||||
/**
|
||||
* Fetch boxes and classes from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] boxes sscma client boxes
|
||||
* @param[out] num_boxes number of boxes
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_fetch_boxes_from_reply(const sscma_client_reply_t *reply, sscma_client_box_t **boxes, int *num_boxes);
|
||||
|
||||
/**
|
||||
* Prase boxes from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] boxes sscma client boxes
|
||||
* @param[in] max_boxes max number of boxes
|
||||
* @param[out] num_boxes number of boxes
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_copy_boxes_from_reply(const sscma_client_reply_t *reply, sscma_client_box_t *boxes, int max_boxes, int *num_boxes);
|
||||
|
||||
/**
|
||||
* Fetch classes from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] classes sscma client classes
|
||||
* @param[out] num_classes number of classes
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_fetch_classes_from_reply(const sscma_client_reply_t *reply, sscma_client_class_t **classes, int *num_classes);
|
||||
|
||||
/**
|
||||
* Prase classes from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] classes sscma client classes
|
||||
* @param[in] max_classes max number of classes
|
||||
* @param[out] num_classes number of classes
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_copy_classes_from_reply(const sscma_client_reply_t *reply, sscma_client_class_t *classes, int max_classes, int *num_classes);
|
||||
|
||||
/**
|
||||
* Fetch points from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] points sscma client points
|
||||
* @param[out] num_points number of points
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_fetch_points_from_reply(const sscma_client_reply_t *reply, sscma_client_point_t **points, int *num_points);
|
||||
|
||||
/**
|
||||
* Prase points from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] points sscma client points
|
||||
* @param[in] max_points max number of points
|
||||
* @param[out] num_points number of points
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_copy_points_from_reply(const sscma_client_reply_t *reply, sscma_client_point_t *points, int max_points, int *num_points);
|
||||
|
||||
/**
|
||||
* Fetch keypoints from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] keypoints sscma client keypoints
|
||||
* @param[out] num_keypoints number of keypoints
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_fetch_keypoints_from_reply(const sscma_client_reply_t *reply, sscma_client_keypoint_t **keypoints, int *num_keypoints);
|
||||
|
||||
/**
|
||||
* Prase keypoints from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] keypoints sscma client keypoints
|
||||
* @param[in] max_keypoints max number of keypoints
|
||||
* @param[out] num_keypoints number of keypoints
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_copy_keypoints_from_reply(const sscma_client_reply_t *reply, sscma_client_keypoint_t *keypoints, int max_keypoints, int *num_keypoints);
|
||||
|
||||
/**
|
||||
* Fetch image from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] image sscma client image
|
||||
* @param[out] image_size size of image
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_fetch_image_from_reply(const sscma_client_reply_t *reply, char **image, int *image_size);
|
||||
|
||||
/**
|
||||
* Prase image from sscma client reply
|
||||
* @param[in] reply sscma client reply
|
||||
* @param[out] image sscma client image
|
||||
* @param[in] max_image_size max size of image
|
||||
* @param[out] image_size size of image
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t sscma_utils_copy_image_from_reply(const sscma_client_reply_t *reply, char *image, int max_image_size, int *image_size);
|
||||
|
||||
/**
|
||||
* Start ota
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] flasher flasher handle
|
||||
* @param[in] offset offset in file
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_ota_start(sscma_client_handle_t client, const sscma_client_flasher_handle_t flasher, size_t offset);
|
||||
|
||||
/**
|
||||
* Write data to ota
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] data data to write
|
||||
* @param[in] len length of data
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_ota_write(sscma_client_handle_t client, const void *data, size_t len);
|
||||
|
||||
/**
|
||||
* Finish ota
|
||||
* @param[in] client SCCMA client handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_ota_finish(sscma_client_handle_t client);
|
||||
|
||||
/**
|
||||
* Abort ota
|
||||
* @param[in] client SCCMA client handle
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t sscma_client_ota_abort(sscma_client_handle_t client);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,178 @@
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/event_groups.h"
|
||||
|
||||
#include "cJSON.h"
|
||||
|
||||
#include "esp_assert.h"
|
||||
|
||||
#include "sscma_client_io_interface.h"
|
||||
#include "sscma_client_flasher_interface.h"
|
||||
|
||||
#include "esp_io_expander.h"
|
||||
|
||||
#define SSCMA_CLIENT_MODEL_MAX_CLASSES 80
|
||||
#define SSCMA_CLIENT_MODEL_KEYPOINTS_MAX 80
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct sscma_client_t *sscma_client_handle_t; /*!< Type of SCCMA client handle */
|
||||
typedef struct sscma_client_io_t *sscma_client_io_handle_t; /*!< Type of SSCMA client IO handle */
|
||||
typedef struct sscma_client_flasher_t *sscma_client_flasher_handle_t; /*!< Type of SCCMA client flasher handle */
|
||||
|
||||
/**
|
||||
* @brief Reply message
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
cJSON *payload;
|
||||
char *data;
|
||||
size_t len;
|
||||
} sscma_client_reply_t;
|
||||
|
||||
/**
|
||||
* @brief Request message
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char cmd[32];
|
||||
QueueHandle_t reply;
|
||||
ListItem_t item;
|
||||
} sscma_client_request_t;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *id; /* !< ID */
|
||||
char *name; /* !< Name */
|
||||
char *hw_ver; /* !< Hardware version */
|
||||
char *sw_ver; /* !< Software version */
|
||||
char *fw_ver; /* !< Firmware version */
|
||||
} sscma_client_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id; /* !< ID */
|
||||
char *uuid; /* !< UUID */
|
||||
char *name; /*!< Name */
|
||||
char *ver; /*!< Version */
|
||||
char *url; /*!< URL */
|
||||
char *checksum; /*!< Checksum */
|
||||
char *classes[SSCMA_CLIENT_MODEL_MAX_CLASSES]; /*!< Classes */
|
||||
} sscma_client_model_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id;
|
||||
int type;
|
||||
int state;
|
||||
int opt_id;
|
||||
char *opt_detail;
|
||||
} sscma_client_sensor_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t w;
|
||||
uint16_t h;
|
||||
uint8_t score;
|
||||
uint8_t target;
|
||||
} sscma_client_box_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t target;
|
||||
uint8_t score;
|
||||
} sscma_client_class_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t z;
|
||||
uint8_t score;
|
||||
uint8_t target;
|
||||
} sscma_client_point_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
sscma_client_box_t box;
|
||||
uint8_t points_num;
|
||||
sscma_client_point_t points[SSCMA_CLIENT_MODEL_KEYPOINTS_MAX];
|
||||
} sscma_client_keypoint_t;
|
||||
|
||||
/**
|
||||
* @brief Callback function of SCCMA client
|
||||
* @param[in] client SCCMA client handle
|
||||
* @param[in] reply Reply message
|
||||
* @param[in] user_ctx User context
|
||||
* @return None
|
||||
*/
|
||||
typedef void (*sscma_client_reply_cb_t)(sscma_client_handle_t client, const sscma_client_reply_t *reply, void *user_ctx);
|
||||
|
||||
/**
|
||||
* @brief Type of SCCMA client callback
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
sscma_client_reply_cb_t on_connect;
|
||||
sscma_client_reply_cb_t on_disconnect; // TODO
|
||||
sscma_client_reply_cb_t on_response;
|
||||
sscma_client_reply_cb_t on_event;
|
||||
sscma_client_reply_cb_t on_log;
|
||||
} sscma_client_callback_t;
|
||||
|
||||
struct sscma_client_t
|
||||
{
|
||||
sscma_client_io_handle_t io; /* !< IO handle */
|
||||
sscma_client_flasher_handle_t flasher; /* !< flasher */
|
||||
int reset_gpio_num; /* !< GPIO number of reset pin */
|
||||
bool reset_level; /* !< Level of reset pin */
|
||||
bool inited; /* !< Whether inited */
|
||||
sscma_client_info_t info; /* !< Info */
|
||||
sscma_client_model_t model; /* !< Model */
|
||||
sscma_client_reply_cb_t on_connect; /* !< Callback function */
|
||||
sscma_client_reply_cb_t on_disconnect; /* !< Callback function */
|
||||
sscma_client_reply_cb_t on_response; /* !< Callback function */
|
||||
sscma_client_reply_cb_t on_event; /* !< Callback function */
|
||||
sscma_client_reply_cb_t on_log; /* !< Callback function */
|
||||
void *user_ctx; /* !< User context */
|
||||
esp_io_expander_handle_t io_expander; /* !< IO expander handle */
|
||||
struct
|
||||
{
|
||||
TaskHandle_t handle;
|
||||
#ifdef CONFIG_SSCMA_PROCESS_TASK_STACK_ALLOC_EXTERNAL
|
||||
StaticTask_t *task;
|
||||
StackType_t *stack;
|
||||
#endif
|
||||
} monitor_task;
|
||||
struct
|
||||
{
|
||||
TaskHandle_t handle;
|
||||
#ifdef CONFIG_SSCMA_MONITOR_TASK_STACK_ALLOC_EXTERNAL
|
||||
StaticTask_t *task;
|
||||
StackType_t *stack;
|
||||
#endif
|
||||
} process_task;
|
||||
struct
|
||||
{
|
||||
char *data; /* !< Data buffer */
|
||||
size_t len; /* !< Data length */
|
||||
size_t pos; /* !< Data position */
|
||||
} rx_buffer, tx_buffer; /* !< RX and TX buffer */
|
||||
QueueHandle_t reply_queue; /* !< Queue for reply message */
|
||||
List_t *request_list; /* !< Request list */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user