Compare commits
22 Commits
master
...
text_rende
| Author | SHA1 | Date |
|---|---|---|
|
|
9ce79aef85 | 10 months ago |
|
|
3a5c9abe34 | 10 months ago |
|
|
83fd0e8a8b | 10 months ago |
|
|
0e8b867323 | 10 months ago |
|
|
6a9ee38a99 | 2 years ago |
|
|
b781dc0d1b | 2 years ago |
|
|
0b25ceb40d | 2 years ago |
|
|
1ab009feef | 2 years ago |
|
|
f062b492fc | 2 years ago |
|
|
23eb8d5bce | 2 years ago |
|
|
28410daead | 2 years ago |
|
|
9faf03daf0 | 2 years ago |
|
|
7dd9ed7d0f | 2 years ago |
|
|
17e2480102 | 2 years ago |
|
|
22a02d1d66 | 2 years ago |
|
|
2699d85193 | 2 years ago |
|
|
56a58fca79 | 4 years ago |
|
|
32a71e956f | 4 years ago |
|
|
8057e659a3 | 4 years ago |
|
|
908ecfc1d7 | 4 years ago |
|
|
c4519fd92f | 4 years ago |
|
|
5232d4c089 | 4 years ago |
@ -1,6 +1,6 @@
|
||||
# The following lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(hello-world)
|
||||
project(hello_world)
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
idf_component_register(SRCS "hello_world_main.c"
|
||||
INCLUDE_DIRS "")
|
||||
idf_component_register(SRCS "main.c" "font.c" "display.c" "text.c" "wlan.c" "https.c" "lwjson/lwjson/src/lwjson/lwjson.c"
|
||||
REQUIRES esp_driver_gpio esp_wifi nvs_flash esp_timer esp-tls
|
||||
INCLUDE_DIRS "." "lwjson/lwjson/src/include")
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
menu "WiFi Credentials"
|
||||
|
||||
config ESP_WIFI_SSID
|
||||
string "WiFi SSID"
|
||||
default "myssid"
|
||||
help
|
||||
SSID (network name) for the example to connect to.
|
||||
|
||||
config ESP_WIFI_PASSWORD
|
||||
string "WiFi Password"
|
||||
default "mypassword"
|
||||
help
|
||||
WiFi password (WPA or WPA2) for the example to use.
|
||||
|
||||
choice ESP_WIFI_SAE_MODE
|
||||
prompt "WPA3 SAE mode selection"
|
||||
default ESP_WPA3_SAE_PWE_BOTH
|
||||
help
|
||||
Select mode for SAE as Hunt and Peck, H2E or both.
|
||||
config ESP_WPA3_SAE_PWE_HUNT_AND_PECK
|
||||
bool "HUNT AND PECK"
|
||||
config ESP_WPA3_SAE_PWE_HASH_TO_ELEMENT
|
||||
bool "H2E"
|
||||
config ESP_WPA3_SAE_PWE_BOTH
|
||||
bool "BOTH"
|
||||
endchoice
|
||||
|
||||
config ESP_WIFI_PW_ID
|
||||
string "PASSWORD IDENTIFIER"
|
||||
depends on ESP_WPA3_SAE_PWE_HASH_TO_ELEMENT|| ESP_WPA3_SAE_PWE_BOTH
|
||||
default ""
|
||||
help
|
||||
password identifier for SAE H2E
|
||||
|
||||
config ESP_MAXIMUM_RETRY
|
||||
int "Maximum retry"
|
||||
default 5
|
||||
help
|
||||
Set the Maximum retry to avoid station reconnecting to the AP unlimited when the AP is really inexistent.
|
||||
|
||||
choice ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD
|
||||
prompt "WiFi Scan auth mode threshold"
|
||||
default ESP_WIFI_AUTH_WPA2_PSK
|
||||
help
|
||||
The weakest authmode to accept in the scan mode.
|
||||
This value defaults to ESP_WIFI_AUTH_WPA2_PSK incase password is present and ESP_WIFI_AUTH_OPEN is used.
|
||||
Please select ESP_WIFI_AUTH_WEP/ESP_WIFI_AUTH_WPA_PSK incase AP is operating in WEP/WPA mode.
|
||||
|
||||
config ESP_WIFI_AUTH_OPEN
|
||||
bool "OPEN"
|
||||
config ESP_WIFI_AUTH_WEP
|
||||
bool "WEP"
|
||||
config ESP_WIFI_AUTH_WPA_PSK
|
||||
bool "WPA PSK"
|
||||
config ESP_WIFI_AUTH_WPA2_PSK
|
||||
bool "WPA2 PSK"
|
||||
config ESP_WIFI_AUTH_WPA_WPA2_PSK
|
||||
bool "WPA/WPA2 PSK"
|
||||
config ESP_WIFI_AUTH_WPA3_PSK
|
||||
bool "WPA3 PSK"
|
||||
config ESP_WIFI_AUTH_WPA2_WPA3_PSK
|
||||
bool "WPA2/WPA3 PSK"
|
||||
config ESP_WIFI_AUTH_WAPI_PSK
|
||||
bool "WAPI PSK"
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
@ -0,0 +1 @@
|
||||
Subproject commit cb8693b058ba302f4829ec6d03f609ac6f848546
|
||||
@ -0,0 +1,74 @@
|
||||
#include "driver/gpio.h"
|
||||
#include "display.h"
|
||||
|
||||
uint8_t fb[64][128][3];
|
||||
|
||||
void write_bits(uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2){
|
||||
gpio_set_level(GPIO_R1, r1);
|
||||
gpio_set_level(GPIO_G1, g1);
|
||||
gpio_set_level(GPIO_B1, b1);
|
||||
gpio_set_level(GPIO_R2, r2);
|
||||
gpio_set_level(GPIO_G2, g2);
|
||||
gpio_set_level(GPIO_B2, b2);
|
||||
}
|
||||
|
||||
void write_address(uint8_t addr){
|
||||
gpio_set_level(GPIO_A, addr&0x01);
|
||||
gpio_set_level(GPIO_B, (addr&0x02)>>1);
|
||||
gpio_set_level(GPIO_C, (addr&0x04)>>2);
|
||||
gpio_set_level(GPIO_D, (addr&0x08)>>3);
|
||||
gpio_set_level(GPIO_E, (addr&0x10)>>4);
|
||||
}
|
||||
|
||||
void latch(){
|
||||
gpio_set_level(GPIO_LAT, 0);
|
||||
gpio_set_level(GPIO_LAT, 1);
|
||||
}
|
||||
|
||||
static void clock(){
|
||||
gpio_set_level(GPIO_CLK, 1);
|
||||
gpio_set_level(GPIO_CLK, 0);
|
||||
}
|
||||
|
||||
void display_init(){
|
||||
gpio_config_t io_conf;
|
||||
//disable interrupt
|
||||
io_conf.intr_type = GPIO_INTR_DISABLE;
|
||||
//set as output mode
|
||||
io_conf.mode = GPIO_MODE_OUTPUT;
|
||||
//bit mask of the pins that you want to set,e.g.GPIO18/19
|
||||
io_conf.pin_bit_mask =
|
||||
(1ULL<<GPIO_LAT)|(1ULL<<GPIO_OE)|(1ULL<<GPIO_CLK)
|
||||
|(1ULL<<GPIO_R1)|(1ULL<<GPIO_G1)|(1ULL<<GPIO_B1)|(1ULL<<GPIO_R2)|(1ULL<<GPIO_G2)|(1ULL<<GPIO_B2)
|
||||
|(1ULL<<GPIO_A)|(1ULL<<GPIO_B)|(1ULL<<GPIO_C)|(1ULL<<GPIO_D)|(1ULL<<GPIO_E);
|
||||
//disable pull-down mode
|
||||
io_conf.pull_down_en = 0;
|
||||
//disable pull-up mode
|
||||
io_conf.pull_up_en = 0;
|
||||
//configure GPIO with the given settings
|
||||
gpio_config(&io_conf);
|
||||
|
||||
gpio_set_level(GPIO_OE, 0);
|
||||
|
||||
write_bits(0,0,0,0,0,0);
|
||||
for(uint8_t i=0;i<128;i++){
|
||||
clock();
|
||||
}
|
||||
latch();
|
||||
gpio_set_level(GPIO_OE, 1);
|
||||
gpio_set_level(GPIO_OE, 0);
|
||||
}
|
||||
|
||||
void display_cycle(void* arg){
|
||||
static uint8_t line = 0;
|
||||
|
||||
for(uint8_t i=0;i<128;i++){
|
||||
write_bits(fb[line][i][0],fb[line][i][1],fb[line][i][2],fb[32+line][i][0],fb[32+line][i][1],fb[32+line][i][2]);
|
||||
clock();
|
||||
}
|
||||
gpio_set_level(GPIO_OE, 1);
|
||||
latch();
|
||||
write_address(line);
|
||||
gpio_set_level(GPIO_OE, 0);
|
||||
line = (line + 1)%32;
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
#ifndef _DISPLAY_H_
|
||||
#define _DISPLAY_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define DISPLAY_WIDTH 128
|
||||
#define DISPLAY_HEIGHT 64
|
||||
|
||||
#define GPIO_R1 25
|
||||
#define GPIO_G1 26
|
||||
#define GPIO_B1 27
|
||||
#define GPIO_R2 14
|
||||
#define GPIO_G2 12
|
||||
#define GPIO_B2 13
|
||||
|
||||
#define GPIO_CLK 16
|
||||
#define GPIO_OE 15
|
||||
#define GPIO_LAT 4
|
||||
|
||||
#define GPIO_A 23
|
||||
#define GPIO_B 19
|
||||
#define GPIO_C 5
|
||||
#define GPIO_D 17
|
||||
#define GPIO_E 18
|
||||
|
||||
|
||||
extern uint8_t fb[64][128][3];
|
||||
|
||||
void write_bits(uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2);
|
||||
void write_address(uint8_t addr);
|
||||
void latch(void);
|
||||
void display_init(void);
|
||||
void display_cycle(void* arg);
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,256 @@
|
||||
#include <stdint.h>
|
||||
|
||||
const uint8_t font[256][7] = {
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //
|
||||
{0x5f,0x00,0x00,0x00,0x00,0x00,0x00}, // !
|
||||
{0x03,0x00,0x03,0x00,0x00,0x00,0x00}, // "
|
||||
{0x14,0x7f,0x14,0x7f,0x14,0x00,0x00}, // #
|
||||
{0x6f,0x49,0xc9,0x7b,0x00,0x00,0x00}, // $
|
||||
{0x63,0x13,0x08,0x64,0x63,0x00,0x00}, // %
|
||||
{0x7f,0xc9,0x49,0x63,0x00,0x00,0x00}, // &
|
||||
{0x03,0x00,0x00,0x00,0x00,0x00,0x00}, // '
|
||||
{0x3e,0x41,0x00,0x00,0x00,0x00,0x00}, // (
|
||||
{0x41,0x3e,0x00,0x00,0x00,0x00,0x00}, // )
|
||||
{0x0a,0x04,0x1f,0x04,0x0a,0x00,0x00}, // *
|
||||
{0x08,0x08,0x3e,0x08,0x08,0x00,0x00}, // +
|
||||
{0xc0,0x00,0x00,0x00,0x00,0x00,0x00}, // ,
|
||||
{0x08,0x08,0x08,0x08,0x00,0x00,0x00}, // -
|
||||
{0x40,0x00,0x00,0x00,0x00,0x00,0x00}, // .
|
||||
{0x60,0x10,0x08,0x04,0x03,0x00,0x00}, // /
|
||||
{0x7f,0x41,0x41,0x7f,0x00,0x00,0x00}, // 0
|
||||
{0x02,0x03,0x7f,0x00,0x00,0x00,0x00}, // 1
|
||||
{0x7b,0x49,0x49,0x6f,0x00,0x00,0x00}, // 2
|
||||
{0x63,0x49,0x49,0x7f,0x00,0x00,0x00}, // 3
|
||||
{0x0f,0x08,0x08,0x7f,0x00,0x00,0x00}, // 4
|
||||
{0x6f,0x49,0x49,0x7b,0x00,0x00,0x00}, // 5
|
||||
{0x7f,0x49,0x49,0x7b,0x00,0x00,0x00}, // 6
|
||||
{0x03,0x01,0x01,0x7f,0x00,0x00,0x00}, // 7
|
||||
{0x7f,0x49,0x49,0x7f,0x00,0x00,0x00}, // 8
|
||||
{0x0f,0x09,0x09,0x7f,0x00,0x00,0x00}, // 9
|
||||
{0x22,0x00,0x00,0x00,0x00,0x00,0x00}, // :
|
||||
{0xc1,0x00,0x00,0x00,0x00,0x00,0x00}, // ;
|
||||
{0x08,0x14,0x22,0x00,0x00,0x00,0x00}, // <
|
||||
{0x14,0x14,0x14,0x14,0x00,0x00,0x00}, // =
|
||||
{0x22,0x14,0x08,0x00,0x00,0x00,0x00}, // >
|
||||
{0x03,0x59,0x09,0x0f,0x00,0x00,0x00}, // ?
|
||||
{0x7f,0x41,0x5d,0x55,0x5f,0x00,0x00}, // @
|
||||
{0x7f,0x09,0x09,0x7f,0x00,0x00,0x00}, // A
|
||||
{0x7f,0x49,0x49,0x77,0x00,0x00,0x00}, // B
|
||||
{0x7f,0x41,0x41,0x63,0x00,0x00,0x00}, // C
|
||||
{0x7f,0x41,0x41,0x3e,0x00,0x00,0x00}, // D
|
||||
{0x7f,0x49,0x49,0x63,0x00,0x00,0x00}, // E
|
||||
{0x7f,0x09,0x09,0x03,0x00,0x00,0x00}, // F
|
||||
{0x7f,0x41,0x49,0x7b,0x00,0x00,0x00}, // G
|
||||
{0x7f,0x08,0x08,0x7f,0x00,0x00,0x00}, // H
|
||||
{0x41,0x7f,0x41,0x00,0x00,0x00,0x00}, // I
|
||||
{0x60,0x40,0x40,0x7f,0x00,0x00,0x00}, // J
|
||||
{0x7f,0x08,0x08,0x77,0x00,0x00,0x00}, // K
|
||||
{0x7f,0x40,0x40,0x60,0x00,0x00,0x00}, // L
|
||||
{0x7f,0x01,0x01,0x7f,0x01,0x01,0x7f}, // M
|
||||
{0x7f,0x04,0x08,0x10,0x7f,0x00,0x00}, // N
|
||||
{0x7f,0x41,0x41,0x7f,0x00,0x00,0x00}, // O
|
||||
{0x7f,0x09,0x09,0x0f,0x00,0x00,0x00}, // P
|
||||
{0x7f,0x41,0xc1,0x7f,0x00,0x00,0x00}, // Q
|
||||
{0x7f,0x09,0x09,0x77,0x00,0x00,0x00}, // R
|
||||
{0x6f,0x49,0x49,0x7b,0x00,0x00,0x00}, // S
|
||||
{0x01,0x01,0x7f,0x01,0x01,0x00,0x00}, // T
|
||||
{0x7f,0x40,0x40,0x7f,0x00,0x00,0x00}, // U
|
||||
{0x7f,0x20,0x10,0x0f,0x00,0x00,0x00}, // V
|
||||
{0x7f,0x40,0x40,0x7f,0x40,0x40,0x7f}, // W
|
||||
{0x77,0x08,0x08,0x77,0x00,0x00,0x00}, // X
|
||||
{0x6f,0x48,0x48,0x7f,0x00,0x00,0x00}, // Y
|
||||
{0x71,0x49,0x49,0x47,0x00,0x00,0x00}, // Z
|
||||
{0x7f,0x41,0x00,0x00,0x00,0x00,0x00}, // [
|
||||
{0x03,0x04,0x08,0x10,0x60,0x00,0x00}, // "\"
|
||||
{0x41,0x7f,0x00,0x00,0x00,0x00,0x00}, // ]
|
||||
{0x04,0x02,0x01,0x02,0x04,0x00,0x00}, // ^
|
||||
{0x80,0x80,0x80,0x80,0x00,0x00,0x00}, // _
|
||||
{0x03,0x00,0x00,0x00,0x00,0x00,0x00}, // `
|
||||
{0x74,0x54,0x54,0x7c,0x00,0x00,0x00}, // a
|
||||
{0x7f,0x44,0x44,0x7c,0x00,0x00,0x00}, // b
|
||||
{0x7c,0x44,0x44,0x6c,0x00,0x00,0x00}, // c
|
||||
{0x7c,0x44,0x44,0x7f,0x00,0x00,0x00}, // d
|
||||
{0x7c,0x54,0x54,0x5c,0x00,0x00,0x00}, // e
|
||||
{0x04,0x7e,0x05,0x01,0x00,0x00,0x00}, // f
|
||||
{0xbc,0xa4,0xa4,0xfc,0x00,0x00,0x00}, // g
|
||||
{0x7f,0x04,0x04,0x7c,0x00,0x00,0x00}, // h
|
||||
{0x7d,0x00,0x00,0x00,0x00,0x00,0x00}, // i
|
||||
{0x80,0xfd,0x00,0x00,0x00,0x00,0x00}, // j
|
||||
{0x7f,0x04,0x04,0x7a,0x00,0x00,0x00}, // k
|
||||
{0x7f,0x00,0x00,0x00,0x00,0x00,0x00}, // l
|
||||
{0x7c,0x04,0x04,0x7c,0x04,0x04,0x7c}, // m
|
||||
{0x7c,0x04,0x04,0x7c,0x00,0x00,0x00}, // n
|
||||
{0x7c,0x44,0x44,0x7c,0x00,0x00,0x00}, // o
|
||||
{0xfc,0x44,0x44,0x7c,0x00,0x00,0x00}, // p
|
||||
{0x7c,0x44,0x44,0xfc,0x00,0x00,0x00}, // q
|
||||
{0x7c,0x04,0x04,0x0c,0x00,0x00,0x00}, // r
|
||||
{0x5c,0x54,0x54,0x74,0x00,0x00,0x00}, // s
|
||||
{0x7f,0x44,0x44,0x60,0x00,0x00,0x00}, // t
|
||||
{0x7c,0x40,0x40,0x7c,0x00,0x00,0x00}, // u
|
||||
{0x7c,0x20,0x10,0x0c,0x00,0x00,0x00}, // v
|
||||
{0x7c,0x40,0x40,0x7c,0x40,0x40,0x7c}, // w
|
||||
{0x6c,0x10,0x10,0x6c,0x00,0x00,0x00}, // x
|
||||
{0xbc,0xa0,0xa0,0xfc,0x00,0x00,0x00}, // y
|
||||
{0x64,0x54,0x54,0x4c,0x00,0x00,0x00}, // z
|
||||
{0x08,0x3e,0x41,0x00,0x00,0x00,0x00}, // {
|
||||
{0xff,0x00,0x00,0x00,0x00,0x00,0x00}, // |
|
||||
{0x41,0x3e,0x08,0x00,0x00,0x00,0x00}, // }
|
||||
{0x1c,0x04,0x1c,0x10,0x1c,0x00,0x00}, // ~
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x7d,0x44,0x44,0x7d,0x00,0x00,0x00}, // o
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00},
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00}
|
||||
};
|
||||
|
||||
@ -1,437 +0,0 @@
|
||||
/* Hello World Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_spi_flash.h"
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_http_client.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp_eth.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_spiffs.h"
|
||||
#include <esp_http_server.h>
|
||||
#include <nvs_flash.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "freertos/queue.h"
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/ledc.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "esp_netif.h"
|
||||
#include "esp_eth.h"
|
||||
#include <cJSON.h>
|
||||
|
||||
#define WIFI_SSID "ags-iot"
|
||||
#define WIFI_PASS "internetOfClocksAndCoffee"
|
||||
//#define WIFI_SSID "AndroidAP_3324"
|
||||
//#define WIFI_PASS "Hella1234"
|
||||
|
||||
char http_output_buffer[98304];
|
||||
uint32_t buffer_pointer = 0;
|
||||
|
||||
// Event group
|
||||
static EventGroupHandle_t wifi_event_group;
|
||||
const int CONNECTED_BIT = BIT0;
|
||||
static xQueueHandle gpio_evt_queue = NULL;
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define CHIP_NAME "ESP32"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S2BETA
|
||||
#define CHIP_NAME "ESP32-S2 Beta"
|
||||
#endif
|
||||
|
||||
#define GPIO_R1 25
|
||||
#define GPIO_G1 26
|
||||
#define GPIO_B1 27
|
||||
#define GPIO_R2 14
|
||||
#define GPIO_G2 12
|
||||
#define GPIO_B2 13
|
||||
|
||||
#define GPIO_CLK 16
|
||||
#define GPIO_OE 15
|
||||
#define GPIO_LAT 4
|
||||
|
||||
#define GPIO_A 23
|
||||
#define GPIO_B 19
|
||||
#define GPIO_C 5
|
||||
#define GPIO_D 17
|
||||
#define GPIO_E 18
|
||||
|
||||
uint8_t fb[64][128][3];
|
||||
|
||||
const unsigned char font[96][7] = {
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00}, //
|
||||
{0x5f,0x00,0x00,0x00,0x00,0x00,0x00}, // !
|
||||
{0x03,0x00,0x03,0x00,0x00,0x00,0x00}, // "
|
||||
{0x14,0x7f,0x14,0x7f,0x14,0x00,0x00}, // #
|
||||
{0x6f,0x49,0xc9,0x7b,0x00,0x00,0x00}, // $
|
||||
{0x63,0x13,0x08,0x64,0x63,0x00,0x00}, // %
|
||||
{0x7f,0xc9,0x49,0x63,0x00,0x00,0x00}, // &
|
||||
{0x03,0x00,0x00,0x00,0x00,0x00,0x00}, // '
|
||||
{0x3e,0x41,0x00,0x00,0x00,0x00,0x00}, // (
|
||||
{0x41,0x3e,0x00,0x00,0x00,0x00,0x00}, // )
|
||||
{0x0a,0x04,0x1f,0x04,0x0a,0x00,0x00}, // *
|
||||
{0x08,0x08,0x3e,0x08,0x08,0x00,0x00}, // +
|
||||
{0xc0,0x00,0x00,0x00,0x00,0x00,0x00}, // ,
|
||||
{0x08,0x08,0x08,0x08,0x00,0x00,0x00}, // -
|
||||
{0x40,0x00,0x00,0x00,0x00,0x00,0x00}, // .
|
||||
{0x60,0x10,0x08,0x04,0x03,0x00,0x00}, // /
|
||||
{0x7f,0x41,0x41,0x7f,0x00,0x00,0x00}, // 0
|
||||
{0x01,0x7f,0x00,0x00,0x00,0x00,0x00}, // 1
|
||||
{0x7b,0x49,0x49,0x6f,0x00,0x00,0x00}, // 2
|
||||
{0x63,0x49,0x49,0x7f,0x00,0x00,0x00}, // 3
|
||||
{0x0f,0x08,0x08,0x7f,0x00,0x00,0x00}, // 4
|
||||
{0x6f,0x49,0x49,0x7b,0x00,0x00,0x00}, // 5
|
||||
{0x7f,0x49,0x49,0x7b,0x00,0x00,0x00}, // 6
|
||||
{0x03,0x01,0x01,0x7f,0x00,0x00,0x00}, // 7
|
||||
{0x7f,0x49,0x49,0x7f,0x00,0x00,0x00}, // 8
|
||||
{0x0f,0x09,0x09,0x7f,0x00,0x00,0x00}, // 9
|
||||
{0x41,0x00,0x00,0x00,0x00,0x00,0x00}, // :
|
||||
{0xc1,0x00,0x00,0x00,0x00,0x00,0x00}, // ;
|
||||
{0x08,0x14,0x22,0x00,0x00,0x00,0x00}, // <
|
||||
{0x14,0x14,0x14,0x14,0x00,0x00,0x00}, // =
|
||||
{0x22,0x14,0x08,0x00,0x00,0x00,0x00}, // >
|
||||
{0x03,0x59,0x09,0x0f,0x00,0x00,0x00}, // ?
|
||||
{0x7f,0x41,0x5d,0x55,0x5f,0x00,0x00}, // @
|
||||
{0x7f,0x09,0x09,0x7f,0x00,0x00,0x00}, // A
|
||||
{0x7f,0x49,0x49,0x77,0x00,0x00,0x00}, // B
|
||||
{0x7f,0x41,0x41,0x63,0x00,0x00,0x00}, // C
|
||||
{0x7f,0x41,0x41,0x3e,0x00,0x00,0x00}, // D
|
||||
{0x7f,0x49,0x49,0x63,0x00,0x00,0x00}, // E
|
||||
{0x7f,0x09,0x09,0x03,0x00,0x00,0x00}, // F
|
||||
{0x7f,0x41,0x49,0x7b,0x00,0x00,0x00}, // G
|
||||
{0x7f,0x08,0x08,0x7f,0x00,0x00,0x00}, // H
|
||||
{0x41,0x7f,0x41,0x00,0x00,0x00,0x00}, // I
|
||||
{0x60,0x40,0x40,0x7f,0x00,0x00,0x00}, // J
|
||||
{0x7f,0x08,0x08,0x77,0x00,0x00,0x00}, // K
|
||||
{0x7f,0x40,0x40,0x60,0x00,0x00,0x00}, // L
|
||||
{0x7f,0x01,0x01,0x7f,0x01,0x01,0x7f}, // M
|
||||
{0x7f,0x01,0x01,0x7f,0x00,0x00,0x00}, // N
|
||||
{0x7f,0x41,0x41,0x7f,0x00,0x00,0x00}, // O
|
||||
{0x7f,0x09,0x09,0x0f,0x00,0x00,0x00}, // P
|
||||
{0x7f,0x41,0xc1,0x7f,0x00,0x00,0x00}, // Q
|
||||
{0x7f,0x09,0x09,0x77,0x00,0x00,0x00}, // R
|
||||
{0x6f,0x49,0x49,0x7b,0x00,0x00,0x00}, // S
|
||||
{0x01,0x01,0x7f,0x01,0x01,0x00,0x00}, // T
|
||||
{0x7f,0x40,0x40,0x7f,0x00,0x00,0x00}, // U
|
||||
{0x7f,0x20,0x10,0x0f,0x00,0x00,0x00}, // V
|
||||
{0x7f,0x40,0x40,0x7f,0x40,0x40,0x7f}, // W
|
||||
{0x77,0x08,0x08,0x77,0x00,0x00,0x00}, // X
|
||||
{0x6f,0x48,0x48,0x7f,0x00,0x00,0x00}, // Y
|
||||
{0x71,0x49,0x49,0x47,0x00,0x00,0x00}, // Z
|
||||
{0x7f,0x41,0x00,0x00,0x00,0x00,0x00}, // [
|
||||
{0x03,0x04,0x08,0x10,0x60,0x00,0x00}, // "\"
|
||||
{0x41,0x7f,0x00,0x00,0x00,0x00,0x00}, // ]
|
||||
{0x04,0x02,0x01,0x02,0x04,0x00,0x00}, // ^
|
||||
{0x80,0x80,0x80,0x80,0x00,0x00,0x00}, // _
|
||||
{0x03,0x00,0x00,0x00,0x00,0x00,0x00}, // `
|
||||
{0x74,0x54,0x54,0x7c,0x00,0x00,0x00}, // a
|
||||
{0x7f,0x44,0x44,0x7c,0x00,0x00,0x00}, // b
|
||||
{0x7c,0x44,0x44,0x6c,0x00,0x00,0x00}, // c
|
||||
{0x7c,0x44,0x44,0x7f,0x00,0x00,0x00}, // d
|
||||
{0x7c,0x54,0x54,0x5c,0x00,0x00,0x00}, // e
|
||||
{0x7f,0x05,0x05,0x01,0x00,0x00,0x00}, // f
|
||||
{0xbc,0xa4,0xa4,0xfc,0x00,0x00,0x00}, // g
|
||||
{0x7f,0x04,0x04,0x7c,0x00,0x00,0x00}, // h
|
||||
{0x7d,0x00,0x00,0x00,0x00,0x00,0x00}, // i
|
||||
{0x80,0xfd,0x00,0x00,0x00,0x00,0x00}, // j
|
||||
{0x7f,0x04,0x04,0x7a,0x00,0x00,0x00}, // k
|
||||
{0x7f,0x00,0x00,0x00,0x00,0x00,0x00}, // l
|
||||
{0x7c,0x04,0x04,0x7c,0x04,0x04,0x7c}, // m
|
||||
{0x7c,0x04,0x04,0x7c,0x00,0x00,0x00}, // n
|
||||
{0x7c,0x44,0x44,0x7c,0x00,0x00,0x00}, // o
|
||||
{0xfc,0x44,0x44,0x7c,0x00,0x00,0x00}, // p
|
||||
{0x7c,0x44,0x44,0xfc,0x00,0x00,0x00}, // q
|
||||
{0x7c,0x04,0x04,0x0c,0x00,0x00,0x00}, // r
|
||||
{0x5c,0x54,0x54,0x74,0x00,0x00,0x00}, // s
|
||||
{0x7f,0x44,0x44,0x60,0x00,0x00,0x00}, // t
|
||||
{0x7c,0x40,0x40,0x7c,0x00,0x00,0x00}, // u
|
||||
{0x7c,0x20,0x10,0x0c,0x00,0x00,0x00}, // v
|
||||
{0x7c,0x40,0x40,0x7c,0x40,0x40,0x7c}, // w
|
||||
{0x6c,0x10,0x10,0x6c,0x00,0x00,0x00}, // x
|
||||
{0xbc,0xa0,0xa0,0xfc,0x00,0x00,0x00}, // y
|
||||
{0x64,0x54,0x54,0x4c,0x00,0x00,0x00}, // z
|
||||
{0x08,0x3e,0x41,0x00,0x00,0x00,0x00}, // {
|
||||
{0xff,0x00,0x00,0x00,0x00,0x00,0x00}, // |
|
||||
{0x41,0x3e,0x08,0x00,0x00,0x00,0x00}, // }
|
||||
{0x1c,0x04,0x1c,0x10,0x1c,0x00,0x00}, // ~
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00}
|
||||
};
|
||||
|
||||
void connect_to_wifi(char* new_ssid, char* new_psk){
|
||||
printf("ssid: \'%s\'\n", new_ssid);
|
||||
printf("psk:\'%s\'\n", new_psk);
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_stop());
|
||||
|
||||
wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
|
||||
// configure the wifi connection and start the interface
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = {*new_ssid},
|
||||
.password = {*new_psk}
|
||||
}
|
||||
};
|
||||
strcpy(&(wifi_config.sta.ssid), new_ssid);
|
||||
strcpy(&(wifi_config.sta.password), new_psk);
|
||||
|
||||
printf("ssid: \'%s\'\n", wifi_config.sta.ssid);
|
||||
printf("psk: \'%s\'\n", wifi_config.sta.password);
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
}
|
||||
|
||||
// Wifi event handler
|
||||
static esp_err_t event_handler(void *ctx, system_event_t *event)
|
||||
{
|
||||
switch(event->event_id) {
|
||||
|
||||
case SYSTEM_EVENT_STA_START:
|
||||
esp_wifi_connect();
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
|
||||
printf("disconnected!\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#define TAG "test"
|
||||
esp_err_t _http_event_handle(esp_http_client_event_t *evt)
|
||||
{
|
||||
switch(evt->event_id) {
|
||||
case HTTP_EVENT_ERROR:
|
||||
ESP_LOGI(TAG, "HTTP_EVENT_ERROR");
|
||||
break;
|
||||
case HTTP_EVENT_ON_CONNECTED:
|
||||
ESP_LOGI(TAG, "HTTP_EVENT_ON_CONNECTED");
|
||||
buffer_pointer = 0;
|
||||
break;
|
||||
case HTTP_EVENT_HEADER_SENT:
|
||||
ESP_LOGI(TAG, "HTTP_EVENT_HEADER_SENT");
|
||||
break;
|
||||
case HTTP_EVENT_ON_HEADER:
|
||||
ESP_LOGI(TAG, "HTTP_EVENT_ON_HEADER");
|
||||
printf("%.*s", evt->data_len, (char*)evt->data);
|
||||
break;
|
||||
case HTTP_EVENT_ON_DATA:
|
||||
ESP_LOGI(TAG, "HTTP_EVENT_ON_DATA, len=%d", evt->data_len);
|
||||
if (!esp_http_client_is_chunked_response(evt->client)) {
|
||||
memcpy(&http_output_buffer[buffer_pointer], evt->data, evt->data_len);
|
||||
buffer_pointer += evt->data_len;
|
||||
}
|
||||
|
||||
break;
|
||||
case HTTP_EVENT_ON_FINISH:
|
||||
ESP_LOGI(TAG, "HTTP_EVENT_ON_FINISH");
|
||||
http_output_buffer[buffer_pointer+1] = 0;
|
||||
//printf("%s", http_output_buffer);
|
||||
printf("PRINTING RECIEVED STRING:\n");
|
||||
printf("%.*s\n", buffer_pointer, http_output_buffer);
|
||||
printf("END OF RECIEVED STRING\n");
|
||||
cJSON *root = cJSON_Parse(http_output_buffer);
|
||||
const char *error_ptr = cJSON_GetErrorPtr();
|
||||
//printf("error: %s\n", error_ptr-100);
|
||||
//printf("%s", cJSON_Print(root));
|
||||
printf("size is: %d\n", buffer_pointer);
|
||||
if(root != NULL) {
|
||||
cJSON* departureListObject = cJSON_GetObjectItem(root, "departureList");
|
||||
if(departureListObject != NULL) {
|
||||
cJSON* departureListObject = cJSON_GetObjectItem(root, "departureList");
|
||||
printf("%s", cJSON_Print(departureListObject));
|
||||
}
|
||||
else
|
||||
printf("dl empty\n");
|
||||
}
|
||||
else
|
||||
printf("root empty\n");
|
||||
|
||||
break;
|
||||
case HTTP_EVENT_DISCONNECTED:
|
||||
ESP_LOGI(TAG, "HTTP_EVENT_DISCONNECTED");
|
||||
break;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void write_bits(uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2){
|
||||
gpio_set_level(GPIO_R1, r1);
|
||||
gpio_set_level(GPIO_G1, g1);
|
||||
gpio_set_level(GPIO_B1, b1);
|
||||
gpio_set_level(GPIO_R2, r2);
|
||||
gpio_set_level(GPIO_G2, g2);
|
||||
gpio_set_level(GPIO_B2, b2);
|
||||
}
|
||||
|
||||
void write_address(uint8_t addr){
|
||||
gpio_set_level(GPIO_A, addr&0x01);
|
||||
gpio_set_level(GPIO_B, (addr&0x02)>>1);
|
||||
gpio_set_level(GPIO_C, (addr&0x04)>>2);
|
||||
gpio_set_level(GPIO_D, (addr&0x08)>>3);
|
||||
gpio_set_level(GPIO_E, (addr&0x10)>>4);
|
||||
}
|
||||
|
||||
void put_chr(uint8_t line, uint8_t pos, uint8_t chr[]){
|
||||
for(int i=0;i<8;i++)
|
||||
for(int j=0;j<7;j++)
|
||||
fb[1+(line*10)+i][(pos*7)+j][0] = (chr[j]&(1<<i))>>i;
|
||||
}
|
||||
|
||||
void put_line(uint8_t line, char *str){
|
||||
uint8_t pos = 0;
|
||||
while(str[pos] != 0){
|
||||
put_chr(line, pos, font[str[pos]-0x20]);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
void latch(){
|
||||
gpio_set_level(GPIO_LAT, 0);
|
||||
gpio_set_level(GPIO_LAT, 1);
|
||||
}
|
||||
|
||||
void clock_cycle(){
|
||||
gpio_set_level(GPIO_CLK, 1);
|
||||
gpio_set_level(GPIO_CLK, 0);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
|
||||
ESP_ERROR_CHECK(nvs_flash_init());
|
||||
|
||||
wifi_event_group = xEventGroupCreate();
|
||||
tcpip_adapter_init();
|
||||
ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
|
||||
|
||||
printf("1!\n");
|
||||
wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
printf("2!\n");
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = WIFI_SSID,
|
||||
.password = WIFI_PASS,
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
printf("Connecting to %s\n", WIFI_SSID);
|
||||
EventBits_t uxBits;
|
||||
uxBits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, false, true, 5000 / portTICK_PERIOD_MS);
|
||||
printf("3!\n");
|
||||
if( ( uxBits & CONNECTED_BIT ) != 0 )
|
||||
{
|
||||
printf("Connected!\n");
|
||||
}
|
||||
else{
|
||||
printf("Not connected!\n");
|
||||
}
|
||||
|
||||
// put_line(0, "429 Amalienplatz");
|
||||
// put_line(1, "0123abcd");
|
||||
// put_line(2, "ags");
|
||||
put_line(0, "Wissenschaftliche");
|
||||
put_line(1, "Arbeitsgemein-");
|
||||
put_line(2, "schaft für Studio-");
|
||||
put_line(3, "und Senderfragen");
|
||||
put_line(4, "an der");
|
||||
put_line(5, "TU Braunschweig");
|
||||
|
||||
gpio_config_t io_conf;
|
||||
//disable interrupt
|
||||
io_conf.intr_type = GPIO_INTR_DISABLE;
|
||||
//set as output mode
|
||||
io_conf.mode = GPIO_MODE_OUTPUT;
|
||||
//bit mask of the pins that you want to set,e.g.GPIO18/19
|
||||
io_conf.pin_bit_mask =
|
||||
(1ULL<<GPIO_LAT)|(1ULL<<GPIO_OE)|(1ULL<<GPIO_CLK)
|
||||
|(1ULL<<GPIO_R1)|(1ULL<<GPIO_G1)|(1ULL<<GPIO_B1)|(1ULL<<GPIO_R2)|(1ULL<<GPIO_G2)|(1ULL<<GPIO_B2)
|
||||
|(1ULL<<GPIO_A)|(1ULL<<GPIO_B)|(1ULL<<GPIO_C)|(1ULL<<GPIO_D)|(1ULL<<GPIO_E);
|
||||
//disable pull-down mode
|
||||
io_conf.pull_down_en = 0;
|
||||
//disable pull-up mode
|
||||
io_conf.pull_up_en = 0;
|
||||
//configure GPIO with the given settings
|
||||
gpio_config(&io_conf);
|
||||
|
||||
esp_http_client_config_t config = {
|
||||
//.url = "https://bsvg.efa.de/bsvagstd/XML_DM_REQUEST?outputFormat=JSON&stateless=1&locationServerActive=1&type_dm=stop&name_dm=\"Saarplatz,Braunschweig\"&mode=direct&ptOptionsActive=1&useRealtime=1",
|
||||
.url = "http://mustbehax.de/web/bsvg.json",
|
||||
.event_handler = _http_event_handle,
|
||||
};
|
||||
esp_http_client_handle_t client = esp_http_client_init(&config);
|
||||
esp_err_t err = esp_http_client_perform(client);
|
||||
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Status = %d, content_length = %d",
|
||||
esp_http_client_get_status_code(client),
|
||||
esp_http_client_get_content_length(client));
|
||||
}
|
||||
esp_http_client_cleanup(client);
|
||||
|
||||
gpio_set_level(GPIO_OE, 1);
|
||||
gpio_set_level(GPIO_OE, 0);
|
||||
|
||||
uint8_t line = 0;
|
||||
for (;;) {
|
||||
for(uint8_t i=0;i<128;i++){
|
||||
write_bits(fb[line][i][0],fb[line][i][1],fb[line][i][2],fb[32+line][i][0],fb[32+line][i][1],fb[32+line][i][2]);
|
||||
//write_bits(1,1,1,1,1,1);
|
||||
clock_cycle();
|
||||
}
|
||||
gpio_set_level(GPIO_OE, 1);
|
||||
latch();
|
||||
write_address(line);
|
||||
gpio_set_level(GPIO_OE, 0);
|
||||
line = (line + 1)%32;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
#include "http.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/dns.h"
|
||||
|
||||
static const char *TAG = "http";
|
||||
|
||||
static const char *REQUEST = "GET " WEB_PATH " HTTP/1.0\r\n"
|
||||
"Host: "WEB_SERVER":"WEB_PORT"\r\n"
|
||||
"User-Agent: esp-idf/1.0 esp32\r\n"
|
||||
"\r\n";
|
||||
|
||||
esp_err_t http_request(char* buf)
|
||||
{
|
||||
const struct addrinfo hints = {
|
||||
.ai_family = AF_INET,
|
||||
.ai_socktype = SOCK_STREAM,
|
||||
};
|
||||
struct addrinfo *res;
|
||||
struct in_addr *addr;
|
||||
int s, r;
|
||||
|
||||
int err = getaddrinfo(WEB_SERVER, WEB_PORT, &hints, &res);
|
||||
|
||||
if(err != 0 || res == NULL) {
|
||||
ESP_LOGE(TAG, "DNS lookup failed err=%d res=%p", err, res);
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* Code to print the resolved IP.
|
||||
* Note: inet_ntoa is non-reentrant, look at ipaddr_ntoa_r for "real" code */
|
||||
addr = &((struct sockaddr_in *)res->ai_addr)->sin_addr;
|
||||
ESP_LOGI(TAG, "DNS lookup succeeded. IP=%s", inet_ntoa(*addr));
|
||||
|
||||
s = socket(res->ai_family, res->ai_socktype, 0);
|
||||
if(s < 0) {
|
||||
ESP_LOGE(TAG, "... Failed to allocate socket.");
|
||||
freeaddrinfo(res);
|
||||
return -1;
|
||||
}
|
||||
ESP_LOGI(TAG, "... allocated socket");
|
||||
|
||||
if(connect(s, res->ai_addr, res->ai_addrlen) != 0) {
|
||||
ESP_LOGE(TAG, "... socket connect failed errno=%d", errno);
|
||||
close(s);
|
||||
freeaddrinfo(res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "... connected");
|
||||
freeaddrinfo(res);
|
||||
|
||||
if (write(s, REQUEST, strlen(REQUEST)) < 0) {
|
||||
ESP_LOGE(TAG, "... socket send failed");
|
||||
close(s);
|
||||
return -1;
|
||||
}
|
||||
ESP_LOGI(TAG, "... socket send success");
|
||||
|
||||
struct timeval receiving_timeout;
|
||||
receiving_timeout.tv_sec = 5;
|
||||
receiving_timeout.tv_usec = 0;
|
||||
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &receiving_timeout,
|
||||
sizeof(receiving_timeout)) < 0) {
|
||||
ESP_LOGE(TAG, "... failed to set socket receiving timeout");
|
||||
close(s);
|
||||
return -1;
|
||||
}
|
||||
ESP_LOGI(TAG, "... set socket receiving timeout success");
|
||||
|
||||
/* Read HTTP response */
|
||||
r = read(s, buf, RCV_BUFSIZE);
|
||||
if(r >= RCV_BUFSIZE)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
#include "esp_system.h"
|
||||
|
||||
/* Constants that aren't configurable in menuconfig */
|
||||
#define WEB_SERVER "mustbehax.de"
|
||||
#define WEB_PORT "80"
|
||||
#define WEB_PATH "/test"
|
||||
|
||||
#define RCV_BUFSIZE 8000
|
||||
|
||||
esp_err_t http_request(char* buf);
|
||||
@ -0,0 +1,124 @@
|
||||
#include "esp_tls.h"
|
||||
#include "esp_log.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
#include "esp_crt_bundle.h"
|
||||
|
||||
static const char *TAG = "https";
|
||||
|
||||
#define WEB_SERVER "bsvg.efa.de"
|
||||
#define WEB_PORT "443"
|
||||
#define WEB_URL "/bsvagstd/XML_DM_REQUEST?outputFormat=JSON&stateless=1&locationServerActive=1&type_dm=stop&name_dm=\"Kaiserstr,Braunschweig\"&mode=direct&ptOptionsActive=1&useRealtime=1"
|
||||
//#define WEB_SERVER "mustbehax.de"
|
||||
//#define WEB_PORT "443"
|
||||
//#define WEB_URL "/web/reduced.json"
|
||||
|
||||
static const char REQUEST[] = "GET " WEB_URL " HTTP/1.1\r\n"
|
||||
"Host: "WEB_SERVER"\r\n"
|
||||
"User-Agent: esp-idf/1.0 esp32\r\n"
|
||||
"\r\n";
|
||||
|
||||
esp_err_t https_get_request_using_crt_bundle(char* buf, size_t bufsize)
|
||||
{
|
||||
memset(buf, 0, bufsize);
|
||||
ESP_LOGI(TAG, "https_request using crt bundle");
|
||||
esp_tls_cfg_t cfg = {
|
||||
.crt_bundle_attach = esp_crt_bundle_attach,
|
||||
};
|
||||
//https_get_request(cfg, "https://"WEB_SERVER""WEB_URL, HOWSMYSSL_REQUEST);
|
||||
//char buf[47000];
|
||||
int ret, len;
|
||||
|
||||
esp_tls_t *tls = esp_tls_init();
|
||||
if (!tls) {
|
||||
ESP_LOGE(TAG, "Failed to allocate esp_tls handle!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (esp_tls_conn_http_new_sync("https://"WEB_SERVER""WEB_URL, &cfg, tls) == 1) {
|
||||
ESP_LOGI(TAG, "Connection established...");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Connection failed...");
|
||||
int esp_tls_code = 0, esp_tls_flags = 0;
|
||||
esp_tls_error_handle_t tls_e = NULL;
|
||||
esp_tls_get_error_handle(tls, &tls_e);
|
||||
/* Try to get TLS stack level error and certificate failure flags, if any */
|
||||
ret = esp_tls_get_and_clear_last_error(tls_e, &esp_tls_code, &esp_tls_flags);
|
||||
if (ret == ESP_OK) {
|
||||
ESP_LOGE(TAG, "TLS error = -0x%x, TLS flags = -0x%x", esp_tls_code, esp_tls_flags);
|
||||
}
|
||||
esp_tls_conn_destroy(tls);
|
||||
return -2;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_CLIENT_SESSION_TICKETS
|
||||
/* The TLS session is successfully established, now saving the session ctx for reuse */
|
||||
if (save_client_session) {
|
||||
esp_tls_free_client_session(tls_client_session);
|
||||
tls_client_session = esp_tls_get_client_session(tls);
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t written_bytes = 0;
|
||||
do {
|
||||
ret = esp_tls_conn_write(tls,
|
||||
REQUEST + written_bytes,
|
||||
strlen(REQUEST) - written_bytes);
|
||||
if (ret >= 0) {
|
||||
ESP_LOGI(TAG, "%d bytes written", ret);
|
||||
written_bytes += ret;
|
||||
} else if (ret != ESP_TLS_ERR_SSL_WANT_READ && ret != ESP_TLS_ERR_SSL_WANT_WRITE) {
|
||||
ESP_LOGE(TAG, "esp_tls_conn_write returned: [0x%02X](%s)", ret, esp_err_to_name(ret));
|
||||
esp_tls_conn_destroy(tls);
|
||||
return -3;
|
||||
}
|
||||
} while (written_bytes < strlen(REQUEST));
|
||||
|
||||
uint32_t write_offset = 0;
|
||||
memset(buf, 0x00, bufsize);
|
||||
ESP_LOGI(TAG, "Reading HTTP response...");
|
||||
do {
|
||||
len = bufsize - write_offset - 1;
|
||||
if(len > 6000)
|
||||
len = 6000;
|
||||
|
||||
ret = esp_tls_conn_read(tls, &buf[write_offset], len);
|
||||
|
||||
if (ret == ESP_TLS_ERR_SSL_WANT_WRITE || ret == ESP_TLS_ERR_SSL_WANT_READ) {
|
||||
continue;
|
||||
} else if (ret < 0) {
|
||||
ESP_LOGE(TAG, "esp_tls_conn_read returned [-0x%02X](%s)", -ret, esp_err_to_name(ret));
|
||||
break;
|
||||
} else if (ret == 0) {
|
||||
ESP_LOGI(TAG, "connection closed");
|
||||
break;
|
||||
}
|
||||
write_offset += ret;
|
||||
len = ret;
|
||||
ESP_LOGI(TAG, "%d bytes read", len);
|
||||
|
||||
//if(!strstr(buf, "departureList")){
|
||||
// ESP_LOGI(TAG,"tossing ... strstr: %ld", (uint32_t)strstr(buf, "departureList"));
|
||||
// write_offset=0;
|
||||
//}else
|
||||
// ESP_LOGI(TAG,"keeping ... strstr: %ld", (uint32_t)strstr(buf, "departureList"));
|
||||
|
||||
} while (1);
|
||||
buf[write_offset+len+1] = 0;
|
||||
|
||||
esp_tls_conn_destroy(tls);
|
||||
return 0;
|
||||
|
||||
///* Print response directly to stdout as it is read */
|
||||
//for (int i = 0; i < sizeof(buf); i++) {
|
||||
// putchar(buf[i]);
|
||||
// if(i%100 == 0)
|
||||
// vTaskDelay(1);
|
||||
//}
|
||||
//putchar('\n'); // JSON output doesn't have a newline at end
|
||||
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
esp_err_t https_get_request_using_crt_bundle(char* buf, size_t bufsize);
|
||||
@ -0,0 +1,221 @@
|
||||
/* Hello World Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <sys/types.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "display.h"
|
||||
#include "text.h"
|
||||
#include "wlan.h"
|
||||
#include "https.h"
|
||||
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#include "lwjson/lwjson.h"
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define CHIP_NAME "ESP32"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S2BETA
|
||||
#define CHIP_NAME "ESP32-S2 Beta"
|
||||
#endif
|
||||
|
||||
|
||||
const esp_timer_create_args_t periodic_timer_args = {
|
||||
.callback = &display_cycle,
|
||||
};
|
||||
|
||||
uint8_t buf_ok = 0;
|
||||
char bsvg_buf[40000];
|
||||
static void https_request_task(void *pvparameters){
|
||||
while(https_get_request_using_crt_bundle(bsvg_buf, sizeof(bsvg_buf)) != 0){
|
||||
ESP_LOGE("bsvg", "Failed to get data from server. Retrying...");
|
||||
vTaskDelay(1);
|
||||
}
|
||||
buf_ok = 1;
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void get_json_string(char* buf, char* name, char* dest){
|
||||
char* element = strstr(buf, name);
|
||||
char *ptr= element;
|
||||
while(*ptr != ':' && *ptr != 0) ptr++;
|
||||
while(*ptr != '"' && *ptr != 0) ptr++;
|
||||
ptr++;
|
||||
|
||||
char *end=ptr;
|
||||
while(*end != '"') end++;
|
||||
|
||||
strncpy(dest, ptr, end-ptr);
|
||||
dest[end-ptr]=0;
|
||||
}
|
||||
|
||||
uint8_t json_ok = 0;
|
||||
static void json_parse_task(void *pvparameters){
|
||||
//uint16_t start_ptr = 0;
|
||||
//while(buf[start_ptr] != '{' && start_ptr < sizeof(buf))
|
||||
// start_ptr++;
|
||||
char *start = strstr(bsvg_buf, "\"departureList\"") + 17;
|
||||
//char *start = strstr(bsvg_buf, "{");
|
||||
ESP_LOGI("bsvg", "start at %ld: \"%.10s\"", (uint32_t)start, start);
|
||||
//departureList = cJSON_Parse(start);
|
||||
|
||||
uint8_t line = 0;
|
||||
char *item = start;
|
||||
char txt[6][50];
|
||||
while((item = strstr(item+1, "{ \"stopID\":")) != 0){
|
||||
char symbol[10];
|
||||
get_json_string(item, "symbol", symbol);
|
||||
|
||||
char direction[50];
|
||||
get_json_string(item, "direction", direction);
|
||||
|
||||
char countdown[10] ;
|
||||
get_json_string(item, "countdown", countdown);
|
||||
|
||||
if(atoi(countdown)>=60){
|
||||
uint8_t h = atoi(countdown) / 60;
|
||||
uint8_t m = atoi(countdown) % 60;
|
||||
sprintf(countdown, "%d:%02d", h, m);
|
||||
}
|
||||
|
||||
if(line < 6){
|
||||
sprintf(txt[line], " %.4s", countdown);
|
||||
put_line(fb, line, txt[line], 1, 1);
|
||||
|
||||
sprintf(txt[line], " %.20s", direction);
|
||||
put_line(fb, line, txt[line], 1, 1);
|
||||
|
||||
sprintf(txt[line], "%.3s", symbol);
|
||||
put_line(fb, line, txt[line], 1, 1);
|
||||
|
||||
}
|
||||
|
||||
//sprintf(txt[line], "%.3s\t%.20s\t%.4s", symbol, direction, countdown);
|
||||
printf("line = %d: %s\n", line, txt[line]);
|
||||
printf("\n");
|
||||
|
||||
line++;
|
||||
}
|
||||
|
||||
//lwjson_init(&lwjson, tokens, LWJSON_ARRAYSIZE(tokens));
|
||||
//if (lwjson_parse(&lwjson, start) == lwjsonOK) {
|
||||
// const lwjson_token_t* t;
|
||||
// printf("JSON parsed..\r\n");
|
||||
|
||||
// /* Find custom key in JSON */
|
||||
// if ((t = lwjson_find(&lwjson, "stopID")) != NULL) {
|
||||
// printf("Key found with data type: %d\r\n", (int)t->type);
|
||||
// }
|
||||
|
||||
// /* Call this when not used anymore */
|
||||
// lwjson_free(&lwjson);
|
||||
//}
|
||||
//else{
|
||||
// ESP_LOGI("bsvg", "parse fail");
|
||||
//}
|
||||
|
||||
json_ok = 1;
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("Hello world!\n");
|
||||
printf("free heap: %d\n", heap_caps_get_free_size( MALLOC_CAP_DEFAULT) );
|
||||
ESP_LOGI("bsvg", "display init");
|
||||
display_init();
|
||||
|
||||
printf("free heap: %d\n", heap_caps_get_free_size( MALLOC_CAP_DEFAULT) );
|
||||
esp_timer_handle_t periodic_timer;
|
||||
ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
|
||||
ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, 500));
|
||||
|
||||
put_line(fb, 1, "Moin", 1, 1);
|
||||
|
||||
wlan_init();
|
||||
|
||||
put_line(fb, 2, "wifi", 1, 1);
|
||||
|
||||
for (;;) {
|
||||
printf("free heap: %d\n", heap_caps_get_free_size( MALLOC_CAP_DEFAULT) );
|
||||
xTaskCreate(&https_request_task, "https_get_task", 8192, NULL, 5, NULL);
|
||||
while (!buf_ok) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
|
||||
printf("free heap: %d\n", heap_caps_get_free_size( MALLOC_CAP_DEFAULT) );
|
||||
ESP_LOGI("bsvg", "got from https server:");
|
||||
for(uint32_t i=0; i<sizeof(bsvg_buf); i++){
|
||||
putchar(bsvg_buf[i]);
|
||||
if(i%1000==0)
|
||||
vTaskDelay(1);
|
||||
}
|
||||
putchar('\n');
|
||||
|
||||
printf("free heap: %d\n", heap_caps_get_free_size( MALLOC_CAP_DEFAULT) );
|
||||
put_line(fb, 3, "https", 1, 1);
|
||||
|
||||
xTaskCreate(&json_parse_task, "json_parse_task", 8192, NULL, 5, NULL);
|
||||
ESP_LOGI("bsvg", "Parsing JSON...");
|
||||
while (!json_ok) {
|
||||
printf("free heap: %d\n", heap_caps_get_free_size( MALLOC_CAP_DEFAULT) );
|
||||
vTaskDelay(1);
|
||||
}
|
||||
ESP_LOGI("bsvg", "Done");
|
||||
|
||||
//if (departureList == NULL)
|
||||
//{
|
||||
// ESP_LOGI("bsvg", "did not get list");
|
||||
// const char *error_ptr = cJSON_GetErrorPtr();
|
||||
// heap_caps_print_heap_info(MALLOC_CAP_DEFAULT);
|
||||
// if (error_ptr != NULL)
|
||||
// {
|
||||
// fprintf(stderr, "Error at %ld: %.10s\n", (uint32_t)error_ptr-(uint32_t)bsvg_buf, error_ptr);
|
||||
// fprintf(stderr, "%.100s%.100s\n", error_ptr-100, error_ptr);
|
||||
// fprintf(stderr, " ^\n");
|
||||
// }
|
||||
// else {
|
||||
// fprintf(stderr, "did not get err ptr\n");
|
||||
// }
|
||||
//}else{
|
||||
// ESP_LOGI("bsvg", "got list");
|
||||
// printf("free heap: %d\n", heap_caps_get_free_size( MALLOC_CAP_DEFAULT) );
|
||||
// ESP_LOGI("bsvg", "type: %d", departureList->type);
|
||||
// ESP_LOGI("bsvg", "child: %ld", (uint32_t)departureList->child);
|
||||
// if(cJSON_IsArray(departureList)){
|
||||
// ESP_LOGI("bsvg", "is Array");
|
||||
// const cJSON *departure = NULL;
|
||||
// cJSON_ArrayForEach(departure, departureList){
|
||||
// cJSON *number = cJSON_GetObjectItemCaseSensitive(cJSON_GetObjectItemCaseSensitive(departure, "servingLine"), "number");;
|
||||
// if(number == NULL)
|
||||
// ESP_LOGI("bsvg", "cant get number");
|
||||
// else if(cJSON_IsNumber(number))
|
||||
// ESP_LOGI("bsvg", "number (int): %d\n", number->valueint);
|
||||
// else if(cJSON_IsString(number))
|
||||
// ESP_LOGI("bsvg", "number (str): %.3s\n", number->valuestring);
|
||||
// else
|
||||
// ESP_LOGI("bsvg", "cant get number value");
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
vTaskDelay(6000);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "text.h"
|
||||
|
||||
uint8_t check_chr_width(const uint8_t chr[]){
|
||||
for(int i=6;i>=0;i--)
|
||||
if(chr[i] != 0)
|
||||
return i;
|
||||
return 2; //space character
|
||||
}
|
||||
|
||||
void put_chr(uint8_t framebuffer[DISPLAY_HEIGHT][DISPLAY_WIDTH][3], uint8_t line, uint8_t pos, const uint8_t chr[], uint8_t size){
|
||||
for(int i=0;i<8;i++)
|
||||
for(int j=0;j<7;j++){
|
||||
uint8_t val = (chr[j]&(1<<i))>>i;
|
||||
for(int x=0;x<size;x++)
|
||||
for(int y=0;y<size;y++)
|
||||
framebuffer[1+(line*10)+(i*size)+y][(pos)+(j*size)+x][0] = val;
|
||||
}
|
||||
}
|
||||
|
||||
void put_line(uint8_t framebuffer[DISPLAY_HEIGHT][DISPLAY_WIDTH][3], uint8_t line, char *str, uint8_t spacing, uint8_t size){
|
||||
uint8_t pos = 0;
|
||||
uint8_t disp_pos = 0;
|
||||
while(str[pos] != 0){
|
||||
uint16_t code = 0;
|
||||
if((str[pos]&0xE0) == 0xC0 && (str[pos+1]&0xC0) == 0x80){
|
||||
code = (str[pos] & 0x1F) << 6;
|
||||
code |= (str[pos+1] & 0x3F);
|
||||
printf("mbc: %x\n", font[code][0]);
|
||||
pos++;
|
||||
}else{
|
||||
code = str[pos];
|
||||
}
|
||||
put_chr(framebuffer, line, disp_pos, font[code-0x20], size);
|
||||
disp_pos += (check_chr_width(font[code-0x20]) + 1 + spacing)*size;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
void put_line_center(uint8_t framebuffer[DISPLAY_HEIGHT][DISPLAY_WIDTH][3], uint8_t line, char *str, uint8_t spacing, uint8_t size){
|
||||
uint8_t pos = 0;
|
||||
uint8_t txt_length = 0;
|
||||
|
||||
while(str[pos] != 0){
|
||||
txt_length += (check_chr_width(font[str[pos]-0x20]) + 1 + spacing)*size;
|
||||
pos++;
|
||||
}
|
||||
pos=0;
|
||||
|
||||
uint8_t disp_pos = (DISPLAY_WIDTH/2) - (txt_length/2);
|
||||
|
||||
while(str[pos] != 0){
|
||||
put_chr(framebuffer, line, disp_pos, font[str[pos]-0x20], size);
|
||||
disp_pos += (check_chr_width(font[str[pos]-0x20]) + 1 + spacing)*size;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
#ifndef _TEXT_H_
|
||||
#define _TEXT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "display.h"
|
||||
|
||||
extern const uint8_t font[96][7];
|
||||
|
||||
void put_line(uint8_t framebuffer[DISPLAY_HEIGHT][DISPLAY_WIDTH][3], uint8_t line, char *str, uint8_t spacing, uint8_t size);
|
||||
void put_line_center(uint8_t framebuffer[DISPLAY_HEIGHT][DISPLAY_WIDTH][3], uint8_t line, char *str, uint8_t spacing, uint8_t size);
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,115 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi.h"
|
||||
|
||||
static const char *TAG = "wlan";
|
||||
|
||||
/* The event group allows multiple bits for each event, but we only care about two events:
|
||||
* - we are connected to the AP with an IP
|
||||
* - we failed to connect after the maximum amount of retries */
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
#define WIFI_FAIL_BIT BIT1
|
||||
|
||||
/* FreeRTOS event group to signal when we are connected*/
|
||||
static EventGroupHandle_t s_wifi_event_group;
|
||||
static int s_retry_num = 0;
|
||||
static void event_handler(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
{
|
||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
|
||||
esp_wifi_connect();
|
||||
} else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
|
||||
if (s_retry_num < CONFIG_ESP_MAXIMUM_RETRY) {
|
||||
esp_wifi_connect();
|
||||
s_retry_num++;
|
||||
ESP_LOGI(TAG, "retry to connect to the AP");
|
||||
} else {
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||
}
|
||||
ESP_LOGI(TAG,"connect to the AP fail");
|
||||
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
|
||||
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
|
||||
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||
s_retry_num = 0;
|
||||
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_init_sta(void)
|
||||
{
|
||||
s_wifi_event_group = xEventGroupCreate();
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
esp_netif_create_default_wifi_sta();
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
esp_event_handler_instance_t instance_any_id;
|
||||
esp_event_handler_instance_t instance_got_ip;
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
|
||||
ESP_EVENT_ANY_ID,
|
||||
&event_handler,
|
||||
NULL,
|
||||
&instance_any_id));
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
|
||||
IP_EVENT_STA_GOT_IP,
|
||||
&event_handler,
|
||||
NULL,
|
||||
&instance_got_ip));
|
||||
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = CONFIG_ESP_WIFI_SSID,
|
||||
.password = CONFIG_ESP_WIFI_PASSWORD,
|
||||
///* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (pasword len => 8).
|
||||
// * If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
|
||||
// * to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
|
||||
// * WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
|
||||
// */
|
||||
//.threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
|
||||
//.sae_pwe_h2e = ESP_WIFI_SAE_MODE,
|
||||
//.sae_h2e_identifier = EXAMPLE_H2E_IDENTIFIER,
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
|
||||
ESP_ERROR_CHECK(esp_wifi_start() );
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||
|
||||
/* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
|
||||
* number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */
|
||||
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
|
||||
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
||||
pdFALSE,
|
||||
pdFALSE,
|
||||
portMAX_DELAY);
|
||||
|
||||
/* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
|
||||
* happened. */
|
||||
if (bits & WIFI_CONNECTED_BIT) {
|
||||
ESP_LOGI(TAG, "connected to ap SSID:%s password:%s",
|
||||
CONFIG_ESP_WIFI_SSID, CONFIG_ESP_WIFI_PASSWORD);
|
||||
} else if (bits & WIFI_FAIL_BIT) {
|
||||
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
|
||||
CONFIG_ESP_WIFI_SSID, CONFIG_ESP_WIFI_PASSWORD);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
}
|
||||
|
||||
void wlan_init(){
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
wifi_init_sta();
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
void wlan_init(void);
|
||||
@ -1,6 +0,0 @@
|
||||
CONFIG_APP_BUILD_TYPE_ELF_RAM=y
|
||||
CONFIG_VFS_SUPPORT_TERMIOS=
|
||||
CONFIG_NEWLIB_NANO_FORMAT=y
|
||||
CONFIG_ESP32_PANIC_PRINT_HALT=y
|
||||
CONFIG_ESP32_DEBUG_STUBS_ENABLE=
|
||||
CONFIG_ESP_ERR_TO_NAME_LOOKUP=
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue