1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-25 20:02:37 +03:00

Merge branch 'master' into master

This commit is contained in:
volca 2015-11-13 09:27:27 +08:00
commit 3e5c2e585d
3 changed files with 123 additions and 84 deletions

View File

@ -178,7 +178,7 @@ SweetPea ESP-210 | 4M | 1M, 3M
*ESP8266FS* is a tool which integrates into the Arduino IDE. It adds a menu item to *Tools* menu for uploading the contents of sketch data directory into ESP8266 flash file system. *ESP8266FS* is a tool which integrates into the Arduino IDE. It adds a menu item to *Tools* menu for uploading the contents of sketch data directory into ESP8266 flash file system.
- Download the tool: http://arduino.esp8266.com/ESP8266FS-1.6.5-1105-g98d2458.zip - Download the tool: https://github.com/esp8266/arduino-esp8266fs-plugin/releases/download/0.1.3/ESP8266FS-0.1.3.zip.
- In your Arduino sketchbook directory, create `tools` directory if it doesn't exist yet - In your Arduino sketchbook directory, create `tools` directory if it doesn't exist yet
- Unpack the tool into `tools` directory (the path will look like `<home_dir>/Arduino/tools/ESP8266FS/tool/esp8266fs.jar`) - Unpack the tool into `tools` directory (the path will look like `<home_dir>/Arduino/tools/ESP8266FS/tool/esp8266fs.jar`)
- Restart Arduino IDE - Restart Arduino IDE

View File

@ -63,7 +63,7 @@ void ArduinoOTAClass::begin() {
if (!_hostname.length()) { if (!_hostname.length()) {
char tmp[15]; char tmp[15];
sprintf(tmp, "esp8266-%02x", ESP.getChipId()); sprintf(tmp, "esp8266-%06x", ESP.getChipId());
_hostname = tmp; _hostname = tmp;
} }
if (!_port) { if (!_port) {
@ -199,7 +199,7 @@ void ArduinoOTAClass::handle() {
#endif #endif
_udp_ota.beginPacket(_ota_ip, _udp_ota.remotePort()); _udp_ota.beginPacket(_ota_ip, _udp_ota.remotePort());
if (_password){ if (_password.length()){
MD5Builder nonce_md5; MD5Builder nonce_md5;
nonce_md5.begin(); nonce_md5.begin();
nonce_md5.add(String(micros())); nonce_md5.add(String(micros()));

View File

@ -30,17 +30,44 @@ import os
import optparse import optparse
import logging import logging
import hashlib import hashlib
import random
# Commands # Commands
FLASH = 0 FLASH = 0
SPIFFS = 100 SPIFFS = 100
AUTH = 200 AUTH = 200
PROGRESS = False
# update_progress() : Displays or updates a console progress bar
## Accepts a float between 0 and 1. Any int will be converted to a float.
## A value under 0 represents a 'halt'.
## A value at 1 or bigger represents 100%
def update_progress(progress):
if (PROGRESS):
barLength = 60 # Modify this to change the length of the progress bar
status = ""
if isinstance(progress, int):
progress = float(progress)
if not isinstance(progress, float):
progress = 0
status = "error: progress var must be float\r\n"
if progress < 0:
progress = 0
status = "Halt...\r\n"
if progress >= 1:
progress = 1
status = "Done...\r\n"
block = int(round(barLength*progress))
text = "\rUploading: [{0}] {1}% {2}".format( "="*block + " "*(barLength-block), int(progress*100), status)
sys.stderr.write(text)
sys.stderr.flush()
else:
sys.stderr.write('.')
sys.stderr.flush()
def serve(remoteAddr, remotePort, password, filename, command = FLASH): def serve(remoteAddr, remotePort, password, filename, command = FLASH):
# Create a TCP/IP socket # Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverPort = 48266 serverPort = random.randint(10000,60000)
server_address = ('0.0.0.0', serverPort) server_address = ('0.0.0.0', serverPort)
logging.info('Starting on %s:%s', str(server_address[0]), str(server_address[1])) logging.info('Starting on %s:%s', str(server_address[0]), str(server_address[1]))
try: try:
@ -115,13 +142,17 @@ def serve(remoteAddr, remotePort, password, filename, command = FLASH):
try: try:
f = open(filename, "rb") f = open(filename, "rb")
if (PROGRESS):
update_progress(0)
else:
sys.stderr.write('Uploading') sys.stderr.write('Uploading')
sys.stderr.flush() sys.stderr.flush()
offset = 0
while True: while True:
chunk = f.read(1460) chunk = f.read(1460)
if not chunk: break if not chunk: break
sys.stderr.write('.') offset += len(chunk)
sys.stderr.flush() update_progress(offset/float(content_size))
connection.settimeout(10) connection.settimeout(10)
try: try:
connection.sendall(chunk) connection.sendall(chunk)
@ -220,6 +251,12 @@ def parser():
action = "store_true", action = "store_true",
default = False default = False
) )
group.add_option("-r", "--progress",
dest = "progress",
help = "Show progress output. Does not work for ArduinoIDE",
action = "store_true",
default = False
)
parser.add_option_group(group) parser.add_option_group(group)
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
@ -244,6 +281,8 @@ def main(args):
logging.debug("Options: %s", str(options)) logging.debug("Options: %s", str(options))
# check options # check options
global PROGRESS
PROGRESS = options.progress
if (not options.esp_ip or not options.image): if (not options.esp_ip or not options.image):
logging.critical("Not enough arguments.") logging.critical("Not enough arguments.")