logo elektroda
logo elektroda
X
logo elektroda

[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

p.kaczmarek2 180192 1264
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #361 19942081
    absinth84
    Level 5  
    Hi did some improvement to the Thermostat, now the mcu clock is synched with ntptime when is asked by mcu message. IT use harcoded timezone (+1) but I start to implement the possibility to customize it from web console. I have some trouble here, how to use memory to store the data. I have had no more time to deep into it..

    Here the changes

    https://github.com/absinth84/OpenBK7231T_App/commit/9543503e8f87ee552c01973d57f51c8fb6abed29

    I started also to decode temperature messages from MCU and print them into logs...


    I have also again problems with the bootloader.. I don't know why but I found it canceled by some standard serial update and it was necessary re-flash via SPI
  • ADVERTISEMENT
  • #362 19942745
    eakeyson
    Level 6  
    p.kaczmarek2 wrote:
    eakeyson wrote:

    Yes, when I did get it to boot the first time I did try to configure some pins. It acts like it still sets that configuration which prevents it from booting.

    There is a simple check that prevents config from disabling UART pins, that is commented out right now.
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/new_pins.c
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    if you uncomment those lines, config and web page won't be able to change roles of pin P0, P1, P10 and P11:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Of course, everything here is under assumption that you're getting silence because you've set UART pin role to something else...
    but try, uncomment shown lines, recompile, flash and give us full log.


    In the past, there was also a real boot crash/hang issue but I think it's fixed since several days (I hope)


    Well, that did the trick, now boots and joins WIFI and mqtt as previous configuration still present. When I got it to boot originally, I was configuring pins in the configurator and apparently configured Pin 0 as PWM, as now it won't let me change or erase that to get to clean config. When I save config, comes right back to what was there. I think that I would like to erase entire config and start over per @btsimonh or is there a better way?

    Bootlog and pic of configurator included.
    device lo.. 2.txt Download (8.98 kB)
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #363 19943002
    p.kaczmarek2
    Moderator Smart Home
    absinth84 wrote:
    . I have some trouble here, how to use memory to store the data. I have had no more time to deep into it..

    I am most likely not going to add much more fields in the web api and in the simple flash config structure.

    My current plan is to allow people to create a text config that will setup more advanced variables by text commands, so something like:
    
    timeZoneOfs 2
    

    that resides in the flash memory.

    It will be also used to map TuyaMCU channels to device channels (fnId, dpId, etc) and to setup multiple I2C devices on single bus.
    Example I2C config that I plan to support (not implemented)
    
    addI2CDevice I2C1 0xA0 TC74 1
    addI2CDevice I2C1 0xA2 TC74 2
    addI2CDevice I2C2 0xA4 SM2135 3 4 5 6 7
    addTuyaMCUDPFunctionReadOnly 0 8
    addTuyaMCUDPFunctionReadOnly 1 9
    setChannelKind 1 Centigrade
    setChannelKind 2 Centigrade
    setChannelKind 3 Red
    setChannelKind 4 Green
    setChannelKind 5 Blue
    setChannelKind 6 Cool
    setChannelKind 7 Warm
    setChannelKind 8 Humidity
    setChannelKind 9 Centigrade
    

    Explanation: first and second lines are adding TC74 temperature sensors to I2C1 bus with certain addresses and maps their outputs to channels 1 and 2. Third line adds RGBCW led controller and maps channels 3 4 5 6 7 to its inputs. TTuyaMCU lines map TuyaMCU dpIDs to channels 8 and 9. Last lines set channel flavor hints for UI generation.
    This is just a plan, it's subject to change.
    I just want to note that we won't be hardcoding per-device settings in C code.

    Still, your time stuff is not bad, I might manually port some of it to main repo.

    I was less active for last days because I started working on BL602:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I am researching the possibility to flash this device and ultimately port my app to that platform as well.

    eakeyson wrote:

    Well, that did the trick, now boots and joins WIFI and mqtt as previous configuration still present.

    Very, very strange. We both (I and @btsimonh ) assumed that device would join the WiFi anyway, even with UART pins disabled. And you're saying that only joins WiFi now....

    eakeyson wrote:

    When I got it to boot originally, I was configuring pins in the configurator and apparently configured Pin 0 as PWM, as now it won't let me change or erase that to get to clean config.

    this is because the old security check in code didn't allow changing role at all, instead of defaulting it to None.
    See new version:
    https://github.com/openshwprojects/OpenBK7231...mmit/5c0edfabdc2f27550f965ca6c7d6cafadd0f4cbc
    Please remember to change #if 0 to #if 1 in order to enable this fix.
    This fix will automatically clear roles of UART pins.
    [/code]
    Helpful post? Buy me a coffee.
  • #364 19943918
    sebastian48
    Level 9  
    I finally had time to finish two WFIPO120FWT "Nedis Wifi Smart Plug" and configure Home Assistant with a bridge to HomeKit. Everything works great (except the physical button on one of them, managed to unsolder the whole pad). One thing that worries me a bit is the wifi password being plain text in the configuration. How do you usually deal with this? In my case the device is an outdoor smart plug, hence within grab for anyone. At the moment I have them on connected to my house wifi. Are you using separate networks for smart home stuff or are we able to obfuscate the password in the device configuration to make it at least a little bit more safe?
  • #365 19944188
    p.kaczmarek2
    Moderator Smart Home
    sebastian48 wrote:
    I finally had time to finish two WFIPO120FWT "Nedis Wifi Smart Plug" and configure Home Assistant with a bridge to HomeKit. Everything works great (except the physical button on one of them, managed to unsolder the whole pad).

    Great news! Please post photos of your setup or screenshots. I am happy to see people using my firmware.

    sebastian48 wrote:
    One thing that worries me a bit is the wifi password being plain text in the configuration. How do you usually deal with this?

    This is a very good question. The chinese industry standard is to store password in plain text and futhermore to printout it to debug log every now and then.
    Seriously, now.
    I've been testing a BL602 led strip today, and take a look:
    
    Calculate ENV CRC32 umber is 0x19FA3EF7.
    Erased ENV OK.
    Saved ENV OK.
    Recevied indication to connect to AP MY_WIFI_NAME_SSID MY_WIFI_PASSWORD_IN_PLAINTEXT
    [APP] [EVT] [PROV] [CONNECT] 446073
    
     SKIP Notify for set Empty Address
    Connect to : MY_WIFI_NAME_SSID MY_WIFI_PASSWORD_IN_PLAINTEXT
    [WF] MM_ADD_IF_REQ Sending: STA
    [WF] MM_ADD_IF_REQ Done
    [WF] vif_index from LAMC is 1
    [WF][SM] Entering idle state
    [WF][SM] Action Connect
               ssid MY_WIFI_NAME_SSID
               ssid len 13
               psk MY_WIFI_PASSWORD_IN_PLAINTEXT
               psk len 24
               pmk 
               pmk len 0
               channel band 0
               channel freq 0
               mac 00:00:00:00:00:00
               dhcp status: true
    [WF][SM] State Action ###idle### --->>> ###connecting###
    connecting using vif_idx 1
    ===start sm_get_bss_params===
    bssid[0] = 0xffff
    bssid[1] = 0xffff
    bssid[2] = 0xffff
    search ssid = MY_WIFI_NAME_SSID
    result ssid index = -1
    ===end sm_get_bss_params===
    [WF][SM] Entering connecting state
    [APP] [EVT] Unknown code 12, 446263                     ..
    

    The same happens on ESP8266 devices (I also found my SSID and pass in ESP8266 flash dump read by esptool many times), and most likely also on several other Tuya platforms.

    But of course we should be better than that and I fully agree with your concerns. I will think about adding some more security layer to my firmware, but with open source, I can't see any really reliable methods to secure it. I could do a simply encryption on it, maybe even a simple xor on each character, it still would be better than what Tuya does. Maybe it would be better to also make sure that your WiFi is secure, add MAC filtering, maybe separate network for smart devices, etc. Depends on your use case.
    Still, the first thing I'd suggest is to disable debug printout of target SSID and pass that is infact now even in our firmware, as it is useful for debugging boot issues, which seems to be common among our users (see few posts above...).

    On a brighter side, I have some great news!
    I have managed to compile and flash example SDK projects on BL602 platform on Magic Home LED strip. It means that Magic Home devices are not secured it any way. It means that it's possible to port my app to BL602 and support all BL602 devices in the future.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    BL602 flashing procedure is relatively simple. There were several problems to overcome with SDK (the newest version seem to have broken compilation), but they are resolved now. Maybe I will do some kind of BL602 tutorial soon.
    ferbulous wrote:

    And there’s also this gu10 ewelink bulbs that use BL602. I did order some ESP-01D modules to replace this
    Spoiler:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    @ferbulous , are you still here? Do you still have desoldered BL602's?

    It flashes correctly now!
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    BL602, here we come!

    It's really possible that soon our app will support 4 platforms: BK7231T, BK7231N, XR809 and BL602 (five if you count http server working on Windows for development purposes).

    PS: but please note, I am not sure now how much exactly of porting work will require running my App on BL602, it depends on some things like sockets API availability etc

    PS2: for more BL602 LED strip information, see this topic (I just posted it in teardowns section, translation pending) https://www.elektroda.pl/rtvforum/topic3881416.html#19944184
    Helpful post? Buy me a coffee.
  • #366 19945760
    eakeyson
    Level 6  
    eakeyson wrote:

    Well, that did the trick, now boots and joins WIFI and mqtt as previous configuration still present.

    Very, very strange. We both (I and @btsimonh ) assumed that device would join the WiFi anyway, even with UART pins disabled. And you're saying that only joins WiFi now....


    Device did not join WIFI anyway, only now when I commented out what you suggested above.

    eakeyson wrote:

    When I got it to boot originally, I was configuring pins in the configurator and apparently configured Pin 0 as PWM, as now it won't let me change or erase that to get to clean config.
    this is because the old security check in code didn't allow changing role at all, instead of defaulting it to None.

    See new version:
    https://github.com/openshwprojects/OpenBK7231...mmit/5c0edfabdc2f27550f965ca6c7d6cafadd0f4cbc
    Please remember to change #if 0 to #if 1 in order to enable this fix.
    This fix will automatically clear roles of UART pins.
    [/code]


    This commit does not work for me with either "#if 0" or "#if 1". Output log stops after pins configured as before.
  • #367 19945777
    p.kaczmarek2
    Moderator Smart Home
    eakeyson wrote:

    This commit does not work for me with either "#if 0" or "#if 1". Output log stops after pins configured as before.

    This can mean only one thing. We were wrong about the initial cause of the problem.

    It's not that you change the role of UART pin, it's that you're trying to set a PWM role for non-PWM pin and thus bk_pwm_stop gets called with -1 argument.
    I see no security check against that in SDK.
    Try this:
    https://github.com/openshwprojects/OpenBK7231...mmit/28e6ee05c32d717f04950f22f8073fafbecfc98e
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #368 19946880
    sebastian48
    Level 9  
    p.kaczmarek2 wrote:
    But of course we should be better than that and I fully agree with your concerns. I will think about adding some more security layer to my firmware, but with open source, I can't see any really reliable methods to secure it. I could do a simply encryption on it, maybe even a simple xor on each character, it still would be better than what Tuya does. Maybe it would be better to also make sure that your WiFi is secure, add MAC filtering, maybe separate network for smart devices, etc. Depends on your use case.
    Still, the first thing I'd suggest is to disable debug printout of target SSID and pass that is infact now even in our firmware, as it is useful for debugging boot issues, which seems to be common among our users (see few posts above...).


    I admire your work. I'm more of a frontend guy but have been playing around with hardware for some time. Still, a lot of the low level C stuff is hard to read and understand for me. But it's fun to learn :). If you are interested in the spare chip I got (two pads are desoldered) I gladly mail it your way. I know you asked but never PM:ed you address.

    Mind boggling that Tuya has this terrible level of security. Seems like a IoT/Smart Home disaster waiting to happen. Anyhow, security by obfuscation is as we know not really security. Add the open source side of it and it's not really helping. Bit of a nut to crack.

    Meanwhile both my devices have experienced some sort of crash where they get stuck in their state until I power cycle. I have yet to find any pattern so I guess I will observe for a few days and maybe just have to fix some clip to connect the log. Maybe Home Assistant log will show something too. I should probably setup the dev env too. I just grabbed the precompiled binary that is about a month old and I've seen there are some changes since. Is this something you have experienced?
  • #369 19947120
    pepesuriano
    Level 9  
    eakeyson wrote:

    Where did you get those clips to attach the Dupont cables to the PCB?


    With the logic analyzer, but here are more or less the same clips: https://aliexpress.com/item/32875745353.html

    ExploWare wrote:
    @pepesuriano my only advice is to link the GND from UART and USB powerline you feed into the AMS. The regulator on the serial might have a floating gnd (good from a safety perspective)


    Done, unfortunately nothing changed and it's not working just as in post https://www.elektroda.com/rtvforum/topic3866123-330.html#19930002
    Is there any guide for doing it with SPI? Perhaps I can try this way since it seems that we are not getting anything with UART :(

    p.kaczmarek2 wrote:

    Where is the 3.3V logic levels selection jumper (assuming that's the USB to TTL converter similiar to the one I am using)?
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    My adapter don't have this, it have 3v3 pin and 5v pin, it's this adapter: https://bdspeedytech.com/index.php?route=product/product&product_id=901
    I tried with an arduino uno also as UART adapter, and it didn't work either :(
  • #371 19947759
    absinth84
    Level 5  
    pepesuriano wrote:
    Is there any guide for doing it with SPI? Perhaps I can try this way since it seems that we are not getting anything with UART

    Which SPI interface do you have? No way to use an RPi?

    An alternative can be modify this project to have an Arduino as SPI interface
    https://github.com/nfd/spi-flash-programmer

    The connections to the flasher are specified here
    https://github.com/OpenBekenIOT/hid_download_py/blob/master/SPIFlash.md
  • #372 19949972
    pepesuriano
    Level 9  
    absinth84 wrote:
    pepesuriano wrote:
    Is there any guide for doing it with SPI? Perhaps I can try this way since it seems that we are not getting anything with UART

    Which SPI interface do you have? No way to use an RPi?

    An alternative can be modify this project to have an Arduino as SPI interface
    https://github.com/nfd/spi-flash-programmer

    The connections to the flasher are specified here
    https://github.com/OpenBekenIOT/hid_download_py/blob/master/SPIFlash.md


    I have a RT809h programmer also, if you know the offsets I can burn directly the binary of openbk to the SPI, do you have the memory address map?
  • #373 19951537
    btsimonh
    Level 11  
    pepesuriano wrote:
    if you know the offsets

    look in bkcdriverflash.c for the partition table.
    app starts at 0x11000, boot loader before that.
    I tried SPI via ESP32 first, and was unsuccessful. RPi worked after some coaxing...
    Theoretically, you should only need SPI if the bootloader is broken - in your case the serial flashing is not working, correct?
    So if your serial connections are ok, you could try first putting the std bootloader in from 0x0 - 0x11000, and then retry serial flashing.
    I had to SPI because I overwrote the bootloader whilst developing the OTA flashing :).
    If you do get SPI working, be sure to read all 2Mbyte as a backup first!!!
    And don't overwrite the RF partition... I don't think we have calibration yet.

    Dodano po 9 [minuty]:

    sebastian48 wrote:
    Seems like a IoT/Smart Home disaster waiting to happen

    yes, it's better to have unsecure devices that you are in control of than devices which get their firmware from China.
    Tuya claims 300M devices in the field. Each of these could be updated over the air at any moment under the control of a single organisation.
    If that organisation was Russian, we would be being told to turn all of our 'smart' lights off at this moment...
    If I was a govmnt sponsored hacker, I'd be hacking the tuya infrastructure. Far more opportunity than MicroTik routers....
    It should be noted that OpenBeken is just as secure as TAS - i.e. not.

    Dodano po 10 [minuty]:

    absinth84 wrote:
    I have some trouble here, how to use memory to store the data. I have had no more time to deep into it..

    we have LittleFS (at least on BK7231). It occupies the OTA flash area (not used unless flashing!!).
    If you use the Webapp for OTA flashing, then there are options to backup the LittleFS, flash the device, then restore the LittleFS.
    Or, you can simply drag and drop your file back into the FS after flash... this will format the LittleFS area on first file write.
    Also, there is a 'bootfile' from which initialisation commands are run. (autoexec.bat?).
    You can also 'host' the webapp in the LittleFS, and edit files from the webApp...
    Using the FS for constant configuration seems a fairly natural thing to do.
  • #374 19951572
    theosoft
    Level 10  
    Hello,

    I try to compile the firmware for the BK7231N.
    I followed the instructions. I am using a Debian VirtualBox VM (32bit and 64bit) on win11.

    I found, that the crosscompiler package (gcc) is for i386 and the package_tool (i.e: encrypt) is for X86_64.

    path in SDK: "OpenBK7231N/platforms/bk7231n/toolchain/gcc-arm-none-eabi-4_9-2015q1/bin/"
    path in SDK: "OpenBK7231N/platforms/bk7231n/bk7231n_os/tools/generate/package_tool/linux/"

    The build process doesn't work, because of the different architectures.

    Am i right??

    regards
    Theosoft

    EDIT: Found a solution. I installed Multi-arch and added i386. So needed libc and libncurses could be installed also for :i386. Compiled succesfully :-)
  • ADVERTISEMENT
  • #375 19953966
    ferbulous
    Level 18  
    @p.kaczmarek2
    Sorry, I havem't been receiving any notification from this thread
    Great work on this, I still do have the desoldered modules and will try flashing them soon
    Been trying out tasmota group feature which was a really neat feature to group multiple led bulbs without HA
    I wonder if similar feature could be implemented?

    Now that tuya cloudcutter tools is public, (thanks! @tjclement )
    https://github.com/khalednassar/tuya-cloudcutter

    Could we now utilize this to flash the bin file with ota method?
    Just noticed flashing custom firmware steps is in progress, will be waiting for this
  • #376 19954281
    sebastian48
    Level 9  
    As I mentioned I have two switches running the latest pre-compiled release. I have noticed that one of them stops responding through Home Assistant after the second one has been activated. Not immediately but after some time, usually hours. They both work individually which makes this even more strange. And they do work with the physical on/off toggle. It seems to be the last one connected that will survive and somehow force the other to lose connection. The one that will continue to run will be rock solid until I reset the other one, then roles will switch.

    This is the setup in Home Assistant:

    
    switch:
      - platform: mqtt
        name: "obk70897666 0"
        state_topic: "obk70897666/0/get"
        command_topic: "obk70897666/0/set"
        qos: 1
        payload_on: 1
        payload_off: 0
        retain: true
    
      - platform: mqtt
        name: "obk10D5618E 1"
        state_topic: "obk10D5618E/1/get"
        command_topic: "obk10D5618E/1/set"
        qos: 1
        payload_on: 1
        payload_off: 0
        retain: true
    


    Am I doing this wrong? The devices are assigned unique IP and have different MAC. Any ideas?
  • #377 19954344
    ExploWare
    Level 10  
    @sebastian48 it seemsfarly identical to my issue. I have 3 relays and one smart plug. Only one relay and the smartlplug connected, will try with all 4 soon
  • #378 19954355
    sebastian48
    Level 9  
    ExploWare wrote:
    @sebastian48 it seemsfarly identical to my issue. I have 3 relays and one smart plug. Only one relay and the smartlplug connected, will try with all 4 soon


    I will continue observe. To me it feels like a Home Assistant issue but not sure. As far as I can tell both web servers are still running even when one of them has stopped responding to MQTT.
  • ADVERTISEMENT
  • #379 19954693
    p.kaczmarek2
    Moderator Smart Home
    Sorry for my absence. I've been unable to contribute due to a minor health issue. I am recovering now and I will renew my development activity soon.
    The plan does not change, my next planned step is to look into that BL602 platform.

    Now I will try to answer the questions.



    sebastian48 wrote:
    ExploWare wrote:
    @sebastian48 it seemsfarly identical to my issue. I have 3 relays and one smart plug. Only one relay and the smartlplug connected, will try with all 4 soon

    I will continue observe. To me it feels like a Home Assistant issue but not sure. As far as I can tell both web servers are still running even when one of them has stopped responding to MQTT.

    If somebody is willing to test, then I could insert a reconnect condition pretty easily. It seems that Beken SDK is not reconnecting automatically. Just catch an event here:
    Code: C / C++
    Log in, to see the code

    and schedule a reconnect.
    Anyone willing to help with testing? The modified code in block above should force reconnect if something goes wrong.
    One could theoretically test it by connecting openbk to wifi and then evicting it from wifi from router (and see if callback is called).
    But please clarify - it only disconnects from WiFI but button and logs still works, right? It's not a total device freeze?


    sharathbk1912 wrote:

    found this
    https://github.com/openshwprojects/OpenBK7231.../apps/bk7231t_bl0937_1_plug_demo/src/bl0937.c

    is there support for bl0937 in OpenBK7231T_app for now ?

    This is Tuya code, not mine. The SDK had already BL0937 support. It's just not integrated into OpenBK. I am still waiting for BL0937 device from eBay to arrive. About a month passed so far...
    Helpful post? Buy me a coffee.
  • #380 19955250
    sebastian48
    Level 9  
    p.kaczmarek2 wrote:
    Sorry for my absence. I've been unable to contribute due to a minor health issue. I am recovering now and I will renew my development activity soon.


    First of all I wish you a speedy recovery.

    Secondly, I'd gladly help out! That said I've just did a complete wipe of my computer and have not setup my developer environment yet so it might take a while until I find the time unless someone is willing to send me a precompiled binary. I also don't have the possibility to log at the moment, I'm still waiting for my head to get a good idea how to access the pads/pins without needing to desolder it completely.

    What is interesting to me is WHY it disconnects? As I said, the other device will run rock solid without any hickups at all. There is definitely a pattern, I'm just trying to figure it out. I am leaning towards Home Assistant still.

    I can confirm that the physical button still works BUT I just now see that the webserver is not responding on the one that is down. So it seems to have crashed.
  • #381 19956249
    ExploWare
    Level 10  
    p.kaczmarek2 wrote:
    Sorry for my absence. I've been unable to contribute due to a minor health issue.

    I wish you health and strength.
    p.kaczmarek2 wrote:

    If somebody is willing to test, then I could insert a reconnect condition pretty easily. It seems that Beken SDK is not reconnecting automatically. Just catch an event here:
    Code: C / C++
    Log in, to see the code

    and schedule a reconnect.
    Anyone willing to help with testing? The modified code in block above should force reconnect if something goes wrong.
    One could theoretically test it by connecting openbk to wifi and then evicting it from wifi from router (and see if callback is called).
    But please clarify - it only disconnects from WiFI but button and logs still works, right? It's not a total device freeze?


    Sure! I've installed the two which are not yet in function, upgraded one of them, the other untouched. Both are NOT IN home assistant, to exclude that factor
    I also updated one of my other ones which are in home assistant.
    I did pull the latest _App code from github. In there I needed to comment out all I2C lines in the new_pins.c, and added your code above to usr_main.c (replacing the existing block.
    I'll try building a ping-script script or so, maybe even better try to telnet into port 80... lets see what happens
  • #382 19958480
    sebastian48
    Level 9  
    I just noticed that the one functioning device also seems to have "crashed" not responding to commands. Still responding with physical button though. Probably needs to be hooked to log over time to understand what is going on. Unfortunately I am unable to do this atm.
  • #383 19960185
    theosoft
    Level 10  
    Edit: I modified my build setup. Now the images are build as dev_XXXX.
    I noticed, that the images are flashed over OTA correctly. But the error message in the log still remains... IGNORING now :-)
    --------------------------------------------------------------------------
    I am trying do use OTA on BK7231N devices. No success...

    I am using the RBL files from release 1.0.4 or compiled by me.
    The log shows, that the download is started and ended ok, but the bootloader message is:
    "Get 'App' partition firmware header failed! This partition will be forced to upgrade."

    1. RBL encryption wrong?? Is the header part of the compressed, encrypted segment? passcodes ok?
    2. Bootloader expects the downloaded file at a different location? OTA partition should be at 0x12A000.

    Is anybody else playing around with the N version? :-)

    regards

    Dodano po 1 [minuty]:

    Dodano po 3 [minuty]:

    For wifi scanning in http_fns.c
    Code: C / C++
    Log in, to see the code
  • #384 19961349
    kmhn
    Level 2  
    Hi folks, @tjclement and I finally cleaned up and merged the remote flashing code into https://github.com/khalednassar/tuya-cloudcutter

    Instructions to follow but it should be pretty self explanatory. Add the custom firmware UG image in custom-firmware then run run_flash.sh

    Of course that's assuming you have a device profile for the exploit to work. You can check out the example device profiles and the writeup if you'd like to make one for a device you have, or create an issue and tag it with exploit-needed along with a firmware dump link on cloudcutter's repository. Can't promise that we'll get to it quickly but I'll try when I have the time.
  • #385 19961687
    Dobie01
    Level 8  
    Hi,
    I have tested the openbk7231T Firmware on some WB2S modules i had lying around.
    Setting an I/O port via MQTT works, but changing the status of a port (by button) does not trigger a mqtt response.
    Am i missing something or is that simply not implemented yet?

    So i could switch a light on but i want to add a motion sensor that sends me a message when it detects movement.
  • #386 19964464
    ExploWare
    Level 10  
    kmhn wrote:
    Hi folks, @tjclement and I finally cleaned up and merged the remote flashing code into https://github.com/khalednassar/tuya-cloudcutter

    Instructions to follow but it should be pretty self explanatory. Add the custom firmware UG image in custom-firmware then run run_flash.sh

    Of course that's assuming you have a device profile for the exploit to work. You can check out the example device profiles and the writeup if you'd like to make one for a device you have, or create an issue and tag it with exploit-needed along with a firmware dump link on cloudcutter's repository. Can't promise that we'll get to it quickly but I'll try when I have the time.


    Dank je wel! Ik zal snel mn lampjes testen en loggen! :)

    ExploWare wrote:
    p.kaczmarek2 wrote:

    If somebody is willing to test...
    ...

    Polling all four devices once a minute by ping and by connecting to port 80, they all once in a while failed,
    I have had it running for 90 hours; quick conclusion is the Home Assistant issue seems legit, of course it could still be the MQTT connection part.
    With my test setup, I have been pinging the IP and trying to connect to port 80 once a minute.
    
    ~$ for i in 19 22 23 24; do  grep \.$i ping-openbk.log|head -n1; grep \.$i ping-openbk.log|grep ping|wc; grep \.$i ping-openbk.log|grep port|wc; done
    
    192.168.2.19 = plug, version with Wifi Reconnect, HomeAssistant
       2482  #ping fails
       4620  #port fails
    192.168.2.22 = relay, version with WiFi Reconnect, no HomeAssistant/MQTT connection
       8339  #ping fails
       9315  #port fails
    192.168.2.23 = relay, version 17feb, no HomeAssistant/MQTT connection
        495  #ping fails
        463  #port fails
    192.168.2.24 = relay, version 28feb, HomeAssistant
       4632  #ping fails
       4652  #port fails
    


    My four devices, one of the four was very steady, it was an older version,not connected to the MQTT. The wifi fix did not solve the connectivity, if anything, it worsened it according to this one way of testing.
  • #387 19965155
    mike2k
    Level 2  
    I too have a nedis power measure thiny, the WIFIP120FT.

    I've tried al kinds of methods to flash the firmware but I'm getting intermittent errors. I power it from my lab supply and I can see it pulling around 0.02 amps @ 3.3V
    The uartdownloader constantly fails at writing the firmware. The beken writer constantly fails at erasing flash, somewhere between 0x00011000 and 0x00018000

    Did I destroy it ? And is it possible to get any of the shelve WB2S and just solder it in place ?
  • #388 19965710
    boozeman
    Level 11  
    mike2k wrote:
    I too have a nedis power measure thiny, the WIFIP120FT.

    I've tried al kinds of methods to flash the firmware but I'm getting intermittent errors. I power it from my lab supply and I can see it pulling around 0.02 amps @ 3.3V
    The uartdownloader constantly fails at writing the firmware. The beken writer constantly fails at erasing flash, somewhere between 0x00011000 and 0x00018000

    Did I destroy it ? And is it possible to get any of the shelve WB2S and just solder it in place ?


    Hi,

    Desolder carefully 0R resistor R33 and try then flash the device. The RX1 pin is used on the circuit and causes relay flickering and lights flashin while try to flash it. I can not flash this witout removing that resistor (It was easier to desolder) After Flashing and testing, you can solder it back and use OTA method for firmware updates.

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #389 19966337
    mike2k
    Level 2  
    boozeman wrote:
    mike2k wrote:
    I too have a nedis power measure thiny, the WIFIP120FT.

    I've tried al kinds of methods to flash the firmware but I'm getting intermittent errors. I power it from my lab supply and I can see it pulling around 0.02 amps @ 3.3V
    The uartdownloader constantly fails at writing the firmware. The beken writer constantly fails at erasing flash, somewhere between 0x00011000 and 0x00018000

    Did I destroy it ? And is it possible to get any of the shelve WB2S and just solder it in place ?


    Hi,

    Desolder carefully 0R resistor R33 and try then flash the device. The RX1 pin is used on the circuit and causes relay flickering and lights flashin while try to flash it. I can not flash this witout removing that resistor (It was easier to desolder) After Flashing and testing, you can solder it back and use OTA method for firmware updates.

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    Thanks for your answer. I even went so far as to desolder the module.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #390 19966342
    rupertst
    Level 7  
    Hi
    another working device:
    Brennenstuhl LED light:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    It is based on WB3S chip, and it's connecting to "brennenstul connect" which is fork of Tuya.
    Successfully flashed device with OpenBK7231T_App_UA_1.0.0.
    Pins are:
    P8 - set to PWM (brightness) or set to rely (on/off)
    P9 - set to PWM (colour of light - warm/cold)
    P1(?) - may be button, but I'm not sure - haven't tested yet

    Web APP work ok.
    It connects to MQTT broker (Mosquitto), however I have some problems with configuring it on Domoticz (I'm not using Home Assistant). I know it can be done by shell script, by publishing in lamp's topic (which is "obk060D1E8D"), but I wold like to do it in more elegant way.
    Domoticz has some plugins for MQTT. The standard one force it to publish in topic with prefix (eg. domoticz/out) and publish in json style. I don't know if the OpenBK7231T_App_UA_1.0.0. would "understand" it.
    There are some other plugins that allows autodiscovery, but its not working properly.
    Maybe I should move to home assistant, but its a lot of work for me :-(
    Maybe adding an option in OpenBK7231T to change publishing topic would solve the problem?

Topic summary

The discussion centers on the development and testing of an open-source firmware project for the BK7231T microcontroller, focusing on creating a cross-platform mini HTTP server, web-based pin configuration, MQTT integration, and Home Assistant compatibility. The project includes a Visual Studio project for Windows and firmware flashing tools like Beken Writer and a Python-based uartprogram. Users report challenges with flashing devices, including issues with firmware size limits (956KB), UART converter compatibility, and power supply stability during flashing. Solutions include using specific UART adapters (e.g., FT232R, CP2102), resetting devices via the CEN pin instead of power cycling, and trimming firmware binaries. The firmware supports devices with BK7231T and BK7231N chips, with ongoing work to add PWM dimmer support, BLE, TuyaMCU protocol integration, and OTA updates. Various smart devices such as WB2S/WB3S modules, smart plugs, LED bulbs, and switches from brands like MOES, Nedis, Hama, and Calex are tested. Users share detailed hardware teardowns, pinouts, and flashing procedures. MQTT topic naming issues related to MAC address usage were identified and fixed. The project emphasizes community collaboration, with suggestions for a Discord server to enhance real-time communication. Additional tools and SDK improvements, including CMake support and BLE integration, are under development to facilitate firmware building and device support expansion.
Summary generated by the language model.
ADVERTISEMENT