kueblc / mocktuyacloud

Framework to emulate Tuya cloud services
119 stars 23 forks source link

Review of Install Warnings and Errors #1

Open GeorgeIoak opened 5 years ago

GeorgeIoak commented 5 years ago

I just did a new install on the RPi and saw some errors and warnings. Before I moved on I wanted to ask you to take a look and see if I need to do something before I continue.

What I've done so far

mssmison commented 5 years ago

I had that same error tonight myself after updating npm

kueblc commented 5 years ago

Thanks for the report, I'll look into it ASAP

GeorgeIoak commented 5 years ago

FYI, I also had to install hostapd and as a test I ran the OTA script without a device just to see what would happen:

pi@raspberrypi:~/mocktuyacloud $ sudo ./ota-firmware.sh
Creating network at tuya_mdev_test
WARN: brmfmac driver doesn't work properly with virtual interfaces and
      it can cause kernel panic. For this reason we disallow virtual
      interfaces for your adapter.
      For more info: https://github.com/oblique/create_ap/issues/203
WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt
ERROR: hostapd not found.
[INFO] [1/13/2019, 8:02:03 PM] MockTuyaCloud: prompting unlinked devices to connect to the network
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRNOTAVAIL: address not available 192.168.12.1:80
    at Server.setupListenHandle [as _listen2] (net.js:1273:19)
    at listenInCluster (net.js:1338:12)
    at doListen (net.js:1471:7)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Emitted 'error' event at:
    at emitErrorNT (net.js:1317:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
create_ap: no process found
pi@raspberrypi:~/mocktuyacloud $ sudo apt-get install hostapd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libnl-route-3-200
The following NEW packages will be installed:
  hostapd libnl-route-3-200
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 576 kB of archives.
After this operation, 1,565 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://mirrors.syringanetworks.net/raspbian/raspbian stretch/main armhf libnl-route-3-200 armhf 3.2.27-2 [113 kB]
Get:2 http://mirror.us.leaseweb.net/raspbian/raspbian stretch/main armhf hostapd armhf 2:2.4-1+deb9u2 [463 kB]
Fetched 576 kB in 1s (291 kB/s)
Selecting previously unselected package libnl-route-3-200:armhf.
(Reading database ... 134604 files and directories currently installed.)
Preparing to unpack .../libnl-route-3-200_3.2.27-2_armhf.deb ...
Unpacking libnl-route-3-200:armhf (3.2.27-2) ...
Selecting previously unselected package hostapd.
Preparing to unpack .../hostapd_2%3a2.4-1+deb9u2_armhf.deb ...
Unpacking hostapd (2:2.4-1+deb9u2) ...
Setting up libnl-route-3-200:armhf (3.2.27-2) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...
Processing triggers for systemd (232-25+deb9u6) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up hostapd (2:2.4-1+deb9u2) ...
Processing triggers for systemd (232-25+deb9u6) ...
pi@raspberrypi:~/mocktuyacloud $ sudo ./ota-firmware.sh
Creating network at tuya_mdev_test
WARN: brmfmac driver doesn't work properly with virtual interfaces and
      it can cause kernel panic. For this reason we disallow virtual
      interfaces for your adapter.
      For more info: https://github.com/oblique/create_ap/issues/203
WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt
Config dir: /tmp/create_ap.wlan0.conf.qAlHVlFk
PID: 4345
Network Manager found, set wlan0 as unmanaged device... DONE
No Internet sharing
hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlan0.conf.qAlHVlFk/hostapd_ctrl
Configuration file: /tmp/create_ap.wlan0.conf.qAlHVlFk/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:b7:26:2c and ssid "tuya_mdev_test"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
[INFO] [1/13/2019, 8:03:30 PM] MockTuyaCloud: prompting unlinked devices to connect to the network
[INFO] [1/13/2019, 8:03:30 PM] MockTuyaApi: server started on 192.168.12.1 port 80
^Cwlan0: interface state ENABLED->DISABLED
wlan0: AP-DISABLED

pi@raspberrypi:~/mocktuyacloud $ nl80211: deinit ifname=wlan0 disabled_11b_rates=0

Doing cleanup.. done
kueblc commented 5 years ago

@GeorgeIoak it looks like despite the warnings and after you installed hostapd your mock cloud started successfully according to [INFO] [1/13/2019, 8:03:30 PM] MockTuyaApi: server started on 192.168.12.1 port 80

At this point if you had any devices in config mode (hold 5s and LED is blinking) they should hopefully try to connect to the mock cloud and get keys. If your wifi card is capable of station mode and AP mode simultaneously, it should also detect and call out devices on your network to encourage them to switch.

Any device that successfully connects to the mock cloud will hopefully request the first stage firmware.

I'm now attempting installation on a fresh rpi0w and having more trouble than you it looks like, ha! Turns out even create_ap isn't magic, my rpi doesn't seem to support station and access point modes at the same time. Do you mind sharing what version rasberrypi you are using?

GeorgeIoak commented 5 years ago

@kueblc I wouldn't wish my bad luck on anyone! FYI, Terry gave me the idea to remove WiFi security and check my 1st plug and when I did it showed up and I was able to connect to it. So I only have 1 problem child to work with now. I do still have an unused BlitzWolf Smart Plug that I'm saving for testing.

To answer your quesion here's what I have:

pi@raspberrypi:~/share $ cat /proc/device-tree/model
Raspberry Pi 3 Model B Rev 1.2

pi@raspberrypi:~/share $ cat /proc/cpuinfo
...
Hardware        : BCM2835
Revision        : a22082

pi@raspberrypi:~/share $ uname -a
Linux raspberrypi 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux

pi@raspberrypi:~/share $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian

Let me know if you need/want to see anything else.

kueblc commented 5 years ago

Still having issues trying to get my rpi0 to cooperate with create_ap. I can get it into host AP mode, but it does not seem like it can do station + host simultaneously. This means that we are limited to flashing via pairing mode on devices like this. I have an idea for a workaround but it may be a few days.

If you'd like to give it another shot, feel free to pull the latest and trying flashing via pairing mode. Latest changes include automatic MQTT upgrade command 5 seconds after connecting, which got my stubborn devices to upgrade.

hungpr0 commented 5 years ago

I also have the same problem with npm https://pastebin.com/uTwLwart

kueblc commented 5 years ago

See if you can run the OTA script anyway. Haven't yet found what's causing that but otherwise the required packages seem to work fine for me.