Skip to content

1.2.2 #106

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 13 commits into from
Apr 21, 2018
Merged

1.2.2 #106

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
56 changes: 3 additions & 53 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,7 @@ menu.DebugLevel=Core Debug Level

##############################################################

nefrybtr3.name=Nefry BT R3

nefrybtr3.upload.tool=esptool
nefrybtr3.upload.maximum_size=1703936
nefrybtr3.upload.maximum_data_size=294912
nefrybtr3.upload.wait_for_upload_port=true

nefrybtr3.serial.disableDTR=true
nefrybtr3.serial.disableRTS=true

nefrybtr3.build.mcu=esp32
nefrybtr3.build.core=esp32
nefrybtr3.build.variant=nefrybt-r3
nefrybtr3.build.board=Nefry_BT_R3
nefrybtr3.build.partitions=default

nefrybtr3.build.f_cpu=240000000L
nefrybtr3.build.flash_mode=dio
nefrybtr3.build.flash_size=4MB
nefrybtr3.build.boot=bootloader
nefrybtr3.build.flash_freq=80m

nefrybtr3.menu.UploadSpeed.921600=921600
nefrybtr3.menu.UploadSpeed.921600.upload.speed=921600
nefrybtr3.menu.UploadSpeed.115200=115200
nefrybtr3.menu.UploadSpeed.115200.upload.speed=115200
nefrybtr3.menu.UploadSpeed.256000.windows=256000
nefrybtr3.menu.UploadSpeed.256000.upload.speed=256000
nefrybtr3.menu.UploadSpeed.230400.windows.upload.speed=256000
nefrybtr3.menu.UploadSpeed.230400=230400
nefrybtr3.menu.UploadSpeed.230400.upload.speed=230400
nefrybtr3.menu.UploadSpeed.460800.linux=460800
nefrybtr3.menu.UploadSpeed.460800.macosx=460800
nefrybtr3.menu.UploadSpeed.460800.upload.speed=460800
nefrybtr3.menu.UploadSpeed.512000.windows=512000
nefrybtr3.menu.UploadSpeed.512000.upload.speed=512000

nefrybtr3.menu.DebugLevel.none=None
nefrybtr3.menu.DebugLevel.none.build.code_debug=0
nefrybtr3.menu.DebugLevel.error=Error
nefrybtr3.menu.DebugLevel.error.build.code_debug=1
nefrybtr3.menu.DebugLevel.warn=Warn
nefrybtr3.menu.DebugLevel.warn.build.code_debug=2
nefrybtr3.menu.DebugLevel.info=Info
nefrybtr3.menu.DebugLevel.info.build.code_debug=3
nefrybtr3.menu.DebugLevel.debug=Debug
nefrybtr3.menu.DebugLevel.debug.build.code_debug=4
nefrybtr3.menu.DebugLevel.verbose=Verbose
nefrybtr3.menu.DebugLevel.verbose.build.code_debug=5

##############################################################

nefrybtr2.name=Nefry BT R2
nefrybtr2.name=Nefry BT R2 / R3

nefrybtr2.upload.tool=esptool
nefrybtr2.upload.maximum_size=1703936
Expand Down Expand Up @@ -94,6 +42,8 @@ nefrybtr2.menu.UploadSpeed.460800.macosx=460800
nefrybtr2.menu.UploadSpeed.460800.upload.speed=460800
nefrybtr2.menu.UploadSpeed.512000.windows=512000
nefrybtr2.menu.UploadSpeed.512000.upload.speed=512000
nefrybtr2.menu.UploadSpeed.1500000=1500000
nefrybtr2.menu.UploadSpeed.1500000.upload.speed=1500000

nefrybtr2.menu.DebugLevel.none=None
nefrybtr2.menu.DebugLevel.none.build.code_debug=0
Expand Down
54 changes: 17 additions & 37 deletions cores/esp32/nefry/Nefry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ BootMode
1 : WriteMode切替をする
*/

#define LIBVERSION ("1.2.1")
#define LIBVERSION ("1.2.2")
#include "Nefry.h"

Adafruit_NeoPixel _NefryLEDNeo;
Adafruit_DotStar _NefryLEDStar;
bool connectAnFlg = false;
//main

