Skip to content

Commit 60a113e

Browse files
authored
Merge pull request #106 from Nefry-Community/1.2Develop
1.2.2
2 parents 22529d7 + c0cd0ec commit 60a113e

File tree

28 files changed

+867
-692
lines changed

28 files changed

+867
-692
lines changed

boards.txt

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,7 @@ menu.DebugLevel=Core Debug Level
66

77
##############################################################
88

9-
nefrybtr3.name=Nefry BT R3
10-
11-
nefrybtr3.upload.tool=esptool
12-
nefrybtr3.upload.maximum_size=1703936
13-
nefrybtr3.upload.maximum_data_size=294912
14-
nefrybtr3.upload.wait_for_upload_port=true
15-
16-
nefrybtr3.serial.disableDTR=true
17-
nefrybtr3.serial.disableRTS=true
18-
19-
nefrybtr3.build.mcu=esp32
20-
nefrybtr3.build.core=esp32
21-
nefrybtr3.build.variant=nefrybt-r3
22-
nefrybtr3.build.board=Nefry_BT_R3
23-
nefrybtr3.build.partitions=default
24-
25-
nefrybtr3.build.f_cpu=240000000L
26-
nefrybtr3.build.flash_mode=dio
27-
nefrybtr3.build.flash_size=4MB
28-
nefrybtr3.build.boot=bootloader
29-
nefrybtr3.build.flash_freq=80m
30-
31-
nefrybtr3.menu.UploadSpeed.921600=921600
32-
nefrybtr3.menu.UploadSpeed.921600.upload.speed=921600
33-
nefrybtr3.menu.UploadSpeed.115200=115200
34-
nefrybtr3.menu.UploadSpeed.115200.upload.speed=115200
35-
nefrybtr3.menu.UploadSpeed.256000.windows=256000
36-
nefrybtr3.menu.UploadSpeed.256000.upload.speed=256000
37-
nefrybtr3.menu.UploadSpeed.230400.windows.upload.speed=256000
38-
nefrybtr3.menu.UploadSpeed.230400=230400
39-
nefrybtr3.menu.UploadSpeed.230400.upload.speed=230400
40-
nefrybtr3.menu.UploadSpeed.460800.linux=460800
41-
nefrybtr3.menu.UploadSpeed.460800.macosx=460800
42-
nefrybtr3.menu.UploadSpeed.460800.upload.speed=460800
43-
nefrybtr3.menu.UploadSpeed.512000.windows=512000
44-
nefrybtr3.menu.UploadSpeed.512000.upload.speed=512000
45-
46-
nefrybtr3.menu.DebugLevel.none=None
47-
nefrybtr3.menu.DebugLevel.none.build.code_debug=0
48-
nefrybtr3.menu.DebugLevel.error=Error
49-
nefrybtr3.menu.DebugLevel.error.build.code_debug=1
50-
nefrybtr3.menu.DebugLevel.warn=Warn
51-
nefrybtr3.menu.DebugLevel.warn.build.code_debug=2
52-
nefrybtr3.menu.DebugLevel.info=Info
53-
nefrybtr3.menu.DebugLevel.info.build.code_debug=3
54-
nefrybtr3.menu.DebugLevel.debug=Debug
55-
nefrybtr3.menu.DebugLevel.debug.build.code_debug=4
56-
nefrybtr3.menu.DebugLevel.verbose=Verbose
57-
nefrybtr3.menu.DebugLevel.verbose.build.code_debug=5
58-
59-
##############################################################
60-
61-
nefrybtr2.name=Nefry BT R2
9+
nefrybtr2.name=Nefry BT R2 / R3
6210

6311
nefrybtr2.upload.tool=esptool
6412
nefrybtr2.upload.maximum_size=1703936
@@ -94,6 +42,8 @@ nefrybtr2.menu.UploadSpeed.460800.macosx=460800
9442
nefrybtr2.menu.UploadSpeed.460800.upload.speed=460800
9543
nefrybtr2.menu.UploadSpeed.512000.windows=512000
9644
nefrybtr2.menu.UploadSpeed.512000.upload.speed=512000
45+
nefrybtr2.menu.UploadSpeed.1500000=1500000
46+
nefrybtr2.menu.UploadSpeed.1500000.upload.speed=1500000
9747

