add code for websocker send
This commit is contained in:
parent
a83d4c70f4
commit
84ae8fdbdc
@ -3,7 +3,7 @@ dependencies:
|
|||||||
component_hash: null
|
component_hash: null
|
||||||
source:
|
source:
|
||||||
type: idf
|
type: idf
|
||||||
version: 5.2.2
|
version: 5.4.0
|
||||||
manifest_hash: 0646c148cf0e35f84678cd2cb46e9929051a1c6db31905f3a584cca01fd1e49a
|
manifest_hash: 0646c148cf0e35f84678cd2cb46e9929051a1c6db31905f3a584cca01fd1e49a
|
||||||
target: esp32c3
|
target: esp32c3
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|||||||
@ -6,13 +6,17 @@
|
|||||||
// #define WIFI_SSID "UPC46273"
|
// #define WIFI_SSID "UPC46273"
|
||||||
// #define WIFI_AUTH WIFI_AUTH_WPA_PSK
|
// #define WIFI_AUTH WIFI_AUTH_WPA_PSK
|
||||||
// #define WIFI_PASS "SPHZHKRY"
|
// #define WIFI_PASS "SPHZHKRY"
|
||||||
#define WIFI_SSID "Wifi Ding"
|
// #define WIFI_SSID "Wifi Ding"
|
||||||
|
// #define WIFI_AUTH WIFI_AUTH_WPA_WPA2_PSK
|
||||||
|
// #define WIFI_PASS "Weet ik niet."
|
||||||
|
#define WIFI_SSID "MBCBootjes"
|
||||||
#define WIFI_AUTH WIFI_AUTH_WPA_WPA2_PSK
|
#define WIFI_AUTH WIFI_AUTH_WPA_WPA2_PSK
|
||||||
#define WIFI_PASS "Weet ik niet."
|
#define WIFI_PASS "hetgrootedok"
|
||||||
|
|
||||||
#define UDP_PORT 1234
|
// #define UDP_PORT 1234
|
||||||
|
|
||||||
// static uint8_t BoatId = 1;
|
#define BOAT_NAME "Test boat"
|
||||||
|
static uint8_t BoatId = 1;
|
||||||
|
|
||||||
#define HISTORY // enable cli history
|
#define HISTORY // enable cli history
|
||||||
|
|
||||||
@ -25,7 +29,7 @@
|
|||||||
#define SERVOS_CH6
|
#define SERVOS_CH6
|
||||||
|
|
||||||
#define WS_RX_BUFFER_LEN 512
|
#define WS_RX_BUFFER_LEN 512
|
||||||
#define WS_URL "ws://10.0.0.2:80/ws"
|
#define WS_URL "ws://10.254.0.2:8080/"
|
||||||
|
|
||||||
#define LOGGER_BUFFER_SIZE 65536
|
#define LOGGER_BUFFER_SIZE 65536
|
||||||
|
|
||||||
|
|||||||
@ -134,7 +134,7 @@ void app_main() {
|
|||||||
|
|
||||||
case STATE_WS_CONNECTING:
|
case STATE_WS_CONNECTING:
|
||||||
ws_client = ws_connect(WS_URL);
|
ws_client = ws_connect(WS_URL);
|
||||||
cli_ws_client = CLI_init((CLI_charOutFn)&charOut_uart, cmdList);
|
cli_ws_client = CLI_init((CLI_charOutFn)&ws_putchar, cmdList);
|
||||||
MainState = STATE_WS_WAIT_CONNECTION;
|
MainState = STATE_WS_WAIT_CONNECTION;
|
||||||
break;
|
break;
|
||||||
case STATE_WS_WAIT_CONNECTION:
|
case STATE_WS_WAIT_CONNECTION:
|
||||||
|
|||||||
@ -17,6 +17,11 @@ static void ws_event_handler(void* handler_args, esp_event_base_t base, int32_t
|
|||||||
case WEBSOCKET_EVENT_CONNECTED:
|
case WEBSOCKET_EVENT_CONNECTED:
|
||||||
LOG_I("ws_event_handler: connected");
|
LOG_I("ws_event_handler: connected");
|
||||||
client->connected = true;
|
client->connected = true;
|
||||||
|
|
||||||
|
char str[100];
|
||||||
|
snprintf(&str[0], 100, "%04d;3440;" BOAT_NAME "\n", BoatId);
|
||||||
|
esp_websocket_client_send_text(client->handle, &str[0], strlen(str), 1000);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WEBSOCKET_EVENT_DISCONNECTED:
|
case WEBSOCKET_EVENT_DISCONNECTED:
|
||||||
LOG_W("ws_event_handler: disconnected");
|
LOG_W("ws_event_handler: disconnected");
|
||||||
@ -125,4 +130,7 @@ int ws_getchar(ws_client_t client)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ws_putchar(ws_client_t client, char c);
|
void ws_putchar(ws_client_t client, char c)
|
||||||
|
{
|
||||||
|
esp_websocket_client_send_text(client->handle, &c, 1, 1000); //TODO: convert RTOS tick in ms
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user