Code Monkey home page Code Monkey logo

lws-esp32-test-server-demos's Introduction

lws-esp32-test-server-demos

For use with lws-esp32-factory

This relies on setup capability provided by

https://github.com/warmcat/lws-esp32-factory

which runs from the "factory" partition on ESP32. This app is designed to run from the 2.9MB OTA partition.

New!

This includes the latest lws HTTP/2 support now, improved memory management for headers, and mbedTLS wrapper fixes to improve speed when multiple SSL connections are coming.

It also now supports ws-over-http2 tunelling, meaning all the ws connections and the http actions share the same tls tunnel. This makes a massive improvement in speed and reduced memory consumption.

As of 2018-04-12 only Chrome Canary 67 supports this new mode, but support in other browsers is coming. Chrome Canary 67 must be started to --enable-websocket-over-http2 to allow the new feature to operate.

About this demo

This demo is the standard lws test server using the standard lws test protocol plugins.

When you open the page the html / png assets are served over http/2 or http/1 depending on how you connected. Then the browser connects back over http/1 and upgrades to ws.

Basic auth is also demoed, see main/main.c for the details of how it works. You can visit the URL /secret, which you cannot see until you log in with "user" and "password". These are set in code in main/main.c.

It opens a lot of simultaneous https connections, one for each ws protocol and one for http/2 to carry the HTML and images, so on ESP32 it's a bit slow to start up.

The demo uses my mbedtls patches for dynamic buffer allocation, so compared to the unpatched mbedtls, you can open many tls connections without killing your RAM. NOTE You should set MBEDTLS_SSL_MAX_CONTENT_LEN to 16384 in your sdkconfig. The patched mbedtls will adapt the buffer sizes according to what is actually sent or received.

Build

This was built and tested againt esp-idf 17ac4bad7381e579e5a7775755cc25480da47d97 from 2018-09-11.

