Skip to content

0.6.2 #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ nefrybt.menu.DebugLevel.info.build.code_debug=3
nefrybt.menu.DebugLevel.debug=Debug
nefrybt.menu.DebugLevel.debug.build.code_debug=4
nefrybt.menu.DebugLevel.verbose=Verbose
nefrybt.menu.DebugLevel.verbose.build.code_debug=5
nefrybt.menu.DebugLevel.verbose.build.code_debug=5
3 changes: 1 addition & 2 deletions cores/esp32/esp32-hal-bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ bool btStarted(){
}

bool btStart(){
esp_bt_controller_config_t cfg;
memset(&cfg, 0, sizeof(esp_bt_controller_config_t));
esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
if(esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_ENABLED){
return true;
}
Expand Down
25 changes: 18 additions & 7 deletions cores/esp32/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "./nefry/NefryWebServer.h"
#include "./nefry/Nefry.h"
#include "./nefry/NefryWiFi.h"
#include "./nefry/NefryConfig.h"

#if CONFIG_AUTOSTART_ARDUINO

Expand All @@ -15,35 +17,44 @@

void loopTask(void *pvParameters)
{
Nefry.nefry_init();
while (Nefry.getBootMode() == -1) {}
while (Nefry.getBootMode() == 0) {
Nefry.pollingSW();
}
if (Nefry.getWriteMode() != true) {
delay(500);
setup();
}
NefryWebServer.begin();
for(;;) {
micros(); //update overflow
if (Nefry.getWriteMode() != true) {
loop();
}
Nefry.nefry_loop();
}
}

void NefryBackEnd(void *pvParameters) {
TickType_t xLastWakeTime;
xLastWakeTime = xTaskGetTickCount();
Nefry.nefry_init();
NefryWeb.begin();
NefryWiFi.beginWeb();
NefryConfig.beginWeb();
NefryWebServer.begin();
for (;;) {
vTaskDelayUntil(&xLastWakeTime,100/portTICK_PERIOD_MS);
NefryWebServer.run();
vTaskDelayUntil(&xLastWakeTime,10/portTICK_PERIOD_MS);
NefryWeb.run();
NefryWebServer.run();
Nefry.pollingSW();
Nefry.nefry_loop();
}
}

extern "C" void app_main()
{
initArduino();
xTaskCreatePinnedToCore(loopTask, "loopTask", 4096, NULL, 2, NULL, 1);
xTaskCreatePinnedToCore(&NefryBackEnd, "NefryBackEnd", 9192, NULL, 1, NULL,0);
xTaskCreatePinnedToCore(loopTask, "loopTask", 8192, NULL, 2, NULL,1);
xTaskCreatePinnedToCore(&NefryBackEnd, "NefryBackEnd", 8192, NULL, 1, NULL,0);
}

#endif
30 changes: 7 additions & 23 deletions cores/esp32/nefry/Nefry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BootMode
1 : WriteMode切替をする
*/

#define LIBVERSION ("0.6.1")
#define LIBVERSION ("0.6.2")
#include "Nefry.h"

Adafruit_NeoPixel _NefryLED[40];
Expand All @@ -34,6 +34,8 @@ Adafruit_NeoPixel _NefryLED[40];
void Nefry_lib::nefry_init() {
beginLed(1, 16, NEO_GRB);
enableSW();
delay(50);
_bootMode = 0;
setLed(0x00, 0x0f, 0x00);
Serial.begin(115200);
Serial.println(F("\n\nStartup"));
Expand Down Expand Up @@ -276,32 +278,14 @@ bool Nefry_lib::getWriteMode() {
if (_bootMode == 2)return true;
return false;
}

long Nefry_lib::getBootMode()
{
return _bootMode;
}
void Nefry_lib::setStoreTitle(const char set[15], const int num)
{
NefryConfig.setStoreTitle(set, num);
return ;
}

/*
String Nefry_Conf::setDefaultModuleId() {
uint8_t macAddr[WL_MAC_ADDR_LENGTH];
String moduleName;
WiFi.macAddress(macAddr);
switch (boardId)
{
case 1:
moduleName = "Nefry";
break;
case 2:
moduleName = "CocoaBit";
break;
}
moduleName += "-";
moduleName += macAddr[WL_MAC_ADDR_LENGTH - 2];
moduleName += macAddr[WL_MAC_ADDR_LENGTH - 1];
return moduleName
}
*/

Nefry_lib Nefry;
5 changes: 3 additions & 2 deletions cores/esp32/nefry/Nefry.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class Nefry_lib
getAddressStr(IPAddress ip);

long
getStoreValue(int pointer);
getStoreValue(int pointer),
getBootMode();


void
Expand Down Expand Up @@ -76,7 +77,7 @@ class Nefry_lib
_swPushingflg = false;

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

const char * program;
Expand Down
64 changes: 45 additions & 19 deletions cores/esp32/nefry/NefryConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ StoreStr : Nefryの環境変数を保存するときに使用する。(0-7)の



String Nefry_Conf::beginWeb(String link) {

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

}
Expand All @@ -64,32 +63,59 @@ String Nefry_Conf::beginWeb(String link) {
content += F("<div class=\"writemode\">");
if (Nefry.getWriteMode())content += "WriteMode";
content += F("</div><a href=\"/\">Back to top</a>");
return NefryWeb.createHtml(F("Nefry DataStore"), "", content);
}
return "";
NefryWebServer.getWebServer()->send(200, "text/html", NefryWeb.createHtml(F("Nefry DataStore"), "", content));
});

