Skip to content

Commit

Permalink
examples: Add some more log output
Browse files Browse the repository at this point in the history
  • Loading branch information
antevir committed Feb 8, 2024
1 parent b5938b9 commit 6cfc951
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions examples/http_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ int main(int argc, char **argv)
const char *pDevice = U_EXAMPLE_UART;
const char *pSsid = U_EXAMPLE_SSID;
const char *pWpaPsk = U_EXAMPLE_WPA_PSK;

if (*pWpaPsk == 0) {
U_CX_LOG_LINE(U_CX_LOG_CH_WARN, "Wi-Fi not configured - connection will not work")
U_CX_LOG_LINE(U_CX_LOG_CH_WARN,
"- You need to define U_EXAMPLE_UART, U_EXAMPLE_SSID & U_EXAMPLE_WPA_PSK.")
}
#endif

U_CX_MUTEX_CREATE(gUrcSem);
Expand Down
6 changes: 6 additions & 0 deletions examples/http_example_no_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ int main(int argc, char **argv)
const char *pSsid = U_EXAMPLE_SSID;
const char *pWpaPsk = U_EXAMPLE_WPA_PSK;

if (*pWpaPsk == 0) {
U_CX_LOG_LINE(U_CX_LOG_CH_WARN, "Wi-Fi not configured - connection will not work")
U_CX_LOG_LINE(U_CX_LOG_CH_WARN,
"- You need to define U_EXAMPLE_UART, U_EXAMPLE_SSID & U_EXAMPLE_WPA_PSK.")
}

uPortAtInit(&client);
if (!uPortAtOpen(&client, pDevice, 115200, true)) {
return 1;
Expand Down
6 changes: 6 additions & 0 deletions examples/port/u_port_no_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ bool uPortAtOpen(uCxAtClient_t *pClient, const char *pDevName, int baudRate, boo
assert(pClient->pConfig != NULL);
assert(pCtx != NULL);
assert(pCtx->uartFd == -1);

U_CX_LOG_LINE(U_CX_LOG_CH_DBG, "Opening %s at %d with %s flow control",
pDevName, baudRate, useFlowControl ? "CTS/RTS" : "no");

gUartFd = openUart(pDevName, baudRate, useFlowControl);
if (gUartFd < 0) {
U_CX_LOG_LINE(U_CX_LOG_CH_ERROR, "Failed to open UART");
Expand All @@ -212,6 +216,8 @@ void uPortAtClose(uCxAtClient_t *pClient)
uPortContext_t *pCtx = pClient->pConfig->pStreamHandle;
assert(pCtx->uartFd != -1);

U_CX_LOG_LINE(U_CX_LOG_CH_DBG, "Closing UART");

close(pCtx->uartFd);
pCtx->uartFd = -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/port/u_port_no_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#endif

#ifndef U_EXAMPLE_WPA_PSK
# define U_EXAMPLE_WPA_PSK "fooooooo"
# define U_EXAMPLE_WPA_PSK ""
#endif

/* ----------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions examples/port/u_port_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ bool uPortAtOpen(uCxAtClient_t *pClient, const char *pDevName, int baudRate, boo
assert(pClient->pConfig != NULL);
assert(pCtx != NULL);
assert(pCtx->uartFd == -1);

U_CX_LOG_LINE(U_CX_LOG_CH_DBG, "Opening %s at %d with %s flow control",
pDevName, baudRate, useFlowControl ? "CTS/RTS" : "no");

gUartFd = openUart(pDevName, baudRate, useFlowControl);
if (gUartFd < 0) {
U_CX_LOG_LINE(U_CX_LOG_CH_ERROR, "Failed to open UART");
Expand All @@ -260,6 +264,8 @@ void uPortAtClose(uCxAtClient_t *pClient)
assert(pCtx->uartFd != -1);
assert(!pCtx->terminateRxTask);

U_CX_LOG_LINE(U_CX_LOG_CH_DBG, "Closing UART");

// Terminate the RX task
pCtx->terminateRxTask = true;
pthread_join(pCtx->rxThread, NULL);
Expand Down
5 changes: 5 additions & 0 deletions examples/port/u_port_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ bool uPortAtOpen(uCxAtClient_t *pClient, const char *pDevName, int baudRate, boo
U_CX_AT_PORT_ASSERT(pCtx != NULL);
U_CX_AT_PORT_ASSERT(pCtx->pUartDev == NULL);

U_CX_LOG_LINE(U_CX_LOG_CH_DBG, "Opening %s at %d with %s flow control",
pDevName, baudRate, useFlowControl ? "CTS/RTS" : "no");

pCtx->pUartDev = device_get_binding(pDevName);
if (pCtx->pUartDev == NULL) {
U_CX_LOG_LINE(U_CX_LOG_CH_ERROR, "Failed to open UART %s", pDevName);
Expand Down Expand Up @@ -220,6 +223,8 @@ void uPortAtClose(uCxAtClient_t *pClient)
uPortContext_t *pCtx = pClient->pConfig->pStreamHandle;
U_CX_AT_PORT_ASSERT(pCtx->pUartDev != NULL);

U_CX_LOG_LINE(U_CX_LOG_CH_DBG, "Closing UART");

uart_irq_rx_disable(pCtx->pUartDev);
k_work_cancel(&pCtx->rxWork);
pCtx->pUartDev = NULL;
Expand Down
2 changes: 1 addition & 1 deletion examples/port/u_port_zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#endif

#ifndef U_EXAMPLE_WPA_PSK
# define U_EXAMPLE_WPA_PSK "fooooooo"
# define U_EXAMPLE_WPA_PSK ""
#endif

/* ----------------------------------------------------------------
Expand Down

0 comments on commit 6cfc951

Please sign in to comment.