Skip to content

Commit 7780b57

Browse files
authored
Merge pull request #28 from Nefry-Community/develop
0.7.0
2 parents 24bb281 + 290348b commit 7780b57

File tree

237 files changed

+14661
-609
lines changed

Some content is hidden

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

237 files changed

+14661
-609
lines changed

Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ menu "Arduino Configuration"
33
config ENABLE_ARDUINO_DEPENDS
44
bool
55
select LWIP_SO_RCVBUF
6-
select BT_ENABLED
76
select ETHERNET
87
select WIFI_ENABLED
98
select ESP32_PHY_CALIBRATION_AND_DATA_STORAGE

cores/esp32/Esp.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,11 @@ bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size)
212212
{
213213
return spi_flash_read(offset, (uint32_t*) data, size) == ESP_OK;
214214
}
215+
216+
217+
uint64_t EspClass::getEfuseMac(void)
218+
{
219+
uint64_t _chipmacid;
220+
esp_efuse_read_mac((uint8_t*) (&_chipmacid));
221+
return _chipmacid;
222+
}

cores/esp32/Esp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class EspClass
7676
bool flashWrite(uint32_t offset, uint32_t *data, size_t size);
7777
bool flashRead(uint32_t offset, uint32_t *data, size_t size);
7878

79+
uint64_t getEfuseMac();
80+
7981
};
8082

8183
extern EspClass ESP;

cores/esp32/esp32-hal-bt.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include "esp32-hal-bt.h"
1616

17+
#if CONFIG_BT_ENABLED
18+
1719
#include "bt.h"
1820
#include "esp_bt_defs.h"
1921
#include "esp_bt_main.h"
@@ -62,5 +64,20 @@ bool btStop(){
6264
return false;
6365
}
6466

67+
#else
68+
bool btStarted()
69+
{
70+
return false;
71+
}
72+
73+
bool btStart()
74+
{
75+
return false;
76+
}
6577

78+
bool btStop()
79+
{
80+
return false;
81+
}
82+
#endif
6683

cores/esp32/esp32-hal-spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ void spiSetDataMode(spi_t * spi, uint8_t dataMode)
332332
break;
333333
case SPI_MODE2:
334334
spi->dev->pin.ck_idle_edge = 1;
335-
spi->dev->user.ck_out_edge = 0;
335+
spi->dev->user.ck_out_edge = 1;
336336
break;
337337
case SPI_MODE3:
338338
spi->dev->pin.ck_idle_edge = 1;
339-
spi->dev->user.ck_out_edge = 1;
339+
spi->dev->user.ck_out_edge = 0;
340340
break;
341341
case SPI_MODE0:
342342
default:

cores/esp32/libb64/cdecode.c

Lines changed: 81 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6,89 +6,94 @@ For details, see http://sourceforge.net/projects/libb64
66
*/
77

88
#include "cdecode.h"
9+
#include <stdint.h>
910

