10000 Merge pull request #675 from nkolban/master · jamesseth/esp32-snippets@088c18c · GitHub
[go: up one dir, main page]

Skip to content

Commit 088c18c

Browse files
authored
Merge pull request nkolban#675 from nkolban/master
ibeacon UUId &
2 parents dd59d41 + e742546 commit 088c18c

File tree

169 files changed

+6764
-4066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+6764
-4066
lines changed

.DS_Store

6 KB
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# FastFlash
2+
As we build ESP32 applications, we typically perform a compile, flash, test loop cycle. We compile an app, we flash the ESP32 with that app and then we test whether it works. We perform these actions over and over again. When we look at the time taken in each step, we see there is compile time on our PC and then the time taken to flash the PC. This story talks about the time taken to flash the PC.
3+
4+
The ESP32 is typically configured to flash at 115200 kbps. This is 115200 bits per second. If we think that a typical ESP32 application is 800KBytes then this requires a transmission of:
5+
6+
800000 * 9 = 7.2 million bits = 62.5 seconds
7+
8+
we can increase our baud rate up to 921600 = 7.8 seconds

VisualStudioCode/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
These are file for Microsoft Visual Studio Code and can be copied into your `.vscode` project folder. For more information on this area, see:
2+
3+
* [VSCode JTAG Debugging of ESP32 - Part 2](https://gojimmypi.blogspot.com/2017/05/vscode-remote-jtag-debugging-of-esp32.html)
4+
* [Deous/VSC-Guide-for-esp32](https://github.com/Deous/VSC-Guide-for-esp32)

VisualStudioCode/c_cpp_properties.json

Lines changed: 266 additions & 0 deletions
Large diffs are not rendered by default.

VisualStudioCode/launch.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
5+
{
6+
"name": "ESP32 OpenOCD launch",
7+
"type": "cppdbg",
8+
"request": "launch",
9+
"program": "./build/app-template.elf",
10+
"args": [],
11+
"stopAtEntry": true,
12+
"cwd": "${workspaceFolder}",
13+
"environment": [],
14+
"externalConsole": false,
15+
"MIMode": "gdb",
16+
"miDebuggerPath": "/opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb",
17+
"setupCommands": [
18+
{
19+
"description": "Enable pretty-printing for gdb",
20+
"text": "-enable-pretty-printing",
21+
"ignoreFailures": true
22+
},
23+
{
24+
"text": "target remote localhost:3333"
25+
},
26+
{
27+
"text": "monitor reset halt"
28+
},
29+
{
30+
"text": "flushregs"
31+
},
32+
{
33+
"text": "thb app_main"
34+
}
35+
],
36+
"logging": {
37+
"trace": true,
38+
"traceResponse": true,
39+
"engineLogging": true
40+
}
41+
}
42+
]
43+
}

VisualStudioCode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

VisualStu D7AE dioCode/tasks.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "menuconfig",
8+
"type": "shell",
9+
"command": "make menuconfig",
10+
"problemMatcher": []
11+
},
12+
{
13+
"label": "make",
14+
"type": "shell",
15+
"command": "make -j5",
16+
"group": {
17+
"kind": "build",
18+
"isDefault": true
19+
},
20+
"problemMatcher": []
21+
},
22+
{
23+
"label": "flash",
24+
"type": "shell",
25+
"command": "make flash monitor",
26+
"problemMatcher": []
27+
},
28+
{
29+
"label": "monitor",
30+
"type": "shell",
31+
"command": "make monitor",
32+
"problemMatcher": []
33+
},
34+
{
35+
"label": "clean",
36+
"type": "shell",
37+
"command": "make clean",
38+
"problemMatcher": []
39+
}
40+
]
41+
}

