forked from MaJerle/lwesp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General purpose WIN32 examples added
- Loading branch information
Showing
58 changed files
with
2,903 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
======================================================================== | ||
CONSOLE APPLICATION : project Project Overview | ||
======================================================================== | ||
|
||
AppWizard has created this project application for you. | ||
|
||
This file contains a summary of what you will find in each of the files that | ||
make up your project application. | ||
|
||
|
||
project.vcxproj | ||
This is the main project file for VC++ projects generated using an Application Wizard. | ||
It contains information about the version of Visual C++ that generated the file, and | ||
information about the platforms, configurations, and project features selected with the | ||
Application Wizard. | ||
|
||
project.vcxproj.filters | ||
This is the filters file for VC++ projects generated using an Application Wizard. | ||
It contains information about the association between the files in your project | ||
and the filters. This association is used in the IDE to show grouping of files with | ||
similar extensions under a specific node (for e.g. ".cpp" files are associated with the | ||
"Source Files" filter). | ||
|
||
project.cpp | ||
This is the main application source file. | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
Other standard files: | ||
|
||
StdAfx.h, StdAfx.cpp | ||
These files are used to build a precompiled header (PCH) file | ||
named project.pch and a precompiled types file named StdAfx.obj. | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
Other notes: | ||
|
||
AppWizard uses "TODO:" comments to indicate parts of the source code you | ||
should add to or customize. | ||
|
||
///////////////////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* \file esp_config.h | ||
* \brief Configuration file | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2018 Tilen Majerle | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE | ||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* This file is part of ESP-AT. | ||
* | ||
* Author: Tilen MAJERLE <[email protected]> | ||
*/ | ||
#ifndef __ESP_CONFIG_H | ||
#define __ESP_CONFIG_H | ||
|
||
/* | ||
* Rename this file to "esp_config.h" for your application | ||
*/ | ||
|
||
/* First include debug before any config changes */ | ||
#include "esp/esp_debug.h" | ||
|
||
/* | ||
* Check default configuration settings for more information | ||
*/ | ||
#define ESP_CFG_SYS_PORT ESP_SYS_PORT_WIN32 | ||
#define ESP_CFG_INPUT_USE_PROCESS 1 | ||
|
||
#define ESP_CFG_NETCONN 1 | ||
|
||
/* After user configuration, call default config to merge config together */ | ||
#include "esp/esp_config_default.h" | ||
|
||
#endif /* __ESP_CONFIG_H */ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/** | ||
* \file main.c | ||
* \brief Main file | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2018 Tilen Majerle | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without restriction, | ||
* including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, | ||
* and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE | ||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* This file is part of ESP-AT. | ||
* | ||
* Before you start using WIN32 implementation with USB and VCP, | ||
* check esp_ll_win32.c implementation and choose your COM port! | ||
*/ | ||
#include "stdafx.h" | ||
#include "esp/esp.h" | ||
#include "station_manager.h" | ||
#include "netconn_client.h" | ||
|
||
static espr_t esp_callback_func(esp_cb_t* cb); | ||
static espr_t esp_conn_callback_func(esp_cb_t* cb); | ||
|
||
#define CONN_HOST "example.com" | ||
#define CONN_PORT 80 | ||
|
||
/** | ||
* \brief Minimal connection request | ||
*/ | ||
static const uint8_t | ||
request_data[] = "" | ||
"GET / HTTP/1.1\r\n" | ||
"Host: " CONN_HOST "\r\n" | ||
"\r\n"; | ||
|
||
/** | ||
* \brief Program entry point | ||
*/ | ||
int | ||
main(void) { | ||
printf("Starting ESP application!\r\n"); | ||
|
||
/* | ||
* Initialize ESP with default callback function | ||
*/ | ||
esp_init(esp_callback_func); | ||
|
||
/* | ||
* Connect to access point. | ||
* | ||
* Try unlimited time until access point accepts up. | ||
* Check for station_manager.c to define preferred access points ESP should connect to | ||
*/ | ||
connect_to_preferred_access_point(1); | ||
|
||
/* | ||
* Start new connections to example.com | ||
* | ||
* Use non-blocking method and process further data in callback function | ||
*/ | ||
esp_conn_start(NULL, ESP_CONN_TYPE_TCP, CONN_HOST, CONN_PORT, NULL, esp_conn_callback_func, 0); | ||
esp_conn_start(NULL, ESP_CONN_TYPE_TCP, CONN_HOST, CONN_PORT, NULL, esp_conn_callback_func, 0); | ||
|
||
/* | ||
* An example of connection which should fail in connecting. | ||
* In this case, \ref ESP_CB_CONN_ERROR event should be triggered | ||
* in callback function processing | ||
*/ | ||
esp_conn_start(NULL, ESP_CONN_TYPE_TCP, CONN_HOST, 10, NULL, esp_conn_callback_func, 0); | ||
|
||
/* | ||
* Do not stop program here as we still need to wait | ||
* for commands to be processed | ||
*/ | ||
while (1) { | ||
esp_delay(1000); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/** | ||
* \brief Callback function for connection events | ||
* \param[in] cb: Event information with data | ||
* \return espOK on success, member of \ref espr_t otherwise | ||
*/ | ||
static espr_t | ||
esp_conn_callback_func(esp_cb_t* cb) { | ||
esp_conn_p conn; | ||
|
||
conn = esp_conn_get_from_evt(cb); /* Get connection handle from event */ | ||
switch (cb->type) { | ||
case ESP_CB_CONN_ACTIVE: { /* Connection just active */ | ||
printf("Connection %d active!\r\n", (int)esp_conn_getnum(conn)); | ||
printf("Sending data on connection %d to remote server\r\n", (int)esp_conn_getnum(conn)); | ||
esp_conn_send(conn, request_data, sizeof(request_data) - 1, NULL, 0); | ||
break; | ||
} | ||
case ESP_CB_CONN_DATA_RECV: { /* Connection data received */ | ||
esp_pbuf_p p; | ||
p = cb->cb.conn_data_recv.buff; /* Get received buffer */ | ||
if (p != NULL) { | ||
printf("Connection %d data received with %d bytes\r\n", | ||
(int)esp_conn_getnum(conn), (int)esp_pbuf_length(p, 1)); | ||
} | ||
break; | ||
} | ||
case ESP_CB_CONN_CLOSED: { /* Connection closed */ | ||
printf("Connection %d closed!\r\n", (int)esp_conn_getnum(conn)); | ||
break; | ||
} | ||
case ESP_CB_CONN_ERROR: { /* Error connecting to server */ | ||
const char* host = cb->cb.conn_error.host; | ||
esp_port_t port = cb->cb.conn_error.port; | ||
printf("Error connecting to %s:%d\r\n", host, (int)port); | ||
break; | ||
} | ||
} | ||
return espOK; | ||
} | ||
|
||
/** | ||
* \brief Event callback function for ESP stack | ||
* \param[in] cb: Event information with data | ||
* \return espOK on success, member of \ref espr_t otherwise | ||
*/ | ||
static espr_t | ||
esp_callback_func(esp_cb_t* cb) { | ||
switch (cb->type) { | ||
case ESP_CB_INIT_FINISH: { | ||
printf("Device initialized!\r\n"); | ||
break; | ||
} | ||
case ESP_CB_RESET: { | ||
printf("Device reset!\r\n"); | ||
break; | ||
} | ||
default: break; | ||
} | ||
return espOK; | ||
} |
Oops, something went wrong.