Expand All @@ -37,11 +36,7 @@ void Nefry_lib::nefry_init() {
connectAnFlg = false;
delay(10);
NefryDisplay.begin();//logo表示
if (boardId == 3) {
beginLed((const int)1, (const int)LED_DO, (uint8_t)DOTSTAR_BRG, LED_CLK);
} else {
beginLed((const int)1, (const int)16, (uint8_t)NEO_GRBW);
}
beginLed((const int)1, (const int)16, (uint8_t)NEO_GRBW);
setLedBlink(0, 0, 0, false, 0);
setLed(0x00, 0x0f, 0x00);
enableSW();
Expand Down Expand Up @@ -88,6 +83,7 @@ void Nefry_lib::nefry_init() {
if(Nefry.getWifiEnabled()){
printDeviceInfo();
}
MDNS.begin("nefrybt");
setLed(0x00, 0xff, 0xff);
_nefryWifiWait = 0;
}
Expand Down Expand Up @@ -298,35 +294,22 @@ bool Nefry_lib::getPollingSW()
}

//LED
void Nefry_lib::beginLed(const int num, const int DataOut, uint8_t t ,const int clk) {
if (boardId == 3) { // Nefry BT r3
_NefryLEDStar = Adafruit_DotStar(num, DataOut, clk, DOTSTAR_BRG);
_NefryLEDStar.begin();
_NefryLEDStar.show();
}
else {
_NefryLEDNeo = Adafruit_NeoPixel(num, DataOut, t);
_NefryLEDNeo.begin();
_NefryLEDNeo.show();
}
void Nefry_lib::beginLed(const int num, const int DataOut, uint8_t t, const int clk) {
_NefryLEDNeo = Adafruit_NeoPixel(num, DataOut, t);
_NefryLEDNeo.begin();
_NefryLEDNeo.show();
}

void Nefry_lib::setLed(const int r, const int g, const int b, const char w, const int pin, const int num) {
if (boardId == 3) { // Nefry BT r3
_NefryLEDStar.setBrightness(w);
_NefryLEDStar.setPixelColor(num, r, g, b);
_NefryLEDStar.show();
}
else {
_NefryLEDNeo.setPixelColor(num, 0, 0, 0);
delay(1);
_NefryLEDNeo.show();
_NefryLEDNeo.setBrightness(w);
_NefryLEDNeo.setPixelColor(num, map(r, 0, 255, 0, 150), g, b);
delay(1);
_NefryLEDNeo.show();
}
_NefryLEDNeo.setPixelColor(num, 0, 0, 0);
delay(1);
_NefryLEDNeo.show();
_NefryLEDNeo.setBrightness(w);
_NefryLEDNeo.setPixelColor(num, map(r, 0, 255, 0, 150), g, b);
delay(1);
_NefryLEDNeo.show();
}

void Nefry_lib::setLed(String _colorStr, const char w, const int pin, const int num) {
int _color[3];
for (int i = 0; i < 3; i++) {
Expand Down Expand Up @@ -421,7 +404,7 @@ void Nefry_lib::setIndexLink(const char title[32], const char url[32]){
ESP32WebServer* Nefry_lib::getWebServer(){
return NefryWebServer.getWebServer();
}
String Nefry_lib::getlistWifi(){
String Nefry_lib::getWiFiList(){
return NefryWiFi.getlistWifi();
}

Expand Down Expand Up @@ -485,10 +468,7 @@ bool Nefry_lib::setAnalyticsData(String action) {
url += "r1";
break;
case 2:
url += "r2";
break;
case 3:
url += "r3";
url += "r2/r3";
break;
default:
url += "error";
Expand Down
4 changes: 2 additions & 2 deletions cores/esp32/nefry/Nefry.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define Nefry_h

#include <Esp.h>
#include "./inc/led/Adafruit_DotStar.h"
#include "./inc/led/Adafruit_NeoPixel.h"
#include "./inc/Preferences/src/Preferences.h"
#include "NefryWiFi.h"
Expand All @@ -13,6 +12,7 @@
#include "NefryWeb.h"
#include "NefryWebServer.h"
#include "./inc/WiFi/src/WiFiClient.h"
#include "./inc/ESPmDNS/src/ESPmDNS.h"


// Offset: W R G B
Expand Down Expand Up @@ -54,7 +54,7 @@ class Nefry_lib
/* Console */
read(),

getlistWifi(),
getWiFiList(),
createHtml(String title, String head, String body);

long
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
ESP8266 mDNS-SD responder and query sample

This is an example of announcing and finding services.

Instructions:
- Update WiFi SSID and password as necessary.
- Flash the sketch to two ESP8266 boards
- The last one powered on should now find the other.
*/

#include <WiFi.h>
#include <ESPmDNS.h>

const char* ssid = "...";
const char* password = "...";

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(250);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

if (!MDNS.begin("ESP32_Browser")) {
Serial.println("Error setting up MDNS responder!");
while(1){
delay(1000);
}
}
}

void loop() {
browseService("http", "tcp");
delay(1000);
browseService("arduino", "tcp");
delay(1000);
browseService("workstation", "tcp");
delay(1000);
browseService("smb", "tcp");
delay(1000);
browseService("afpovertcp", "tcp");
delay(1000);
browseService("ftp", "tcp");
delay(1000);
browseService("ipp", "tcp");
delay(1000);
browseService("printer", "tcp");
delay(10000);
}

void browseService(const char * service, const char * proto){
Serial.printf("Browsing for service _%s._%s.local. ... ", service, proto);
int n = MDNS.queryService(service, proto);
if (n == 0) {
Serial.println("no services found");
} else {
Serial.print(n);
Serial.println(" service(s) found");
for (int i = 0; i < n; ++i) {
// Print details for each service found
Serial.print(" ");
Serial.print(i + 1);
Serial.print(": ");
Serial.print(MDNS.hostname(i));
Serial.print(" (");
Serial.print(MDNS.IP(i));
Serial.print(":");
Serial.print(MDNS.port(i));
Serial.println(")");
}
}
Serial.println();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
ESP32 mDNS responder sample

This is an example of an HTTP server that is accessible
via http://esp32.local URL thanks to mDNS responder.

Instructions:
- Update WiFi SSID and password as necessary.
- Flash the sketch to the ESP32 board
- Install host software:
- For Linux, install Avahi (http://avahi.org/).
- For Windows, install Bonjour (http://www.apple.com/support/bonjour/).
- For Mac OSX and iOS support is built in through Bonjour already.
- Point your browser to http://esp32.local, you should see a response.

*/


#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiClient.h>

const char* ssid = "............";
const char* password = "..............";

// TCP server at port 80 will respond to HTTP requests
WiFiServer server(80);

void setup(void)
{
Serial.begin(115200);

// Connect to WiFi network
WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

// Set up mDNS responder:
// - first argument is the domain name, in this example
// the fully-qualified domain name is "esp8266.local"
// - second argument is the IP address to advertise
// we send our IP address on the WiFi network
if (!MDNS.begin("esp32")) {
Serial.println("Error setting up MDNS responder!");
while(1) {
delay(1000);
}
}
Serial.println("mDNS responder started");

// Start TCP (HTTP) server
server.begin();
Serial.println("TCP server started");

// Add service to MDNS-SD
MDNS.addService("http", "tcp", 80);
}

void loop(void)
{
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
Serial.println("");
Serial.println("New client");

// Wait for data from client to become available
while(client.connected() && !client.available()){
delay(1);
}

// Read the first line of HTTP request
String req = client.readStringUntil('\r');

// First line of HTTP request looks like "GET /path HTTP/1.1"
// Retrieve the "/path" part by finding the spaces
int addr_start = req.indexOf(' ');
int addr_end = req.indexOf(' ', addr_start + 1);
if (addr_start == -1 || addr_end == -1) {
Serial.print("Invalid request: ");
Serial.println(req);
return;
}
req = req.substring(addr_start + 1, addr_end);
Serial.print("Request: ");
Serial.println(req);
client.flush();

String s;
if (req == "/")
{
IPAddress ip = WiFi.localIP();
String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP32 at ";
s += ipStr;
s += "</html>\r\n\r\n";
Serial.println("Sending 200");
}
else
{
s = "HTTP/1.1 404 Not Found\r\n\r\n";
Serial.println("Sending 404");
}
client.print(s);

Serial.println("Done with client");
}

Loading