cloud/GCP/JWT/base64url.cpp

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// https://raw.githubusercontent.com/zhicheng/base64/master/base64.c
2+
/* This is a public domain base64 implementation written by WEI Zhicheng. */
3+
4+
#include <stdio.h>
5+
6+
#include "base64url.h"
7+
8+
/* BASE 64 encode table */
9+
static const char base64en[] = {
10+
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
11+
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
12+
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
13+
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
14+
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
15+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
16+
'w', 'x', 'y', 'z', '0', '1', '2', '3',
17+
'4', '5', '6', '7', '8', '9', '-', '_',
18+
};
19+
20+
#define BASE64_PAD '='
21+
22+
23+
#define BASE64DE_FIRST '+'
24+
#define BASE64DE_LAST 'z'
25+
/* ASCII order for BASE 64 decode, -1 in unused character */
26+
static const signed char base64de[] = {
27+
/* '+', ',', '-', '.', '/', '0', '1', '2', */
28+
62, -1, -1, -1, 63, 52, 53, 54,
29+
30+
/* '3', '4', '5', '6', '7', '8', '9', ':', */
31+
55, 56, 57, 58, 59, 60, 61, -1,
32+
33+
/* ';', '<', '=', '>', '?', '@', 'A', 'B', */
34+
-1, -1, -1, -1, -1, -1, 0, 1,
35+
36+
/* 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', */
37+
2, 3, 4, 5, 6, 7, 8, 9,
38+
39+
/* 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', */
40+
10, 11, 12, 13, 14, 15, 16, 17,
41+
42+
/* 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', */
43+
18, 19, 20, 21, 22, 23, 24, 25,
44+
45+
/* '[', '\', ']', '^', '_', '`', 'a', 'b', */
46+
-1, -1, -1, -1, -1, -1, 26, 27,
47+
48+
/* 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', */
49+
28, 29, 30, 31, 32, 33, 34, 35,
50+
51+
/* 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', */
52+
36, 37, 38, 39, 40, 41, 42, 43,
53+
54+
/* 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', */
55+
44, 45, 46, 47, 48, 49, 50, 51,
56+
};
57+
58+
int base64url_encode(const unsigned char *in, unsigned int inlen, char *out)
59+
{
60+
unsigned int i, j;
61+
62+
for (i = j = 0; i < inlen; i++) {
63+
int s = i % 3; /* from 6/gcd(6, 8) */
64+
65+
switch (s) {
66+
case 0:
67+
out[j++] = base64en[(in[i] >> 2) & 0x3F];
68+
continue;
69+
case 1:
70+
out[j++] = base64en[((in[i-1] & 0x3) << 4) + ((in[i] >> 4) & 0xF)];
71+
continue;
72+
case 2:
73+
out[j++] = base64en[((in[i-1] & 0xF) << 2) + ((in[i] >> 6) & 0x3)];
74+
out[j++] = base64en[in[i] & 0x3F];
75+
}
76+
}
77+
78+
/* move back */
79+
i -= 1;
80+
81+
/* check the last and add padding */
82+
83+
if ((i % 3) == 0) {
84+
out[j++] = base64en[(in[i] & 0x3) << 4];
85+
//out[j++] = BASE64_PAD;
86+
//out[j++] = BASE64_PAD;
87+
} else if ((i % 3) == 1) {
88+
out[j++] = base64en[(in[i] & 0xF) << 2];
89+
//out[j++] = BASE64_PAD;
90+
}
91+
92+
out[j++] = 0;
93+
94+
return BASE64_OK;
95+
}
96+
97+
int base64url_decode(const char *in, unsigned int inlen, unsigned char *out)
98+
{
99+
unsigned int i, j;
100+
101+
for (i = j = 0; i < inlen; i++) {
102+
int c;
103+
int s = i % 4; /* from 8/gcd(6, 8) */
104+
105+
if (in[i] == '=')
106+
return BASE64_OK;
107+
108+
if (in[i] < BASE64DE_FIRST || in[i] > BASE64DE_LAST ||
109+
(c = base64de[in[i] - BASE64DE_FIRST]) == -1)
110+
return BASE64_INVALID;
111+
112+
switch (s) {
113+
case 0:
114+
out[j] = ((unsigned int)c << 2) & 0xFF;
115+
continue;
116+
case 1:
117+
out[j++] += ((unsigned int)c >> 4) & 0x3;
118+
119+
/* if not last char with padding */
120+
if (i < (inlen - 3) || in[inlen - 2] != '=')
121+
out[j] = ((unsigned int)c & 0xF) << 4;
122+
continue;
123+
case 2:
124+
out[j++] += ((unsigned int)c >> 2) & 0xF;
125+
126+
/* if not last char with padding */
127+
if (i < (inlen - 2) || in[inlen - 1] != '=')
128+
out[j] = ((unsigned int)c & 0x3) << 6;
129+
continue;
130+
case 3:
131+
out[j++] += (unsigned char)c;
132+
}
133+
}
134+
135+
return BASE64_OK;
136+
}

cloud/GCP/JWT/base64url.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// https://raw.githubusercontent.com/zhicheng/base64/master/base64.h
2+
#ifndef __BASE64URL_H__
3+
#define __BASE64URL_H__
4+
5+
enum {BASE64_OK = 0, BASE64_INVALID};
6+
7+
#define BASE64_ENCODE_OUT_SIZE(s) (((s) + 2) / 3 * 4)
8+
#define BASE64_DECODE_OUT_SIZE(s) (((s)) / 4 * 3)
9+
10+
int base64url_encode(const unsigned char *in, unsigned int inlen, char *out);
11+
12+
int base64url_decode(const char *in, unsigned int inlen, unsigned char *out);
13+
14+
15+
#endif /* __BASE64URL_H__ */

0 commit comments

Comments
 (0)
0