arendst / Sonoff-MQTT-OTA

Provide ESP8266 based itead Sonoff with MQTT and OTA firmware - Now EOL
202 stars 47 forks source link

New topic not saved #3

Closed PaulvS closed 8 years ago

PaulvS commented 8 years ago

Hi Theo,

I flashed a Sonoff switch with firmware 0.5.4 and I want to change the topic. In the Makefile I already changed the project to sonoff4, but now I want to change it to sonoff10 As stated in the readme I issue the command cmnd\sonoff4\topic sonoff10

A lot of information is passed to the serial output, but the end result is that the sonoff is still listening to the old topic and the new topic is not saved. The same counts for the otaurl. This is also lost after a restart. It seems that the configuration is not saved.

Serial output:

Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
TCP: data received 30 bytes
*** Topic: cmnd/sonoff4/topic, (subtopic: /topic, size: 6), data: sonoff10 (size: 8) 
*** Type: TOPIC, data: sonoff10 
MQTT: queuing publish, length: 30, queue size(0/2048)
TOPIC = sonoff10
MQTT: Sending, type: 3, id: 0000
TCP: Sent
Save configuration to flash ...
Wifi: WIFI_STATUS
state: 5 -> 0 (0)
rm 0
pm close 7 0 0/33281198
del if0
usl
TCP: Reconnect to 192.168.1.217:1883

 ets Jan  8 2013,rst cause:1, boot mode:(3,7)

load 0x40100000, len 1396, room 16 
tail 4
chksum 0x89
load 0x3ffe8000, len 776, room 4 
tail 4
chksum 0xe8
load 0x3ffe8308, len 540, room 4 
tail 8
chksum 0xc0
csum 0xc0

2nd boot version : 1.4(b1)
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size & Map: 4Mbit(256KB+256KB)
jump to run user1 @ 1000

rlŽ‚rlŒÞê+‘�configuration from flash ...
Use default configuration
Save configuration to flash ...

Project sonoff4 (Topic sonoff4) with version 0.5.4
MQTT_InitConnection
MQTT_InitClient
Wifi: WIFI_INIT
System started ...
mode : sta(5c:cf:7f:0c:b3:8c)
add if0
f r-1, Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: STATION_IDLE
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 5
cnt 

connected with MyIoT, channel 11
dhcp client start...
Wifi: WIFI_STATUS
Wifi: STATION_IDLE
ip:192.168.1.171,mask:255.255.255.0,gw:192.168.1.1
Wifi: WIFI_STATUS
TCP: Connect to ip  192.168.1.217:1883
MQTT: Connected to broker 192.168.1.217:1883
MQTT: Sending, type: 1, id: 0000
TCP: Sent
TCP: data received 4 bytes
MQTT: Connected to 192.168.1.217:1883
MQTT: Connected
MQTT: queue subscribe, topic"cmnd/sonoff4/#", id: 1
MQTT: queuing publish, length: 34, queue size(23/2048)
NAME = Sonoff switch
MQTT: queuing publish, length: 29, queue size(59/2048)
VERSION = 0.5.4
MQTT: Sending, type: 8, id: 0001
TCP: Sent
TCP: data received 5 bytes
MQTT: Subscribe successful
MQTT: Sending, type: 3, id: 0000
TCP: Sent
MQTT: Sending, type: 3, id: 0000
TCP: Sent
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Sun Feb 21 19:16:53 2016

Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
sntp: 1456082217, Sun Feb 21 19:16:57 2016

Wifi: WIFI_STATUS
pm open phy_2,type:2 0 0
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
Wifi: WIFI_STATUS
arendst commented 8 years ago

The configuration is saved but during reboot GPIO5 signals a low meaning to default the config. As GPIO5 is floating on sonoff this may happen although I could not reproduce it. I removed the code using GPIO5 as the pin on sonoff is not accessible anyway. Please test and let me know if that fixed your problem.

PaulvS commented 8 years ago

First it still wasn't working for me, but I have to admit that I used esptool.exe on my computer instead of esptool.py. This seems to make a difference, cause as soon as I used esptool.py the saving of the topic and other parameters was working straight away. So, yes, it fixed my problem.

Now I have to mast the OTA updates. I use an AWS ubuntu instance to compile the software and now I want to setup the OTA server also on that machine.