Skip to content

Commit 24bb281

Browse files
authored
Merge pull request #23 from Nefry-Community/develop
0.6.2
2 parents d9ed7e0 + fc7dd0a commit 24bb281

36 files changed

+2345
-473
lines changed

boards.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ nefrybt.menu.DebugLevel.info.build.code_debug=3
9797
nefrybt.menu.DebugLevel.debug=Debug
9898
nefrybt.menu.DebugLevel.debug.build.code_debug=4
9999
nefrybt.menu.DebugLevel.verbose=Verbose
100-
nefrybt.menu.DebugLevel.verbose.build.code_debug=5
100+
nefrybt.menu.DebugLevel.verbose.build.code_debug=5

cores/esp32/esp32-hal-bt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ bool btStarted(){
2323
}
2424

2525
bool btStart(){
26-
esp_bt_controller_config_t cfg;
27-
memset(&cfg, 0, sizeof(esp_bt_controller_config_t));
26+
esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
2827
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED){
2928
return true;
3029
}

cores/esp32/main.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "./nefry/NefryWebServer.h"
66
#include "./nefry/Nefry.h"
7+
#include "./nefry/NefryWiFi.h"
8+
#include "./nefry/NefryConfig.h"
79

810
#if CONFIG_AUTOSTART_ARDUINO
911

@@ -15,35 +17,44 @@
1517

1618
void loopTask(void *pvParameters)
1719
{
18-
Nefry.nefry_init();
20+
while (Nefry.getBootMode() == -1) {}
21+
while (Nefry.getBootMode() == 0) {
22+
Nefry.pollingSW();
23+
}
1924
if (Nefry.getWriteMode() != true) {
25+
delay(500);
2026
setup();
2127
}
22-
NefryWebServer.begin();
2328
for(;;) {
2429
micros(); //update overflow
2530
if (Nefry.getWriteMode() != true) {
2631
loop();
2732
}
28-
Nefry.nefry_loop();
2933
}
3034
}
3135

3236
void NefryBackEnd(void *pvParameters) {
3337
TickType_t xLastWakeTime;
3438
xLastWakeTime = xTaskGetTickCount();
39+
Nefry.nefry_init();
40+
NefryWeb.begin();
41+
NefryWiFi.beginWeb();
42+
NefryConfig.beginWeb();
43+
NefryWebServer.begin();
3544
for (;;) {
36-
vTaskDelayUntil(&xLastWakeTime,100/portTICK_PERIOD_MS);
37-
NefryWebServer.run();
45+
vTaskDelayUntil(&xLastWakeTime,10/portTICK_PERIOD_MS);
46+
NefryWeb.run();
47+
NefryWebServer.run();
3848
Nefry.pollingSW();
49+
Nefry.nefry_loop();
3950
}
4051
}
4152

4253
extern "C" void app_main()
4354
{
4455
initArduino();
45-
xTaskCreatePinnedToCore(loopTask, "loopTask", 4096, NULL, 2, NULL, 1);
46-
xTaskCreatePinnedToCore(&NefryBackEnd, "NefryBackEnd", 9192, NULL, 1, NULL,0);
56+
xTaskCreatePinnedToCore(loopTask, "loopTask", 8192, NULL, 2, NULL,1);
57+
xTaskCreatePinnedToCore(&NefryBackEnd, "NefryBackEnd", 8192, NULL, 1, NULL,0);
4758
}
4859

4960
#endif

cores/esp32/nefry/Nefry.cpp

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

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