NefryWebServer.getWebServer()->on("/set_config", [&]() {
char webarg[5] = { "smo0" };
for (int i = 0; i < 10; i++) {
webarg[3] = '0' + i;
String s = NefryWebServer.getWebServer()->arg(webarg);
#ifdef DEBUG_ESP_HTTP_SERVER
DEBUG_OUTPUT.print(webarg);
DEBUG_OUTPUT.print(" : ");
DEBUG_OUTPUT.println(s);
#endif
NefryDataStore.setStorageStr(s, i);
}
webarg[0] = 'i';
for (int i = 0; i < 10; i++) {
webarg[3] = '0' + i;
String s = NefryWebServer.getWebServer()->arg(webarg);
#ifdef DEBUG_ESP_HTTP_SERVER
DEBUG_OUTPUT.print(webarg);
DEBUG_OUTPUT.print(" : ");
DEBUG_OUTPUT.println(s);
#endif
NefryDataStore.setStorageValue(s.toInt(), i);
}
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>")));
NefryWebServer.resetTimer(2);
});
}
/* HTMLに表示するのか */
/* HTMLに表示するのか */
void Nefry_Conf::setStoreTitle(const char set[15], const int num) {
if (0 <= num&&num < 20) {
strcpy(module_input[num], set);
htmlPrint[num] = 1;
htmlPrint[num] = true;
}

}


void Nefry_Conf::begin()
{
for (int i = 0; i < 10; i++) {
sprintf(module_input[i], "String %d", i);
sprintf(module_input[10+i], "Value %d", 10+i);
sprintf(module_input[10 + i], "Value %d", 10 + i);
if (Nefry.getWriteMode()) {
htmlPrint[i] = 1;
htmlPrint[10+i] = 1;
htmlPrint[i] = true;
htmlPrint[10 + i] = true;
}
else {
htmlPrint[i] = 0;
htmlPrint[10 + i] = 0;
}
htmlPrint[i] = false;
htmlPrint[10 + i] = false;
}
}
}
Nefry_Conf NefryConfig;
6 changes: 1 addition & 5 deletions cores/esp32/nefry/NefryConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ class Nefry_Conf
{
public:
void
beginWeb(),
begin(),
setStoreTitle(const char set[15], const int num);

String
beginWeb(String link),
setDefaultModuleId();

private:
bool htmlPrint[20];//10
char module_input[20][15];
Expand Down
Loading