diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-05-11 16:14:14 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-05-11 16:14:14 +0200 |
commit | 1cafcbd398fa0e5a4afb1ade33ecf21694cde235 (patch) | |
tree | e49c32842e1e44efdc4198fbd787b275f1d65630 /code | |
parent | c827937e4599c4144f5d22af2de8e7a802b88be5 (diff) |
msgq functions rename; wifi constant rename
Diffstat (limited to 'code')
-rw-r--r-- | code/esp32/components/eos/cell_pcm.c | 4 | ||||
-rw-r--r-- | code/esp32/components/eos/include/eos.h | 3 | ||||
-rw-r--r-- | code/esp32/components/eos/include/msgq.h | 4 | ||||
-rw-r--r-- | code/esp32/components/eos/msgq.c | 4 | ||||
-rwxr-xr-x | code/esp32/components/eos/wifi.c | 16 |
5 files changed, 15 insertions, 16 deletions
diff --git a/code/esp32/components/eos/cell_pcm.c b/code/esp32/components/eos/cell_pcm.c index 46c64d9..9ee6b63 100644 --- a/code/esp32/components/eos/cell_pcm.c +++ b/code/esp32/components/eos/cell_pcm.c @@ -79,7 +79,7 @@ static void i2s_event_task(void *pvParameters) { buf = NULL; xSemaphoreTake(mutex, portMAX_DELAY); - if (pcm_hold_tx && (eos_msgq_size(&pcm_evt_q) == PCM_HOLD_CNT_TX)) pcm_hold_tx = 0; + if (pcm_hold_tx && (eos_msgq_len(&pcm_evt_q) == PCM_HOLD_CNT_TX)) pcm_hold_tx = 0; if (!pcm_hold_tx) eos_msgq_pop(&pcm_evt_q, &_type, &buf, &bytes_e, NULL); xSemaphoreGive(mutex); @@ -200,7 +200,7 @@ int eos_pcm_push(unsigned char *data, size_t size) { if (size > PCM_MIC_WM) return EOS_ERR; xSemaphoreTake(mutex, portMAX_DELAY); - if (pcm_hold_tx && (eos_msgq_size(&pcm_evt_q) == PCM_HOLD_CNT_TX)) { + if (pcm_hold_tx && (eos_msgq_len(&pcm_evt_q) == PCM_HOLD_CNT_TX)) { unsigned char _type; uint16_t _len; diff --git a/code/esp32/components/eos/include/eos.h b/code/esp32/components/eos/include/eos.h index 58399ce..87ac9f3 100644 --- a/code/esp32/components/eos/include/eos.h +++ b/code/esp32/components/eos/include/eos.h @@ -5,8 +5,7 @@ #define EOS_ERR_FULL -10 #define EOS_ERR_EMPTY -11 #define EOS_ERR_NOTFOUND -12 - -#define EOS_ERR_BUSY -20 +#define EOS_ERR_BUSY -13 #define EOS_TASK_PRIORITY_UART 1 #define EOS_TASK_PRIORITY_UART_RI 1 diff --git a/code/esp32/components/eos/include/msgq.h b/code/esp32/components/eos/include/msgq.h index f4a493e..86bb067 100644 --- a/code/esp32/components/eos/include/msgq.h +++ b/code/esp32/components/eos/include/msgq.h @@ -17,7 +17,7 @@ typedef struct EOSMsgQ { void eos_msgq_init(EOSMsgQ *msgq, EOSMsgItem *array, uint8_t size); int eos_msgq_push(EOSMsgQ *msgq, unsigned char type, unsigned char *buffer, uint16_t len, uint8_t flags); void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *type, unsigned char **buffer, uint16_t *len, uint8_t *flags); -uint8_t eos_msgq_size(EOSMsgQ *msgq); +uint8_t eos_msgq_len(EOSMsgQ *msgq); typedef struct EOSBufQ { uint8_t idx_r; @@ -29,4 +29,4 @@ typedef struct EOSBufQ { void eos_bufq_init(EOSBufQ *bufq, unsigned char **array, uint8_t size); int eos_bufq_push(EOSBufQ *bufq, unsigned char *buffer); unsigned char *eos_bufq_pop(EOSBufQ *bufq); -uint8_t eos_bufq_size(EOSBufQ *bufq);
\ No newline at end of file +uint8_t eos_bufq_len(EOSBufQ *bufq); diff --git a/code/esp32/components/eos/msgq.c b/code/esp32/components/eos/msgq.c index 5a0bb4a..c704399 100644 --- a/code/esp32/components/eos/msgq.c +++ b/code/esp32/components/eos/msgq.c @@ -40,7 +40,7 @@ void eos_msgq_pop(EOSMsgQ *msgq, unsigned char *type, unsigned char **buffer, ui } } -uint8_t eos_msgq_size(EOSMsgQ *msgq) { +uint8_t eos_msgq_len(EOSMsgQ *msgq) { return (uint8_t)(msgq->idx_w - msgq->idx_r); } @@ -64,6 +64,6 @@ unsigned char *eos_bufq_pop(EOSBufQ *bufq) { return bufq->array[IDX_MASK(bufq->idx_r++, bufq->size)]; } -uint8_t eos_bufq_size(EOSBufQ *bufq) { +uint8_t eos_bufq_len(EOSBufQ *bufq) { return (uint8_t)(bufq->idx_w - bufq->idx_r); } diff --git a/code/esp32/components/eos/wifi.c b/code/esp32/components/eos/wifi.c index 124c36e..31aefea 100755 --- a/code/esp32/components/eos/wifi.c +++ b/code/esp32/components/eos/wifi.c @@ -18,8 +18,8 @@ // XXX: No DHCP server -#define WIFI_CONNECT_MAX_ATTEMPTS 3 -#define WIFI_SCAN_MAX_RECORDS 20 +#define WIFI_MAX_SCAN_RECORDS 20 +#define WIFI_MAX_CONNECT_ATTEMPTS 3 #define WIFI_STATE_STOPPED 0 #define WIFI_STATE_SCANNING 1 @@ -49,8 +49,8 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { char _disconnect; uint8_t _action, _state; unsigned char *rbuf; - wifi_ap_record_t scan_r[WIFI_SCAN_MAX_RECORDS]; - uint16_t scan_n = WIFI_SCAN_MAX_RECORDS; + wifi_ap_record_t scan_r[WIFI_MAX_SCAN_RECORDS]; + uint16_t scan_n = WIFI_MAX_SCAN_RECORDS; switch(event->event_id) { case WIFI_EVENT_SCAN_DONE: @@ -95,7 +95,7 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { xSemaphoreTake(mutex, portMAX_DELAY); wifi_state = WIFI_STATE_CONNECTED; wifi_action = WIFI_ACTION_NONE; - wifi_connect_cnt = WIFI_CONNECT_MAX_ATTEMPTS; + wifi_connect_cnt = WIFI_MAX_CONNECT_ATTEMPTS; xSemaphoreGive(mutex); break; @@ -111,7 +111,7 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { rbuf = eos_net_alloc(); if (_action == WIFI_ACTION_CONNECT) { rbuf[0] = EOS_WIFI_MTYPE_CONNECT; - rbuf[1] = 0; + rbuf[1] = EOS_ERR; eos_net_send(EOS_NET_MTYPE_WIFI, rbuf, 2, 0); } else { rbuf[0] = EOS_WIFI_MTYPE_DISCONNECT; @@ -130,7 +130,7 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { } else { rbuf = eos_net_alloc(); rbuf[0] = EOS_WIFI_MTYPE_CONNECT; - rbuf[1] = 1; + rbuf[1] = EOS_OK; eos_net_send(EOS_NET_MTYPE_WIFI, rbuf, 2, 0); } break; @@ -252,7 +252,7 @@ int eos_wifi_connect(void) { wifi_action = WIFI_ACTION_CONNECT; wifi_state = WIFI_STATE_CONNECTING; - wifi_connect_cnt = WIFI_CONNECT_MAX_ATTEMPTS; + wifi_connect_cnt = WIFI_MAX_CONNECT_ATTEMPTS; } else { rv = EOS_ERR_BUSY; } |