3030
Adafruit_NeoPixel _NefryLED[40];
@@ -34,6 +34,8 @@ Adafruit_NeoPixel _NefryLED[40];
3434
void Nefry_lib::nefry_init() {
3535
beginLed(1, 16, NEO_GRB);
3636
enableSW();
37+
delay(50);
38+
_bootMode = 0;
3739
setLed(0x00, 0x0f, 0x00);
3840
Serial.begin(115200);
3941
Serial.println(F("\n\nStartup"));
@@ -276,32 +278,14 @@ bool Nefry_lib::getWriteMode() {
276278
if (_bootMode == 2)return true;
277279
return false;
278280
}
279-
281+
long Nefry_lib::getBootMode()
282+
{
283+
return _bootMode;
284+
}
280285
void Nefry_lib::setStoreTitle(const char set[15], const int num)
281286
{
282287
NefryConfig.setStoreTitle(set, num);
283288
return ;
284289
}
285290

286-
/*
287-
String Nefry_Conf::setDefaultModuleId() {
288-
uint8_t macAddr[WL_MAC_ADDR_LENGTH];
289-
String moduleName;
290-
WiFi.macAddress(macAddr);
291-
switch (boardId)
292-
{
293-
case 1:
294-
moduleName = "Nefry";
295-
break;
296-
case 2:
297-
moduleName = "CocoaBit";
298-
break;
299-
}
300-
moduleName += "-";
301-
moduleName += macAddr[WL_MAC_ADDR_LENGTH - 2];
302-
moduleName += macAddr[WL_MAC_ADDR_LENGTH - 1];
303-
return moduleName
304-
}
305-
*/
306-
307291
Nefry_lib Nefry;

cores/esp32/nefry/Nefry.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class Nefry_lib
4444
getAddressStr(IPAddress ip);
4545

4646
long
47-
getStoreValue(int pointer);
47+
getStoreValue(int pointer),
48+
getBootMode();
4849

4950

5051
void
@@ -76,7 +77,7 @@ class Nefry_lib
7677
_swPushingflg = false;
7778

7879
int
79-
_bootMode = 0, /* Boot状態を管理 0:起動中 1:通常起動 2:書き込みモード */
80+
_bootMode = -1, /* Boot状態を管理 -1:初期化中 0:起動中 1:通常起動 2:書き込みモード */
8081
hextonum(char c);
8182

8283
const char * program;

cores/esp32/nefry/NefryConfig.cpp

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ StoreStr : Nefryの環境変数を保存するときに使用する。(0-7)の
2121

2222

2323

24-
String Nefry_Conf::beginWeb(String link) {
25-
26-
if (link.equals("config")) {
24+
void Nefry_Conf::beginWeb() {
25+
NefryWebServer.getWebServer()->on("/config", [&]() {
2726
String content = F("<h1>Nefry DataStore Setup</h1><p>このページはプログラム内から読み書きした値を表示、編集することができます。</p>"
28-
"<p>わざわざプログラムを書き換えずに値を変更できるためWebサービスでアクセスキーが必要になる場合など環境変数として扱うことができます。</p>"
27+
"<p>わざわざプログラムを書き換えずに値を変更できるためWebサービスでアクセスキーが必要になる場合やモードを切り替える時など環境変数として扱うことができます。</p>"
2928
"<ul><li>setStoreValue or setStoreStr : 値の保存</li><li>getStoreValue or getStoreStr : 値の取得</li><li>setStoreTitle : 内容の表示</li></ul>"
3029
"<p>それぞれの関数の使い方はNefry公式サイトをご覧になるか、サンプルプログラムを参考にしてください。</p><form method='get'action='set_config'>");
31-
int formNumber,printCounter = 0;
30+
int formNumber, printCounter = 0;
3231
for (formNumber = 0; formNumber < 10; formNumber++) {
33-
if (htmlPrint[formNumber] == 1) {
32+
if (htmlPrint[formNumber] == true) {
3433
content += F("<div class=\"row\"><label>");
3534
content += module_input[formNumber];
3635
content += F("</label><div><input name=\"smo");
@@ -42,7 +41,7 @@ String Nefry_Conf::beginWeb(String link) {
4241
}
4342
}
4443
for (formNumber = 10; formNumber < 20; formNumber++) {
45-
if (htmlPrint[formNumber] == 1) {
44+
if (htmlPrint[formNumber] == true) {
4645
content += F("<div class=\"row\"><label>");
4746
content += module_input[formNumber];
4847
content += F("</label><div><input name=\"imo");
@@ -54,7 +53,7 @@ String Nefry_Conf::beginWeb(String link) {
5453
}
5554
}
5655
delay(1);
57-
if(printCounter == 0){
56+
if (printCounter == 0) {
5857
content += F("<p>表示するものがひとつもありません。setStoreTitle関数を使って表示をするか、WriteModeにしてください。</p>");
5958

6059
}
@@ -64,32 +63,59 @@ String Nefry_Conf::beginWeb(String link) {
6463
content += F("<div class=\"writemode\">");
6564
if (Nefry.getWriteMode())content += "WriteMode";
6665
content += F("</div><a href=\"/\">Back to top</a>");
67-
return NefryWeb.createHtml(F("Nefry DataStore"), "", content);
68-
}
69-
return "";
66+
NefryWebServer.getWebServer()->send(200, "text/html", NefryWeb.createHtml(F("Nefry DataStore"), "", content));
67+
});
68+
69+
NefryWebServer.getWebServer()->on("/set_config", [&]() {
70+
char webarg[5] = { "smo0" };
71+
for (int i = 0; i < 10; i++) {
72+
webarg[3] = '0' + i;
73+
String s = NefryWebServer.getWebServer()->arg(webarg);
74+
#ifdef DEBUG_ESP_HTTP_SERVER
75+
DEBUG_OUTPUT.print(webarg);
76+
DEBUG_OUTPUT.print(" : ");
77+
DEBUG_OUTPUT.println(s);
78+
#endif
79+
NefryDataStore.setStorageStr(s, i);
80+
}
81+
webarg[0] = 'i';
82+
for (int i = 0; i < 10; i++) {
83+
webarg[3] = '0' + i;
84+
String s = NefryWebServer.getWebServer()->arg(webarg);
85+
#ifdef DEBUG_ESP_HTTP_SERVER
86+
DEBUG_OUTPUT.print(webarg);
87+
DEBUG_OUTPUT.print(" : ");
88+
DEBUG_OUTPUT.println(s);
89+
#endif
90+
NefryDataStore.setStorageValue(s.toInt(), i);
91+
}
92+
NefryWebServer.getWebServer()->send(200, "text/html", NefryWeb.createHtml(F("Nefry DataStore Set"), "", F("<h1>Nefry Module Set</h1><p>Saveing & Restart...</p><a href=\"/\">Back to top</a>")));
93+
NefryWebServer.resetTimer(2);
94+
});
7095
}
71-
/* HTMLに表示するのか */
96+
/* HTMLに表示するのか */
7297
void Nefry_Conf::setStoreTitle(const char set[15], const int num) {
7398
if (0 <= num&&num < 20) {
7499
strcpy(module_input[num], set);
75-
htmlPrint[num] = 1;
100+
htmlPrint[num] = true;
76101
}
77102

78103
}
79104

105+
80106
void Nefry_Conf::begin()
81107
{
82108
for (int i = 0; i < 10; i++) {
83109
sprintf(module_input[i], "String %d", i);
84-
sprintf(module_input[10+i], "Value %d", 10+i);
110+
sprintf(module_input[10 + i], "Value %d", 10 + i);
85111
if (Nefry.getWriteMode()) {
86-
htmlPrint[i] = 1;
87-
htmlPrint[10+i] = 1;
112+
htmlPrint[i] = true;
113+
htmlPrint[10 + i] = true;
88114
}
89115
else {
90-
htmlPrint[i] = 0;
91-
htmlPrint[10 + i] = 0;
92-
}
116+
htmlPrint[i] = false;
117+
htmlPrint[10 + i] = false;
118+
}
93119
}
94120
}
95121
Nefry_Conf NefryConfig;

cores/esp32/nefry/NefryConfig.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ class Nefry_Conf
99
{
1010
public:
1111
void
12+
beginWeb(),
1213
begin(),
1314
setStoreTitle(const char set[15], const int num);
14-
15-
String
16-
beginWeb(String link),
17-
setDefaultModuleId();
18-
1915
private:
2016
bool htmlPrint[20];//10
2117
char module_input[20][15];

0 commit comments

Comments
 (0)