Good job, I will post that information in a form of miniguide for compiling on WSL soon. I didn't know that.
Regarding rebuild, I think that @btsimonh added the recursive "delete generated files" in the build script somewhere because there was some kind of issue. I am not sure.
Do you need help with compiling OBK to run on Windows (as a simulator with self tests)?
hezipereg wrote:
Code: C / C++
Log in, to see the code
This is called once when a driver starts. You can create custom commands there via CMD_RegisterCommand. The registered commands can be later called via MQTT, etc.
hezipereg wrote:
Code: C / C++
Log in, to see the code
This is called on every second. I am not sure if you need it.
hezipereg wrote:
Code: C / C++
Log in, to see the code
This is used to add custom information to HTTP page. Maybe you can use it to display the percentages, etc, how much shutters are open.
hezipereg wrote:
Code: C / C++
Log in, to see the code
This is called on quick tick, every 25ms. See QUICK_TMR_DURATION . Use this to update your timer counters and when they overflow, stop the shutter operations.
hezipereg wrote:
Code: C / C++
Log in, to see the code
This is called when a driver is stopped. This is often ignored, as we just assume user will restart the device.
hezipereg wrote:
Code: C / C++
Log in, to see the code
This is a channel change callback in case that you might need that. If you decide that you want to use some channel as as shutter percentage level, you may watch for it to change.
Keep in mind that there are many possible approaches to implementing the shutters driver and even I don't know which is the best. You can use our SDK in many ways, just find the one that suits your needs best.
Till today I had a controller working about 2 years and suddenly disconnected from the Wifi network. I can not normally add to Tuya so I decided if it is possible to do an Open Beken?
There is a problem because the device reports as New Device when it should be a Curtain Switch.
I have checked the capacitors and replaced them without any change.
I still need to change the software .
Can I ask for help?
>>21109623 .
I do not know TuyaMCU... it worked normally with tuya app.
I have something to upload the soft so maybe check.
Where can I generate the soft? You have already helped me in the past with the light switch flies nicely
Our flasher downloads the soft from the internet:
https://github.com/openshwprojects/BK7231GUIFlashTool But first check with a multimeter if the RX and TX from the WiFi module is not connected to this microcontroller by any chance?
Hello, very good, just thank @rodionzhitomirsky and @gliga69 for your code. I modified it and it works very well. Both the physical and web buttons work correctly, and the blind percentage seems great. I have it on a Loratap SC400W-EU, but don't trust the PINs; each Loratap is unique.
I'm leaving the code here, with a comment on where to put your PINs, in case anyone is interested.
clearIO
// ====== CONFIG ======
// Used to hold the delay value in millis for sleeping during closing or opening loop
// Play with your curtain and find the right value for this delay
SetChannel 8 100
// Delay to wait (millis) before starting to move the curtain after we close both relays
// maybe it is not necessary, but I prefer it to be to ensure we do not have
// both open and close relays powered simultaneously:
SetChannel 7 500
// MQTT stuff
MqttClient lr_curtain_2
MqttHost <YOUR_HA_MQTT_HOST>
MqttUser <YOUR_HA_MQTT_USER>
MqttPassword <YOUR_HA_MQTT_PASSWORD>
// ====== END OF CONFIG ======
// set channels 7, 8 and 9 to be private, so that we do not spend resources to publish their values:
SetChannelPrivate 7 1
SetChannelPrivate 8 1
SetChannelPrivate 9 1
// HIde relays from GUI
setChannelVisible 1 0
setChannelVisible 3 0
// We start the main opening/closing loop with a delay
// and than immediately have a calibration delay
// so, let's decrement the calibration delay to not have them both
// at the beginning of the loop:
addChannel 7 -$CH8 0 5000
PowerSave 1
//startDriver ntp
// set pins and channels
// Pin 7 is connected to opening relay
SetPinRole 7 Rel
// we also connect it to channel 1
SetPinChannel 7 1
SetChannelLabel 1 "Up"
// Pin 6 is connected to closing relay
SetPinRole 6 Rel
// we also connect it to channel 3
SetPinChannel 6 3
SetChannelLabel 3 "Down"
// crea los botones
setChannelType 20 Toggle
SetChannelLabel 20 "Down"
setChannelType 21 Toggle
SetChannelLabel 21 "Stop"
SetChannel 21 1
setChannelType 22 Toggle
SetChannelLabel 22 "Up"
// 23 - stop button
SetPinRole 26 Btn
// 24 - opening button
SetPinRole 9 Btn
// 26 - closing button
SetPinRole 24 Btn
// CH9 - saved position for reboot
// CH10 - current position
// CH11 - target position
SetChannelLabel 9 "Saved Position"
setChannelType 9 Dimmer
SetChannelLabel 10 "Current Position"
setChannelType 10 Dimmer
SetChannelLabel 11 "Target Position"
setChannelType 11 Dimmer
SetStartValue 9 -1
// read position saved before reboot:
SetChannel 10 $CH9
SetChannel 11 $CH9
// Setup LED:
//SetPinRole 10 LED
//SetPinChannel 10 4
// ============= MQTT ============
// Let it shine when MQTT connection is established:
addEventHandler MQTTState 1 SetChannel 4 1
addEventHandler MQTTState 0 SetChannel 4 0
// [2] Always set MQTT Retain flag to all published values;
// [7] Broadcast self state every N seconds:
// [10] Broadcast self state on MQTT connect
flags 1156
// Inform HA about our values every 30 seconds, publish 2 values per second
mqtt_broadcastInterval 30
mqtt_broadcastItemsPerSec 2
alias Set_Stop backlog setChannel 3 0; setChannel 1 0
alias Start_Opening backlog SetChannel 22 1; stopAllScripts; startScript autoexec.bat openSkylight
alias Start_Closing backlog SetChannel 20 1; stopAllScripts; startScript autoexec.bat closeSkylight
alias Stop_All backlog stopAllScripts; startScript autoexec.bat stopSkylight
alias Open_To_Target backlog stopAllScripts; startScript autoexec.bat openSkylightToTarget
alias Stop_Clicked backlog Set_Stop; Stop_All; SetChannel 21 1
// Click and fast release will effect in fully closing or opening.
// If during this process we click on the same button again, it stops
// EDIT PINS..............................................................................................................................................
addEventHandler OnClick 24 if $CH03==1 then Stop_Clicked else Start_Closing
addChangeHandler Channel20 == 1 if $CH03==1 then Stop_Clicked else Start_Closing
addEventHandler OnClick 9 if $CH01==1 then Stop_Clicked else Start_Opening
addChangeHandler Channel22 == 1 if $CH01==1 then Stop_Clicked else Start_Opening
addEventHandler OnClick 26 Stop_Clicked
addChangeHandler Channel21 == 1 if $CH02==1 then Stop_Clicked else Stop_Clicked
//..............................................................................................................................................................................
addChangeHandler Channel20 == 1 backlog SetChannel 21 0; SetChannel 22 0
addChangeHandler Channel21 == 1 backlog SetChannel 20 0; SetChannel 22 0
addChangeHandler Channel22 == 1 backlog SetChannel 20 0; SetChannel 21 0
return
// === OPEN TO GIVEN PERCENTAGE ===
openSkylightToTarget:
Set_Stop
delay_ms $CH7
openSkylightToTarget_again:
delay_ms $CH8
if $CH10<$CH11 then goto continue_opening
if $CH10>$CH11 then goto continue_closing
// we are done, we reached our target
// If we were opening or closing fully, we let the motor
// run for 3 seconds for the case we are uncalibrated:
if $CH10==0 then goto calibrate
if $CH10==100 then goto calibrate
goto openSkylightFinished
continue_opening:
// Unset_Close
setChannel 3 0
// Set_Open
setChannel 1 1
// increment:
addChannel 10 1 0 100
goto openSkylightToTarget_again
continue_closing:
// Unset_Open
setChannel 1 0
// Set_Close
setChannel 3 1
// decrement:
addChannel 10 -1 0 100
goto openSkylightToTarget_again
calibrate:
delay_ms 3000
Set_Stop
SetChannel 9 $CH10
return
openSkylightFinished:
Set_Stop
SetChannel 9 $CH10
return
// === CLOSE ===
closeSkylight:
SetChannel 11 0
goto openSkylightToTarget
return
// === OPEN ===
openSkylight:
SetChannel 11 100
goto openSkylightToTarget
return
// === STOP ===
stopSkylight:
Set_Stop
SetChannel 11 $CH10
SetChannel 9 $CH10
return
The discussion centers on the BK7231N-based LoraTap SC400W-EU switch board, focusing on desoldering challenges, flashing procedures, and firmware customization using OpenBeken. Initial difficulties in desoldering the switch pins led to partial soldering of RX, TX, VCC, and GND for flashing via shorting GND to CEN. Users shared detailed GPIO pin mappings for LEDs, buttons, and relays, clarifying LED roles such as LED, LED_n (inverted), and WifiLED_n, with hardware limitations restricting color control to on/off states. Configuration adjustments via the autoexec.bat script enabled control of LED states and introduced a runtime parameter for shutter open/close duration, which was integrated with Home Assistant through MQTT and input_number entities. Advanced users discussed developing a dedicated shutter driver in C within the OpenBK7231T_App framework, including driver structure, function callbacks, and build environment setup using Cygwin or WSL. Troubleshooting build issues and GitHub workflow for pull requests were addressed. The conversation also covered TuyaMCU device considerations, flashing tools, and extracting Tuya configurations. Finally, a user shared a custom blind driver script for the LoraTap SC400W-EU, emphasizing unique pin assignments and MQTT integration for Home Assistant control, highlighting the variability of hardware revisions. Summary generated by the language model.