Clone and bring in the lws submodule (it's unpatched lws master)

  $ git clone [email protected]:warmcat/lws-esp32-test-server-demos.git
  $ git submodule update --init --recursive
 $ make lws_flash_ota ; make monitor

Using the lws test apps

See what IP your ESP32 got from your AP, the visit it in your browser using, eg https://192.168.2.249

If your dhcp server provides your dns, you can also reach the device using lws-serial, eg, https://lws-1234 or https://lws-1234.local

  • dumb increment should be updating at ~20Hz

  • mirror should let you draw in the canvas... open a second browser instance and they should be able to see each other's drawings

  • close testing should work

  • server info should reflect browsers open on the site dynamically

  • POST tests should pass the string and upload the file if one given

  • The button at the bottom should reset you into the setup / factory app

  • The "War and Peace" demo should load the 4MB text from the 1.2MB gzipped zip file directly, using gzipped data to the browser.

lws-esp32-test-server-demos's People

Contributors

igrr avatar lws-team avatar projectgus avatar spritetm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lws-esp32-test-server-demos's Issues

nvs basic auth accepts any user and pwd

Something is missing in the new nvs basic auth implementation. I do not have my ordinary Environment up at the moment so I have difficulties to trouble shoot.

It seems that the input-checking against the stored values does not work. I can log in giving any username and/or password...

Potentially I guess I could be the one to blame even though I do not think so: I noticed a weakness in the init of the lwsdemoba in main.c program. I modified the code to what I belive is a better and more robust implementation ("commit" was missing and the Close statement was only executed the first time the code ran). With the code below those have been corrected I hope:

if (nvs_open("lwsdemoba", NVS_READWRITE, &nvh) != ESP_OK) {
nvs_set_str(nvh, "Username", "Password");
nvs_commit(nvh);
}
nvs_close(nvh);

Stack overflow in task main at a variable point in time while running this demo

I started since today with a fresh install of msys2 etc, configured it for ESP-IDF development, rolled back to the ESP-IDF version that was mentioned here, was able to build both the factory image and this demo.

When I run it, there seems to be a crash at variable times. Sometimes I manage to get to the landing page where the socket of the dumb increment demo starts working (incrementing at a proper pace it seems), sometimes it crashes before that. It always seems to crash when I try to connect to it with a browser.

This is the output from the monitor, it's always this error:


***ERROR*** A stack overflow in task main has been detected.
abort() was called at PC 0x4008deac on core 0
0x4008deac: xEventGroupClearBits at C:/msys32/home/Wout/esp/esp-idf/components/freertos/event_groups.c:338


Backtrace: 0x4008dc23:0x3ffbae60 0x4008de95:0x3ffbae80 0x4008deac:0x3ffbaea0 0x4008abb0:0x3ffbaec0 0x4008c8d0:0x3ffbaef0 0x4008c886:0x3ffbaedc
0x4008dc23: xRingbufferSend at C:/msys32/home/Wout/esp/esp-idf/components/freertos/ringbuf.c:992

0x4008de95: xEventGroupClearBits at C:/msys32/home/Wout/esp/esp-idf/components/freertos/event_groups.c:338

0x4008deac: xEventGroupClearBits at C:/msys32/home/Wout/esp/esp-idf/components/freertos/event_groups.c:338

0x4008abb0: phy_pwdet_onetime_en at /home/cff/gittree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7_cal.c:2458 (discriminator 1)

0x4008c8d0: xTaskPriorityDisinherit at C:/msys32/home/Wout/esp/esp-idf/components/freertos/tasks.c:4193 (discriminator 3)

0x4008c886: xTaskPriorityDisinherit at C:/msys32/home/Wout/esp/esp-idf/components/freertos/tasks.c:4161 (discriminator 1)

Unable to connect to test server

Hi,

I been able to connect to the factory server, however after loading the test-server
I'm unable to connect to it?

What ip do I use, I'm currently using the same as the factory.

BR
Paul Grant

Submodule update problem

When I clone the repository (Nov 24) and then try to update the submodules I get the following:

lws-esp32-test-server-demos (master *=) $ git submodule update --init --recursive fatal: reference is not a tree: 9c7eed17ff370f543c93f6127e8467bde4a6727d Unable to checkout '9c7eed17ff370f543c93f6127e8467bde4a6727d' in submodule path 'components/libwebsockets'

Getting OOM when reconnecting socket

I want to reconnect to a socket if it is closed.

So I add a connect flag to LWS_CALLBACK_CLOSED

case LWS_CALLBACK_CLOSED:
	//vTaskDelay(1000/portTICK_PERIOD_MS);
	printf("re-connecting with token protocol\n");
	token_connect = true;
	token_received = false;
	break;

and that starts lws_client_connect_via_info in main.c

if (token_connect && token_conn_count >= 10) {
	printf("%s token protocol\n",tag);
	vTaskDelay(3000/portTICK_PERIOD_MS);
	token_connecting = true;
	token_req_sent = false;
	//token_connect = false;  
	wsi_token = NULL;
	i.pwsi = &wsi_token;
	i.protocol = "token-protocol";
	i.path = "/tokens";
	wsi_token = lws_client_connect_via_info(&i);
	token_conn_count = 0;
}

This works when I manually restart my server

[power-protocol] callback_token: 50
re-connecting with token protocol
4: error on reading from skt : 104
[lws_service loop]
[connection-loop] token protocol
4: _realloc: size 544: client wsi
4: _realloc: size 192: client ws struct
4: _realloc: size 5152: client stash
4: _realloc: size 996: ah struct
4: _realloc: size 512: ah data
4: lws_client_connect_2: 0x3ffd51c4: address 192.168.0.10

However if I leave my server running for a few hours, the socket inevitably closes and reconnecting fails giving "OOM"

[connection-loop] token protocol
4: _realloc: size 544: client wsi
4: _realloc: size 192: client ws struct
4: OOM

Can you tell me how I can auto-reconnect when a socket is closed? It's strange to me that it works when I manually restart the server but not when it happens after leaving it running.

Reset to configuration mode does not work

Unless I have missunderstood how it is supposed to work, I Think the "Reset to configuration mode" does not work. Pressing that button causes the esp32 to reboot, but it just starts STA-mode again and does not start its own AP. When accessing it via the web-browser I would have expected to see the factory-app but I only get the same test-demo app. See log below.

NOTE: I have the GPIO-buttons floating (not connected, so they could be at any level). Must the "reset to factory" button have an external pull (down/up) resistor for this to work?

?[35;1m[2018/02/02 19:00:22:0048] NOTICE: heap :165624 (+15560)
?[35;1m[2018/02/02 19:00:23:0041] NOTICE: heap :165400 (-224)
?[35;1m[2018/02/02 19:00:24:5682] NOTICE: _realloc: size 552: new server wsi (free heap 165628)
?[35;1m[2018/02/02 19:00:24:5722] NOTICE: ssl_pm_handshake
?[35;1m[22018/02/02 19:00:24:5727] NOTICE: mbedtls_handshake: ssl ret -0 state 1
?[35;1m[2018/02/02 19:00:24:5828] NOTICE: mbedtls_handshake: ssl ret -0 state 2
?[35;1m[2018/02/02 19:00:24:5909] NOTICE: mbedtls_handshake: ssl ret -0 state 3
?[35;1m[2018/02/02 19:00:24:6001] NOTICE: mbedtls_handshake: ssl ret -0 state 4
?[35;1m[2018/02/02 19:00:25:6332] NNOTICE: mbedtls_handshake: ssl ret -0 state 5
?[35;1m[2018/02/02 19:00:25:6340] NOTICE: mbedtls_handshake: ssl ret -0 state 6
??[35;1m[2018/02/02 19:00:25:6427] NOTICE: mbedtls_handshake: ssl ret -0 state 7
?[35;1m[2018/02/02 19:00:25:6450] NOTICE: mbedtls_handshake: ssl ret -0 state 8
?[35;1m[2018/02/02 19:00:25:6530] NOTTICE: mbedtls_handshake: ssl ret -6900 state 8
?[35;1m[2018/02/02 19:00:25:6601] NOTICE: _realloc: size 996: ah struct (free heap 150060)
?[35;1m[2018/02/02 19:00:25:6684] NOTICE: _realloc: size 900: ah data (free heap 147444)
?[35;1m[2018/022/02 19:00:25:6770] NOTICE: heap :147440 (-17960)
?[35;1m[2018/02/02 19:00:25:6875] NOTICE: ssl_pm_handshake
?[35;1m[2018/02/02 19:00:26:0899] NOTICE: mbedtls_handshake: ssl ret -0 state 9
?[35;1m[22018/02/02 19:00:26:0906] NOTICE: mbedtls_handshake: ssl ret -0 state 10
?[35;1m[2018/02/02 19:00:26:0950] NOTICE: mbedtls_handshake: ssl ret -0 state 11
?[35;1m[22018/02/02 19:00:26:1042] NOTICE: mbedtls_handshake: ssl ret -0 state 12
?[35;1m[2018/02/02 19:00:26:1126] NOTICE: mbedtls_handshake: ssl ret -0 state 13
?[35;1m[2018/02/02 19:00:26:1238] NOTICE: mbedtls_handshake: ssl ret -0 state 14
?[35;1m[2018/02/02 19:00:26:1255] NOTICE: mbedtls_handshake: ssl ret -0 state 15
?[35;1m[2018/02/02 19:00:26:1328] NOTICE: mbedtls_handshake: ssl ret -0 state 16
?[35;1m[2018/02/02 19:00:26:1393] NOTICE: _reallocc: size 208: h2n (free heap 154344)
?[35;1m[2018/02/02 19:00:26:1468] NOTICE: _realloc: size 780: dynamic table entries (free heap 153560)
?[35;1m[2018/02/02 19:00:26:1565] NOTICE: heap :153560 (+6120)
?[35;1m[2018/02/02 19:00:26:1673] NOTICE: _realloc: size 512: h2 rx scratch (free heap 153388)
?[35;1m[2018/02/02 19:00:26:1727] NOTICE: _realloc: size 48: pps (free heap 155232)
?[35;1m[2018/02/02 19:00:26:1789] NOTICE: _realloc: sizee 48: pps (free heap 155184)
?[35;1m[2018/02/02 19:00:26:2003] NOTICE: _realloc: size 552: new server wsi (free heap 154896)
?[35;1m[2018/02/02 19:00:26:2010] NOTICE: _realloc: size 996: ah struct (free heap 153896)
?[35;1m[2018/02/02 19:00:26:2068] NOTICE: _realloc: size 900: ah data (free heap 152992)
?[35;1m[2018/02/02 19:00:26:2159] NOTICE: _realloc: size 11: hpack dyn (free heap 152977)
?[35;1m[2018/02/02 19:00:26:2235] NOTICE: _realloc: size 13: hpack dyn ((free heap 152963)
?[35;1m[2018/02/02 19:00:26:2337] NOTICE: _realloc: size 4: hpack dyn (free heap 152956)
?[35;1m[2018/02/02 19:00:26:2400] NOTICE: _realloc: size 22: hpack dyn (free heap 152934)
?[35;1m[2018/02/02 19:00:26:2481] NOTICE: _realloc: size 15: hpack dyn (free heap 152917)
?[35;1m[2018/02/02 19:00:26:2566] NOTICE: _realloc:: size 130: hpack dyn (free heap 152782)
?[35;1m[2018/02/02 19:00:26:2647] NOTICE: _realloc: size 18: hpack dyn (free heap 152758)
?[35;1m[2018/02/02 19:00:26:2785] NOTICE: esp32_lws_fops_open: esplws-rtf/index.html
?[31;1m[2018/02/02 19:00:26:2828] ERR: Unable to open 'esplws-rtf/index.html'
?[35;1m[2018/02/02 19:00:26:2878] NOTICCE: lws_esp32_restart_guided: b00bcafe
I (143195) wifi: state: run -> init (0)
I (143195) wifi: pm stop, total sleep time: 0/136817427

I (143205) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (143255) wifi: flush txq
I (143255) wifi: stop sw txq
I (143255) wifi: lmac stop hw txq
?[35;1m[2018/02/02 19:00:26:3507] NOTICE: SYSTEM_EVENT_STA_DISCONNECTED
?[35;1m[20118/02/02 19:00:26:3536] NOTICE: gapss from LWS_GAPSS_STAT_HAPPY to LWS_GAPSS_SCAN
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4356
load:00x40078000,len:0
load:0x40078000,len:11948
entry 0x40078dc8
?[35;1m[2018/02/02 19:00:26:3595] NOTICE: gapss from LWS_GAPSS_INITIAL to LWS_GAPSS_SCAN
I (155) wifi: wifi firmware version: 9adebde
I (155) wifi: config NVS flash: disabled
I (155) wifi: config nano formating: disabled
I (165) wifi: Init dynamic tx buffer num: 32
I (165) wifi: Init data frame dynamic rx buffer num: 20
I (165) wifi: Init management frame dynamic rx buffer num: 20
I (175) wifi: wifi driver task: 3ffc3c30, prio:23, stack:4096
I (185) wifi: Init static rx buffer num: 20
I (185) wifi: Init dynamic rx buffer num: 20
I (185) wifi: wifi power manaager task: 0x3ffcc740 prio: 21 stack: 2560
I (255) wifi: mode : sta (30:ae:a4:0e:99:e4)
?[35;1m[2018/02/02 19:00:26:4698] NOTICE: SYSTEM_EVENT_STA_DISCONNECTED
?[35;1m[2018/02/02 19:00:26:4703] NOTICE: gapss from LWS_GAPSS_SCAN to LWS_GAPSS_SCAN
?[35;1m[2018/02/02 19:00:26:4766] NOTICE: lws_esp32_scan_timer_cb
?[35;1m[2018/02/02 19:00:26:4860] NOTICE: _realloc: size 560: context (free heap 207608)
?[35;1m[2018/02/02 19:00:26:4907] NOTICE: _realloc: size 900: pt_serv_buf (free heap 206620)
?[35;1m[2018/02/02 19:00:26:4990] NOTICE: _realloc:: size 80: fds table (free heap 206536)
?[35;1m[2018/02/02 19:00:26:5072] NOTICE: _realloc: size 120: esp32 lws_lookup (free heap 206412)
?[35;1m[2018/02/02 19:00:26:5161] NOTICE: mem: platform fd map: 120 bytes
?[35;1m[2018/02/02 19:00:26:5233] NOTICE: _realloc: size 552: event pipe wsi (free heap 205856)
?[35;1m[2018/02/02 19:00:26:5332] NOTICE: ROMFS length 1517KiB
{
"schema": "lws1",
"model": "lws",
"builder": "Fredrik-laptop",
"app": "lws-esp32-test-server-demos",
"user": "fredrik",
"giit": "9b126e1-dirty",
"date": "den 2 feb 2018 18:14:14",
"unixtime": "1517591653",
"file": "lws-esp32-test-server-demos-1517591653.bin",
"factory": "0"
}
?[35;1m[2018/02/02 19:00:26:5652] NOTICE: _realloc: size 488: create vhost (free heap 205920)
?[35;1m[2018/02/02 19:00:26:5738] NOTICE: _realloc: size 23: vh paths (free heap 205893)
?[35;1m[2018/02/02 19:00:26:5819] NOTICE: _realloc: size 224: vhost-specific plugin table (free heap 205664)
?[35;1m[2018/02/02 19:00:26:5919] NOTTICE: _realloc: size 28: same vh list (free heap 205632)
?[35;1m[2018/02/02 19:00:26:6002] NOTICE: Creating Vhost 'station' port 443, 7 protocols, IPv6 off
?[35;1m[2018/02/02 19:00:26:6095] NOTICE: Using SSL mode
?[35;1m[2018/02/02 19:00:26:6158] NOTICE: _realloc: size 1209: alloc_file (free heap 204255)
?[35;1m[2018/02/02 19:00:26:6269] NOTICE: alloc_file: nvs: read ap-cert.pem, 1208 bytes
parsing as der
?[35;1m[2018/02/02 19:00:26:6341] NOTICE: _realloc: size 1680: alloc_file (free heap 201880)
?[35;1m[2018/02/02 19:00::26:6461] NOTICE: alloc_file: nvs: read ap-key.pem, 1679 bytes
?[35;1m[2018/02/02 19:00:26:7365] NOTICE: no client cert required
?[35;1m[2018/02/02 19:00:26:7373] NOTICE: HTTP2 / ALPN enabled
?[35;1m[2018/02/02 19:00:26:7383] NOTICE: created client ssl context for station
?[35;1m[2018/02/02 19:00:26:7475] NOTICE: _realloc: size 552: listen wsi (free heap 200720)
?[35;1m[2018/02/02 19:00:26:7550] NOTICE: lws_esp32_selfsigned: station
?[35;1m[2018/02/02 19:00:26:7611] NOTICE: lws_esp32_selfsigned: certs exist
?[35;1m[2018/02/022 19:00:26:7683] NOTICE: _realloc: size 1209: alloc_file (free heap 195459)
?[35;1m[2018/02/02 19:00:26:7799] NOTICE: alloc_file: nvs: read ap-cert.pem, 1208 bytes
parsing as der
?[35;1m[2018/02/02 19:00:26:7881] NOTICE: _realloc: size 1680: alloc_file (free heap 194976)
?[35;1m[2018/02/02 19:00:26:7991] NOTICE: alloc_file: nvs: read ap-key.pem, 1679 bytes
?[35;1m[2018/02/02 19:00:26:8902] NOTICE: _realloc: size 28: protocol_vh_privs (free heap 196656)
?[35;1m[2018/02/02 19:00:26:8908] NOTICE: _realloc: size 16: vhh priv (free heap 196636)
?[35;1m[2018/02/02 19:00:26:8967] NOTICE: _realloc: size 4: vh priv (free heap 196572)
?[35;1m[2018/02/02 19:00:26:9046] NOTICE: _realloc: size 20: vh priv (free heap 196552)
?[35;1m[2018/02/02 19:00:26:9128] NOTICE: vhost station: cert expiry: 11654d
?[35;1m[2018/02/02 19:00:26:9201] NOTICE: heap :196552 (-10968)
?[35;1m[2018/02/02 19:00:26:9261] NOTICE: _realloc: size 552: tid probe (free heap 196000)
?[35;1m[2018/02/02 19:00:28:0289] NOTICE: heap :196380 (-172)
?[35;1m[2018/002/02 19:00:28:8942] NOTICE: SYSTEM_EVENT_SCAN_DONE
?[35;1m[2018/02/02 19:00:28:8955] NOTICE: gapss from LWS_GAPSS_SCAN to LWS_GAPSS_STAT
I (2815) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (3375) wifi: state: init -> auth (b0)
I (3375) wifi: sttate: auth -> assoc (0)
?[35;1m[2018/02/02 19:00:29:5835] NOTICE: heap :196696 (+316)

I (3375) wifi: state: assoc -> run (10)
I ((3455) wifi: connected with MyRouterSSID, channel 1
?[35;1m[2018/02/02 19:00:29:9736] NOTICE:: SYSTEM_EVENT_STA_GOT_IP
?[35;1m[2018/02/02 19:00:29:9768] NOTICE: gapss from LWS_GAPSS_STAT to LWS_GAPSS_STAT_HAPPY
?[35;1m[2018/02/02 19:00:29:9887] NOTICE: _realloc: size 136: group (free heap 190312)
?[35;1m[2018/02/02 19:00:29:9892] NOTICE: --- Got IP 192.168.101.45
?[35;1m[20018/02/02 19:00:30:0291] NOTICE: heap :189912 (-6784)
?[35;1m[[2018/02/02 19:00:31:0135] NOTICE: heap :190096 (+184)

Compiling for ESP32 in MSYS2 environment under Windows 10

I'm trying to compile these demos under Windows 10 in the MSYS2 environment provided by ESP-IDF.

I installed the toolchain and MSYS2 shell as described here - http://esp-idf.readthedocs.io/en/latest/get-started/windows-setup.html

This is all working fine and I'm compiling other ESP32 code. However the lws-esp32 implementation seems to require cmake to compile. This does not appear to be bundled in the MSYS2 environment distributed by ESP-IDF. Failing with the following error:

doing lws cmake
/bin/sh: line 2: cmake: command not found
make[2]: *** No targets specified and no makefile found.  Stop.
make[1]: *** [/d/Coding/lws-esp32-test-server-demos/components/libwebsockets/component.mk:12: build] Error 2
make: *** [C:/msys32/home/ben/esp/esp-idf/make/project.mk:435: component-libwebsockets-build] Error 2

Installing with pacman -S mingw-w64-i686-cmake gets us over that hurdle. However compilation then seems to be targetting MSVC rather than the cross compilation target:

$ make
doing lws cmake
-- Building for: Visual Studio 14 2015
-- The C compiler identification is MSVC 19.0.23918.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- broken

At this point I'm kind of stuck, the cmake call in the component.mk seems to be doing the right thing, passing the xtensa-esp32-elf-gcc location for CROSS_PATH and setting the CMAKE_TOOLCHAIN_FILE to the /contib/cross-esp32.cmake file. But it seems to be being ignored.

Any suggestions?

Sending adc data as client

I am trying to send data from the adc to a server. I used protocol_dumb_increment.c as a guide and added this function however lws_client_connect_via_info crashes:

void adc1task(struct lws * wsi)
{
  // initialize ADC
  adc1_config_width(ADC_WIDTH_12Bit);
  adc1_config_channel_atten(MIC_CHANNEL,ADC_ATTEN_11db);
  int n, m;

  // connect to ws server
  struct lws_client_connect_info i;
  struct lws_context *context = lws_get_context(wsi);
  memset(&i, 0, sizeof(i));
  i.address = "192.168.0.2";
  i.host = "192.168.0.2:4000";
  i.origin = NULL;
  i.port = 4000;
  i.context = context;
  i.ietf_version_or_minus_one = -1;
  lws_client_connect_via_info(&i);

  unsigned char buf[LWS_PRE + 20];
  unsigned char *voltage = &buf[LWS_PRE];

  while(1){
      n = lws_snprintf((char *)voltage, sizeof(buf) - LWS_PRE, "%d", adc1_get_voltage(MIC_CHANNEL));
      m = lws_write(wsi, voltage, n, LWS_WRITE_TEXT);
      if (m < n)
        printf("ERROR %d writing to socket\n", n);
      printf("adc1 value:%s\n",voltage);
      vTaskDelay(1000/portTICK_PERIOD_MS);
  }
}

Here is the complete file: https://github.com/physiii/liger/blob/master/code/main/plugins/protocol_lws_microphone.c

test server as ap

hi,

i want to use the test server as AP instead of station. I changed to line
in main.c
lws_esp32_wlan_start_station() to lws_esp32_wlan_start_ap()

1- only one client can connect. Is this true? or only my experience. Can i change the number?
2- i get spontaneous stack overflow and can not backtrace it, because my compiler is in cloud computer. Is there any other way?

cmake issue

Hi,

When I build this project, I got the following error output:

_cp: cannot stat ‘/home/nicholas/Sources/test/lws-esp32-test-server-demos/main/../build/lws-esp32.bin’: No such file or directory
Original length: 0x5b39d8 ( 5978584)
After ROMFS + Build info: 0x720715 ( 7472917)
doing lws cmake
CMake Error at cross-esp32.cmake:15 (SET):
Syntax error in cmake code at

/home/nicholas/Sources/test/lws-esp32-test-server-demos/components/libwebsockets/cross-esp32.cmake:15

when parsing string

-nostdlib -Wall -Werror \

    -I${BUILD_DIR_BASE}/include \

    -I${IDF_PATH}/components/mdns/include \

▽ -I${IDF_PATH}/components/driver/include \

    -I${IDF_PATH}/components/spi_flash/include \

    -I${IDF_PATH}/components/nvs_flash/include \

    -I${IDF_PATH}/components/tcpip_adapter/include \

    -I${IDF_PATH}/components/lwip/include/lwip/posix \

    -I${IDF_PATH}/components/lwip/include/lwip \

    -I${IDF_PATH}/components/lwip/include/lwip/port \

    -I${IDF_PATH}/components/esp32/include/ \

    -I${IDF_PATH}/components/bootloader_support/include/ \

    -I${IDF_PATH}/components/app_update/include/ \

    ${LWS_C_FLAGS} -Os \

    -I${IDF_PATH}/components/nvs_flash/test_nvs_host \

    -I${IDF_PATH}/components/freertos/include

syntax error, unexpected cal_SYMBOL, expecting $end (30)
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/CMakeDetermineSystem.cmake:93 (include)
CMakeLists.txt:7 (project)

CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Could not find cmake module file: /home/nicholas/Sources/test/lws-esp32-test-server-demos/build/libwebsockets/CMakeFiles/2.8.12.2/CMakeCCompiler.cmake
-- Configuring incomplete, errors occurred!
make[2]: *** No targets specified and no makefile found. Stop.
make[1]: *** [build] Error 2
make: *** [libwebsockets-build] Error 2_

Is there Syntax error in cross-esp32.cmake?

How to use authentication with websockets?

This is not an issue, but rather a request for an additional feature/demo:

lws-esp32-factory and lws-esp32-test-server-demos make use of ssl and certificates in a really nice way. I am impressed!

But I think I also need some sort of authentication. Basic-auth would be ok. I do not find my way through the lws-code well enough yet to understand where to start. Would it be easy for you to add a login prompt as part of the lws-esp32-test-server-demos?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.