9848
nefrybtr2.menu.DebugLevel.none=None
9949
nefrybtr2.menu.DebugLevel.none.build.code_debug=0

cores/esp32/nefry/Nefry.cpp

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

27-
#define LIBVERSION ("1.2.1")
27+
#define LIBVERSION ("1.2.2")
2828
#include "Nefry.h"
2929

3030
Adafruit_NeoPixel _NefryLEDNeo;
31-
Adafruit_DotStar _NefryLEDStar;
3231
bool connectAnFlg = false;
3332
//main
3433

@@ -37,11 +36,7 @@ void Nefry_lib::nefry_init() {
3736
connectAnFlg = false;
3837
delay(10);
3938
NefryDisplay.begin();//logo表示
40-
if (boardId == 3) {
41-
beginLed((const int)1, (const int)LED_DO, (uint8_t)DOTSTAR_BRG, LED_CLK);
42-
} else {
43-
beginLed((const int)1, (const int)16, (uint8_t)NEO_GRBW);
44-
}
39+
beginLed((const int)1, (const int)16, (uint8_t)NEO_GRBW);
4540
setLedBlink(0, 0, 0, false, 0);
4641
setLed(0x00, 0x0f, 0x00);
4742
enableSW();
@@ -88,6 +83,7 @@ void Nefry_lib::nefry_init() {
8883
if(Nefry.getWifiEnabled()){
8984
printDeviceInfo();
9085
}
86+
MDNS.begin("nefrybt");
9187
setLed(0x00, 0xff, 0xff);
9288
_nefryWifiWait = 0;
9389
}
@@ -298,35 +294,22 @@ bool Nefry_lib::getPollingSW()
298294
}
299295

