Comments (6)
I made some changes to the network interface connection handling to give a solution to this. The start function no longer blocks until a connection has been established. The application can use the new ´´function network_interface_wifi_station_espressif_ip_up()´´ to check the interface status.
See this commit for the implementaiton: b442715
Note that that commit is not yet tested. I'll test it after work.
Let me know if you have other suggestions about how to improve the API.
Thanks.
from simba.
i am using esp12e board, platformio 3.0.1
main.c code like this, dhcp get ip address 192.168.201.117
but this code can not open http 8000 port
is there something i forgot to do ?
thank you :)
#include "simba.h"
#include "esp_wifi.h"
#include "esp_sta.h"
static struct network_interface_wifi_station_espressif_t wifi;
static struct http_server_t server;
static struct shell_t shell;
THRD_STACK(listener_stack, 1024);
THRD_STACK(connection_stack, 1500);
static int request_index(struct http_server_connection_t *connection_p,
struct http_server_request_t *request_p);
static struct http_server_route_t routes[] = {
{ .path_p = "/", .callback = request_index },
{ .path_p = NULL, .callback = NULL }
};
static struct http_server_listener_t listener = {
.address_p = "192.168.201.117",
.port = 8000,
.thrd = {
.name_p = "http_listener",
.stack = {
.buf_p = listener_stack,
.size = sizeof(listener_stack)
}
}
};
static struct http_server_connection_t connections[] = {
{
.thrd = {
.name_p = "http_conn_0",
.stack = {
.buf_p = connection_stack,
.size = sizeof(connection_stack)
}
}
},
{ .thrd = { .name_p = NULL } }
};
static int request_index(struct http_server_connection_t *connection_p,
struct http_server_request_t *request_p)
{
static const char index_html[] = "Simba";
struct http_server_response_t response;
/* Only the GET action is supported. */
if (request_p->action != http_server_request_action_get_t) {
return (-1);
}
/* Create the response. */
response.code = http_server_response_code_200_ok_t;
response.content.type = http_server_content_type_text_html_t;
response.content.buf_p = index_html;
response.content.size =
strlen(response.content.buf_p);
return (http_server_response_write(connection_p,
request_p,
&response));
}
static int no_route(struct http_server_connection_t *connection_p,
struct http_server_request_t *request_p)
{
struct http_server_response_t response;
/* Create the response. */
response.code = http_server_response_code_404_not_found_t;
response.content.type = http_server_content_type_text_html_t;
response.content.buf_p = NULL;
response.content.size = 0;
return (http_server_response_write(connection_p,
request_p,
&response));
}
int main()
{
sys_start();
log_set_default_handler_output_channel(sys_get_stdout());
inet_module_init();
socket_module_init();
network_interface_module_init();
ping_module_init();
network_interface_wifi_station_espressif_module_init();
network_interface_wifi_station_espressif_init(&wifi, "ssid", "password");
network_interface_add(&wifi.network_interface);
network_interface_start(&wifi.network_interface);
http_server_init(&server, &listener, connections, NULL, routes, no_route);
http_server_start(&server);
shell_init(&shell, sys_get_stdin(), sys_get_stdout(), NULL, NULL, "admin", "admin");
shell_main(&shell);
return (0);
}
from simba.
The ip address of the TCP socket listening for connection is hard coded in the http server. I will fix that bug tonight.
Meanwhile, replace
https://github.com/eerimoq/simba/blob/master/src/inet/http_server.c#L325
with
inet_aton(listener_p->address_p, &addr.ip);
so the ip address will be correct.
from simba.
esp12e also support softap mode
is there some plan to add module support it ?
from simba.
No not for now. I'm all busy porting MicroPython to Simba (Pumbaa). Python on microcontrollers is quite nice =)
from simba.
A fix for the HTTP server problem has been implemented and will be included in future releases.
from simba.
Related Issues (20)
- Missing serial port configuration parameters for shell example HOT 2
- Use external interrupts with esp01 HOT 5
- Upgrade support for esp family HOT 3
- std_read() HOT 3
- Reduce Memory Usage HOT 2
- SoftwareSerial RS485 Arduino.h to Simba.h HOT 3
- STM32F103C8T6 Support
- Not all ports have nvm_port_vwrite HOT 1
- Fuzzy testing brainstorming
- New user, unable to compile blink in Arduino ESP12E
- Pro Micro blink example not working HOT 2
- Uploading SPIFFS to ESP8266 HOT 1
- Unable to build with DHT from PlatformIO HOT 2
- Is there missing struct initialization? (http_websocket_client_connect) HOT 2
- Timer timeouts in threads are broken. HOT 2
- Vendor link on platformio broken HOT 1
- Request: Comparison Chart HOT 1
- nanoatmega328new board should be mapped to arduino nano HOT 1
- PIN_INPUT_PULL_UP has been deleted HOT 5
- Question about pure MCU work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simba.