10-
int base64_decode_value(char value_in)
11-
{
12-
static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
13-
static const char decoding_size = sizeof(decoding);
14-
value_in -= 43;
15-
if (value_in < 0 || value_in > decoding_size) {
16-
return -1;
17-
}
18-
return decoding[(int)value_in];
11+
static int base64_decode_value_signed(int8_t value_in){
12+
static const int8_t decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
13+
static const int8_t decoding_size = sizeof(decoding);
14+
value_in -= 43;
15+
if (value_in < 0 || value_in > decoding_size) return -1;
16+
return decoding[(int)value_in];
17+
}
18+
19+
void base64_init_decodestate(base64_decodestate* state_in){
20+
state_in->step = step_a;
21+
state_in->plainchar = 0;
1922
}
2023

21-
void base64_init_decodestate(base64_decodestate* state_in)
22-
{
23-
state_in->step = step_a;
24-
state_in->plainchar = 0;
24+
static int base64_decode_block_signed(const int8_t* code_in, const int length_in, int8_t* plaintext_out, base64_decodestate* state_in){
25+
const int8_t* codechar = code_in;
26+
int8_t* plainchar = plaintext_out;
27+
int8_t fragment;
28+
29+
*plainchar = state_in->plainchar;
30+
31+
switch (state_in->step){
32+
while (1){
33+
case step_a:
34+
do {
35+
if (codechar == code_in+length_in){
36+
state_in->step = step_a;
37+
state_in->plainchar = *plainchar;
38+
return plainchar - plaintext_out;
39+
}
40+
fragment = (int8_t)base64_decode_value_signed(*codechar++);
41+
} while (fragment < 0);
42+
*plainchar = (fragment & 0x03f) << 2;
43+
case step_b:
44+
do {
45+
if (codechar == code_in+length_in){
46+
state_in->step = step_b;
47+
state_in->plainchar = *plainchar;
48+
return plainchar - plaintext_out;
49+
}
50+
fragment = (int8_t)base64_decode_value_signed(*codechar++);
51+
} while (fragment < 0);
52+
*plainchar++ |= (fragment & 0x030) >> 4;
53+
*plainchar = (fragment & 0x00f) << 4;
54+
case step_c:
55+
do {
56+
if (codechar == code_in+length_in){
57+
state_in->step = step_c;
58+
state_in->plainchar = *plainchar;
59+
return plainchar - plaintext_out;
60+
}
61+
fragment = (int8_t)base64_decode_value_signed(*codechar++);
62+
} while (fragment < 0);
63+
*plainchar++ |= (fragment & 0x03c) >> 2;
64+
*plainchar = (fragment & 0x003) << 6;
65+
case step_d:
66+
do {
67+
if (codechar == code_in+length_in){
68+
state_in->step = step_d;
69+
state_in->plainchar = *plainchar;
70+
return plainchar - plaintext_out;
71+
}
72+
fragment = (int8_t)base64_decode_value_signed(*codechar++);
73+
} while (fragment < 0);
74+
*plainchar++ |= (fragment & 0x03f);
75+
}
76+
}
77+
/* control should not reach here */
78+
return plainchar - plaintext_out;
2579
}
2680

27-
int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in)
28-
{
29-
const char* codechar = code_in;
30-
char* plainchar = plaintext_out;
31-
char fragment;
81+
static int base64_decode_chars_signed(const int8_t* code_in, const int length_in, int8_t* plaintext_out){
82+
base64_decodestate _state;
83+
base64_init_decodestate(&_state);
84+
int len = base64_decode_block_signed(code_in, length_in, plaintext_out, &_state);
85+
if(len > 0) plaintext_out[len] = 0;
86+
return len;
87+
}
3288

33-
*plainchar = state_in->plainchar;
89+
int base64_decode_value(char value_in){
90+
return base64_decode_value_signed(*((int8_t *) &value_in));
91+
}
3492

35-
switch (state_in->step) {
36-
while (1) {
37-
case step_a:
38-
do {
39-
if (codechar == code_in+length_in) {
40-
state_in->step = step_a;
41-
state_in->plainchar = *plainchar;
42-
return plainchar - plaintext_out;
43-
}
44-
fragment = (char)base64_decode_value(*codechar++);
45-
} while (fragment < 0);
46-
*plainchar = (fragment & 0x03f) << 2;
47-
case step_b:
48-
do {
49-
if (codechar == code_in+length_in) {
50-
state_in->step = step_b;
51-
state_in->plainchar = *plainchar;
52-
return plainchar - plaintext_out;
53-
}
54-
fragment = (char)base64_decode_value(*codechar++);
55-
} while (fragment < 0);
56-
*plainchar++ |= (fragment & 0x030) >> 4;
57-
*plainchar = (fragment & 0x00f) << 4;
58-
case step_c:
59-
do {
60-
if (codechar == code_in+length_in) {
61-
state_in->step = step_c;
62-
state_in->plainchar = *plainchar;
63-
return plainchar - plaintext_out;
64-
}
65-
fragment = (char)base64_decode_value(*codechar++);
66-
} while (fragment < 0);
67-
*plainchar++ |= (fragment & 0x03c) >> 2;
68-
*plainchar = (fragment & 0x003) << 6;
69-
case step_d:
70-
do {
71-
if (codechar == code_in+length_in) {
72-
state_in->step = step_d;
73-
state_in->plainchar = *plainchar;
74-
return plainchar - plaintext_out;
75-
}
76-
fragment = (char)base64_decode_value(*codechar++);
77-
} while (fragment < 0);
78-
*plainchar++ |= (fragment & 0x03f);
79-
}
80-
}
81-
/* control should not reach here */
82-
return plainchar - plaintext_out;
93+
int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in){
94+
return base64_decode_block_signed((int8_t *) code_in, length_in, (int8_t *) plaintext_out, state_in);
8395
}
8496

85-
int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out)
86-
{
87-
base64_decodestate _state;
88-
base64_init_decodestate(&_state);
89-
int len = base64_decode_block(code_in, length_in, plaintext_out, &_state);
90-
if(len > 0) {
91-
plaintext_out[len] = 0;
92-
}
93-
return len;
97+
int base64_decode_chars(const char* code_in, const int length_in, char* plaintext_out){
98+
return base64_decode_chars_signed((int8_t *) code_in, length_in, (int8_t *) plaintext_out);
9499
}

cores/esp32/nefry/Nefry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BootMode
2424
1 : WriteMode切替をする
2525
*/
2626

27-
#define LIBVERSION ("0.6.2")
27+
#define LIBVERSION ("0.7.0")
2828
#include "Nefry.h"
2929

3030
Adafruit_NeoPixel _NefryLED[40];

cores/esp32/nefry/NefryWeb.cpp

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ void Nefry_Web::beginWeb() {
5656
content += Nefry.getAddressStr(WiFi.localIP());
5757
content += F("</div><div>Module ID: ");
5858
content += Nefry.getModuleID();
59+
content += F("</div><div>");
60+
if (Nefry.getWriteMode())content += F("WriteMode");
5961
content += F(
60-
"</div><div class=\"writemode\">"
6162
"</div><ul>"
6263
"<li><a href='/wifi_conf'>Setup WiFi</a>"
6364
"<li><a href='/config'>Data Store</a>"
64-
"<li><a href='/web_update'>Module Config</a>"
65+
"<li><a href='/module'>Module Config</a>"
6566
"<li><a href='/web_update'>Web Sketch Download</a>"
6667
"<li><a href='/update'>Upload Sketch</a>"
6768
"<li><a href='/console'>Web Console</a>"
@@ -103,6 +104,66 @@ void Nefry_Web::beginWeb() {
103104
F("<h1>Nefry Write mode</h1><p>Reset start!</p><a href=\"/\">Back to top</a>")));
104105
NefryWebServer.resetTimer(2);
105106
});
107+
108+
NefryWebServer.getWebServer()->on("/module", [&]() {
109+
String content = F(
110+
"<h1>Module Config</h1>"
111+
"<p>Nefryモジュールに関する設定をすることができます。</p><table><tr>"
112+
"<th>Wifi Sport</th><td>"
113+
);
114+
content += WiFi.SSID();
115+
content += F("</td></tr><tr><th>IP Address</th><td>");
116+
content += Nefry.getAddressStr(WiFi.localIP());
117+
content += F("</td></tr><tr><th>SubnetMask</th><td>");
118+
content += Nefry.getAddressStr(WiFi.subnetMask());
119+
content += F("</td></tr><tr><th>Gateway IP Address</th><td>");
120+
content += Nefry.getAddressStr(WiFi.gatewayIP());
121+
content += F("</td></tr><tr><th>MAC Address</th><td>");
122+
content += WiFi.macAddress();
123+
content += F("</td></tr><tr><th>Module ID</th><td>");
124+
content += Nefry.getModuleID();
125+
content += F("</td></tr><tr><th>Nefry library</th><td>");
126+
content += Nefry.getVersion();
127+
content += F("</td></tr><tr><th>Running ProgramName </th><td>");
128+
content += Nefry.getProgramName();
129+
content += F("</td></tr><tr><th></th><td>");
130+
if(Nefry.getWriteMode())content += F("WriteMode");
131+
content += F(
132+
"</td></tr></table></br><form method='get'action='setmodule'><div class=\"row\"><label>Module ID:</label>"
133+
"<div><input name=\"id\"maxlength=\"32\"value=\""
134+
);
135+
content += Nefry.getModuleID();
136+
content += F(
137+
"\"></div></div>"
138+
"<div class=\"row\"><label>Module class:</label><div><input name=\"cls\"maxlength=\"32\"value=\"");
139+
content += Nefry.getModuleClass();
140+
content += F(
141+
"\"></div></div>"
142+
"<div class=\"row\"><label>Nefry WiFi Pass:</label><div><input type=\"password\"name=\"pwd\"maxlength=\"64\"></div></div>"
143+
"<div class=\"row\"><label>Nefry User:</label><div><input name=\"user\"maxlength=\"32\"value=\"");
144+
content += Nefry.getUser();
145+
content += F("\"></div></div><div class = \"row\"><label>Nefry User Pass:</label><div><input type=\"password\"name=\"uPas\"maxlength=\"32\"value=\"\"></div></div>");
146+
content += F("<div class=\"psrow\"><div><input type=\"button\"value=\"Save\"onclick=\"return jsSubmit(this.form);\"></div></form>"
147+
"<div><form method='get'action='reset'><input type=\"button\"value=\"Restart\"onclick=\"return jsSubmit(this.form);\"></form></div>"
148+
"<div><form method='get'action='onreset'><input type=\"button\"value=\"Write Mode\"onclick=\"return jsSubmit(this.form);\"></form></div>"
149+
" </div><a href=\"/\">Back to top</a>");
150+
151+
NefryWebServer.getWebServer()->send(200, "text/html", createHtml(F("Module Config"),"",content));
152+
});
153+
154+
NefryWebServer.getWebServer()->on("/setmodule", [&]() {
155+
String pwd = NefryWebServer.getWebServer()->arg("pwd");
156+
String upwd = NefryWebServer.getWebServer()->arg("uPas");
157+
Nefry.setModuleID(NefryWebServer.getWebServer()->arg("id"));
158+
Nefry.setModuleClass(NefryWebServer.getWebServer()->arg("cls"));
159+
if(pwd.length() > 0)
160+
Nefry.setModulePass(pwd);
161+
Nefry.setUser(NefryWebServer.getWebServer()->arg("user"));
162+
if (upwd.length() > 0)
163+
Nefry.setUserPass(upwd);
164+
NefryWebServer.getWebServer()->send(200, "text/html", createHtml(F("Save Module Config"), "", F("<h1>Nefry Module Set</h1><p>Saveing & Restart...</p><a href=\"/\">Back to top</a>")));
165+
NefryWebServer.resetTimer(2);
166+
});
106167
}
107168