300296
//LED
301-
void Nefry_lib::beginLed(const int num, const int DataOut, uint8_t t ,const int clk) {
302-
if (boardId == 3) { // Nefry BT r3
303-
_NefryLEDStar = Adafruit_DotStar(num, DataOut, clk, DOTSTAR_BRG);
304-
_NefryLEDStar.begin();
305-
_NefryLEDStar.show();
306-
}
307-
else {
308-
_NefryLEDNeo = Adafruit_NeoPixel(num, DataOut, t);
309-
_NefryLEDNeo.begin();
310-
_NefryLEDNeo.show();
311-
}
297+
void Nefry_lib::beginLed(const int num, const int DataOut, uint8_t t, const int clk) {
298+
_NefryLEDNeo = Adafruit_NeoPixel(num, DataOut, t);
299+
_NefryLEDNeo.begin();
300+
_NefryLEDNeo.show();
312301
}
313302

314303
void Nefry_lib::setLed(const int r, const int g, const int b, const char w, const int pin, const int num) {
315-
if (boardId == 3) { // Nefry BT r3
316-
_NefryLEDStar.setBrightness(w);
317-
_NefryLEDStar.setPixelColor(num, r, g, b);
318-
_NefryLEDStar.show();
319-
}
320-
else {
321-
_NefryLEDNeo.setPixelColor(num, 0, 0, 0);
322-
delay(1);
323-
_NefryLEDNeo.show();
324-
_NefryLEDNeo.setBrightness(w);
325-
_NefryLEDNeo.setPixelColor(num, map(r, 0, 255, 0, 150), g, b);
326-
delay(1);
327-
_NefryLEDNeo.show();
328-
}
304+
_NefryLEDNeo.setPixelColor(num, 0, 0, 0);
305+
delay(1);
306+
_NefryLEDNeo.show();
307+
_NefryLEDNeo.setBrightness(w);
308+
_NefryLEDNeo.setPixelColor(num, map(r, 0, 255, 0, 150), g, b);
309+
delay(1);
310+
_NefryLEDNeo.show();
329311
}
312+
330313
void Nefry_lib::setLed(String _colorStr, const char w, const int pin, const int num) {
331314
int _color[3];
332315
for (int i = 0; i < 3; i++) {
@@ -421,7 +404,7 @@ void Nefry_lib::setIndexLink(const char title[32], const char url[32]){
421404
ESP32WebServer* Nefry_lib::getWebServer(){
422405
return NefryWebServer.getWebServer();
423406
}
424-
String Nefry_lib::getlistWifi(){
407+
String Nefry_lib::getWiFiList(){
425408
return NefryWiFi.getlistWifi();
426409
}
427410

@@ -485,10 +468,7 @@ bool Nefry_lib::setAnalyticsData(String action) {
485468
url += "r1";
486469
break;
487470
case 2:
488-
url += "r2";
489-
break;
490-
case 3:
491-
url += "r3";
471+
url += "r2/r3";
492472
break;
493473
default:
494474
url += "error";

cores/esp32/nefry/Nefry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define Nefry_h
33

44
#include <Esp.h>
5-
#include "./inc/led/Adafruit_DotStar.h"
65
#include "./inc/led/Adafruit_NeoPixel.h"
76
#include "./inc/Preferences/src/Preferences.h"
87
#include "NefryWiFi.h"
@@ -13,6 +12,7 @@
1312
#include "NefryWeb.h"
1413
#include "NefryWebServer.h"
1514
#include "./inc/WiFi/src/WiFiClient.h"
15+
#include "./inc/ESPmDNS/src/ESPmDNS.h"
1616

1717

1818
// Offset: W R G B
@@ -54,7 +54,7 @@ class Nefry_lib
5454
/* Console */
5555
read(),
5656

57-
getlistWifi(),
57+
getWiFiList(),
5858
createHtml(String title, String head, String body);
5959

6060
long
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
ESP8266 mDNS-SD responder and query sample
3+
4+
This is an example of announcing and finding services.
5+
6+
Instructions:
7+
- Update WiFi SSID and password as necessary.
8+
- Flash the sketch to two ESP8266 boards
9+
- The last one powered on should now find the other.
10+
*/
11+
12+
#include <WiFi.h>
13+
#include <ESPmDNS.h>
14+
15+
const char* ssid = "...";
16+
const char* password = "...";
17+
18+
void setup() {
19+
Serial.begin(115200);
20+
WiFi.begin(ssid, password);
21+
while (WiFi.status() != WL_CONNECTED) {
22+
delay(250);
23+
Serial.print(".");
24+
}
25+
Serial.println("");
26+
Serial.print("Connected to ");
27+
Serial.println(ssid);
28+
Serial.print("IP address: ");
29+
Serial.println(WiFi.localIP());
30+
31+
if (!MDNS.begin("ESP32_Browser")) {
32+
Serial.println("Error setting up MDNS responder!");
33+
while(1){
34+
delay(1000);
35+
}
36+
}
37+
}
38+
39+
void loop() {
40+
browseService("http", "tcp");
41+
delay(1000);
42+
browseService("arduino", "tcp");
43+
delay(1000);
44+
browseService("workstation", "tcp");
45+
delay(1000);
46+
browseService("smb", "tcp");
47+
delay(1000);
48+
browseService("afpovertcp", "tcp");
49+
delay(1000);
50+
browseService("ftp", "tcp");
51+
delay(1000);
52+
browseService("ipp", "tcp");
53+
delay(1000);
54+
browseService("printer", "tcp");
55+
delay(10000);
56+
}
57+
58+
void browseService(const char * service, const char * proto){
59+
Serial.printf("Browsing for service _%s._%s.local. ... ", service, proto);
60+
int n = MDNS.queryService(service, proto);
61+
if (n == 0) {
62+
Serial.println("no services found");
63+
} else {
64+
Serial.print(n);
65+
Serial.println(" service(s) found");
66+
for (int i = 0; i < n; ++i) {
67+
// Print details for each service found
68+
Serial.print(" ");
69+
Serial.print(i + 1);
70+
Serial.print(": ");
71+
Serial.print(MDNS.hostname(i));
72+
Serial.print(" (");
73+
Serial.print(MDNS.IP(i));
74+
Serial.print(":");
75+
Serial.print(MDNS.port(i));
76+
Serial.println(")");
77+
}
78+
}
79+
Serial.println();
80+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
ESP32 mDNS responder sample
3+
4+
This is an example of an HTTP server that is accessible
5+
via http://esp32.local URL thanks to mDNS responder.
6+
7+
Instructions:
8+
- Update WiFi SSID and password as necessary.
9+
- Flash the sketch to the ESP32 board
10+
- Install host software:
11+
- For Linux, install Avahi (http://avahi.org/).
12+
- For Windows, install Bonjour (http://www.apple.com/support/bonjour/).
13+
- For Mac OSX and iOS support is built in through Bonjour already.
14+
- Point your browser to http://esp32.local, you should see a response.
15+
16+
*/
17+
18+
19+
#include <WiFi.h>
20+
#include <ESPmDNS.h>
21+
#include <WiFiClient.h>
22+
23+
const char* ssid = "............";
24+
const char* password = "..............";
25+
26+
// TCP server at port 80 will respond to HTTP requests
27+
WiFiServer server(80);
28+
29+
void setup(void)
30+
{
31+
Serial.begin(115200);
32+
33+
// Connect to WiFi network
34+
WiFi.begin(ssid, password);
35+
Serial.println("");
36+
37+
// Wait for connection
38+
while (WiFi.status() != WL_CONNECTED) {
39+
delay(500);
40+
Serial.print(".");
41+
}
42+
Serial.println("");
43+
Serial.print("Connected to ");
44+
Serial.println(ssid);
45+
Serial.print("IP address: ");
46+
Serial.println(WiFi.localIP());
47+
48+
// Set up mDNS responder:
49+
// - first argument is the domain name, in this example
50+
// the fully-qualified domain name is "esp8266.local"
51+
// - second argument is the IP address to advertise
52+
// we send our IP address on the WiFi network
53+
if (!MDNS.begin("esp32")) {
54+
Serial.println("Error setting up MDNS responder!");
55+
while(1) {
56+
delay(1000);
57+
}
58+
}
59+
Serial.println("mDNS responder started");
60+
61+
// Start TCP (HTTP) server
62+
server.begin();
63+
Serial.println("TCP server started");
64+
65+
// Add service to MDNS-SD
66+
MDNS.addService("http", "tcp", 80);
67+
}
68+
69+
void loop(void)
70+
{
71+
// Check if a client has connected
72+
WiFiClient client = server.available();
73+
if (!client) {
74+
return;
75+
}
76+
Serial.println("");
77+
Serial.println("New client");
78+
79+
// Wait for data from client to become available
80+
while(client.connected() && !client.available()){
81+
delay(1);
82+
}
83+
84+
// Read the first line of HTTP request
85+
String req = client.readStringUntil('\r');
86+
87+
// First line of HTTP request looks like "GET /path HTTP/1.1"
88+
// Retrieve the "/path" part by finding the spaces
89+
int addr_start = req.indexOf(' ');
90+
int addr_end = req.indexOf(' ', addr_start + 1);
91+
if (addr_start == -1 || addr_end == -1) {
92+
Serial.print("Invalid request: ");
93+
Serial.println(req);
94+
return;
95+
}
96+
req = req.substring(addr_start + 1, addr_end);
97+
Serial.print("Request: ");
98+
Serial.println(req);
99+
client.flush();
100+
101+
String s;
102+
if (req == "/")
103+
{
104+
IPAddress ip = WiFi.localIP();
105+
String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
106+
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP32 at ";
107+
s += ipStr;
108+
s += "</html>\r\n\r\n";
109+
Serial.println("Sending 200");
110+
}
111+
else
112+
{
113+
s = "HTTP/1.1 404 Not Found\r\n\r\n";
114+
Serial.println("Sending 404");
115+
}
116+
client.print(s);
117+
118+
Serial.println("Done with client");
119+
}
120+

0 commit comments

Comments
 (0)