108169
void Nefry_Web::begin()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
uint64_t chipid;
2+
3+
void setup() {
4+
Serial.begin(115200);
5+
}
6+
7+
void loop() {
8+
chipid=ESP.getEfuseMac();//The chip ID is essentially its MAC address(length: 6 bytes).
9+
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
10+
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
11+
12+
delay(3000);
13+
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <Nefry.h>
2+
//フルカラーLED ランダムに色が変わります。
3+
void setup() {
4+
Nefry.setProgramName("FullColorLED"); //プログラム名を管理することができます。
5+
randomSeed(analogRead(A0));
6+
}
7+
int red,green,blue;
8+
void loop() {
9+
red=random(255); //random関数は0-255の数値をランダムに返します。
10+
green=random(255);
11+
blue=random(255);
12+
Nefry.setLed(red,green,blue); //LEDがランダムに点灯します。
13+
delay(1000); //1秒待つ
14+
}

libraries/Nefry/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Nefry
2-
version=0.6.2
2+
version=0.7.0
33
author=Nefry community
44
maintainer=
55
sentence=nefry.

libraries/Nefy_IFTTT/examples/IFTTT_DataSend_Sample/IFTTT_DataSend_Sample.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ void setup() {
88
Nefry.setStoreTitle("Event",1); //Nefry DataStoreのタイトルを指定
99
SecretKey = Nefry.getStoreStr(0); //Nefry DataStoreからデータを取得
1010
Event = Nefry.getStoreStr(1); //Nefry DataStoreからデータを取得
11+
Nefry.enableSW(); //SWを有効化
1112
}
1213

1314
void loop() {

libraries/Nefy_IFTTT/examples/IFTTT_simple_Sample/IFTTT_simple_Sample.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void setup() {
77
Nefry.setStoreTitle("Event",1); //Nefry DataStoreのタイトルを指定
88
SecretKey = Nefry.getStoreStr(0); //Nefry DataStoreからデータを取得
99
Event = Nefry.getStoreStr(1); //Nefry DataStoreからデータを取得
10+
Nefry.enableSW(); //SW有効化
1011
}
1112

1213
void loop() {

0 commit comments

Comments
 (0)