logo elektroda
logo elektroda
X
logo elektroda

Adding BLE Functionalities to OpenBK7231T Code for WBL3 Module & PWM Smart Light Control

manivalaguru 2349 11
ADVERTISEMENT
  • #1 19969749
    manivalaguru
    Level 3  
    Posts: 7
    Rate: 1
    hello,
    im using wbl3 module with pwm driver for smart light i have used your openbk7231T code and controlled light brightness through my mqtt broker now i want to add ble functionalities to the code so that i can configure the ssid password for wifi and username password for mqtt can you please help me with this??
    note: i have referred your my_mqtt_demo code for ble but ble stack seems to be initiated somewhere other than main i want to init the ble in main and change the advertise packet to the ibeacon format

    thanks and regards
    manikandan v
  • ADVERTISEMENT
  • #2 19970953
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    Hello, it's nice to see another person using OpenBK7231T

    Regarding your question... Right now all credentials (WiFi SSID, password, MQTT server information, etc) are configured by the Web panel. Open web browser (while being in the same network as device) and enter device IP address. First configuration is done by temporary open access point created by Bekken device (device has 192.168.4.1 IP, you might have to set manually your computer IP to 192.168.4.15 or something if DHCP doesn't work).

    I know there are BLE (Bluetooth) functionalities in Bekken SDKs, but they are not used by me right now.
    Here is the BLE driver header:
    https://github.com/openshwprojects/OpenBK7231.../bk7231t/bk7231t_os/beken378/driver/ble/ble.h

    What are you exactly trying to achieve? If you're a developer and know C, then you're welcome to help us with integrating BLE into OpenBK7231T, but in current state, we are not using BLE at all. WiFi only.

    Tell me why do you need BLE for and I will try to help get this running.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 19973956
    manivalaguru
    Level 3  
    Posts: 7
    Rate: 1
    hello,
    thanks for your reply

    we are having 100's of ble watches which will advertise in certain intervals. I want this light to scan our watches. We are differentiating our watches with serial numbers which will be included in the watch raw advertising packet, so the light should scan our devices and then advertise which device it scanned by sending a serial number in its raw advertising packet.

    my overall application
    ble->scanning and advertising(scan our devices and advertise with our serial number)
    mqtt->to change the light color and brightness
    flash memory->to store the ssid, pswrd, certs etc
    ota->to flash over the air

    if i implement the ble, i can also change the ssid and pwrd of mqtt and wifi in ble connected mode

    can you help me with this?

    note: i have attached our advertising format in photo
    Attachments:
    • Adding BLE Functionalities to OpenBK7231T Code for WBL3 Module & PWM Smart Light Control fe.jpeg (77.02 KB) You must be logged in to download this attachment.
  • #4 19982820
    manivalaguru
    Level 3  
    Posts: 7
    Rate: 1
    @p.kaczmarek2 can you help me with this?

    thanks and regards
    manikandan v
  • ADVERTISEMENT
  • #5 19982821
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    Can you provide any more of documentation of what are you trying to do? Also what kind of watches, etc? Do they have a known protocol?

    I don't have any such watches so it would be hard for me to test the code during development.

    I might try preparing a simple BLE demo soon but that's far from what you require.
    Helpful post? Buy me a coffee.
  • #6 19982832
    manivalaguru
    Level 3  
    Posts: 7
    Rate: 1
    @p.kaczmarek2 we are using nrf ble controllers in watches..for now only adding ble advertising to your code is enough for me can you tell me how I can start that?
    thanks and regards
    manikandan v
  • #7 19982842
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    Well, here is the BLE driver interface:
    https://github.com/tuya/tuya-iotos-embeded-sd.../bk7231t/bk7231t_os/beken378/driver/ble/ble.h
    I am not sure if it's possible to use both WiFi and BLE at once.
    Here is something you might find interesting:
    https://github.com/tuya/tuya-iotos-embeded-sd...78/driver/ble/ble_pub/modules/rwip/src/rwip.c
    How much C experience do you have?
    Helpful post? Buy me a coffee.
  • #8 19988113
    manivalaguru
    Level 3  
    Posts: 7
    Rate: 1
    @p.kaczmarek2 sorry for the late reply I have put a document as asked kindly verify and let me know

    thanks and regards
    manikandan v
    Attachments:
    • trackerwave_wbl3.docx (190.4 KB) You must be logged in to download this attachment.
  • #9 19993735
    manivalaguru
    Level 3  
    Posts: 7
    Rate: 1
    @p.kaczmarek2 have you checked?
  • ADVERTISEMENT
  • #10 19996448
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    I've seen this, but at this moment I am busy with the features requested by project supporters and donators and everyone is focusing on WiFi features. I will look into Bluetooth a little later. Maybe you could at least try to get a basic BT running? You have access to whole SDK.
    Helpful post? Buy me a coffee.
  • #11 19998251
    manivalaguru
    Level 3  
    Posts: 7
    Rate: 1
    @p.kaczmarek2 I have done both advertising and sending data but right now I can only send a maximum of 20 characters been trying to increase the MTU size and then send notify messages from device to mobile if I can achieve these both my requirement is over
  • #12 19998591
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14394
    Help: 650
    Rate: 12314
    Where is your codebase, I would need to see it in order to try helping.
    Helpful post? Buy me a coffee.

Topic summary

✨ The discussion revolves around integrating Bluetooth Low Energy (BLE) functionalities into the OpenBK7231T code for the WBL3 module, which is currently used for controlling smart light brightness via MQTT. The user seeks assistance in modifying the code to enable BLE scanning and advertising, specifically to detect BLE watches and transmit their serial numbers. The conversation includes references to existing BLE drivers and SDKs, with the user expressing a need to store WiFi and MQTT credentials in flash memory and implement Over-The-Air (OTA) updates. The responses highlight the challenges of using both WiFi and BLE simultaneously and the need for further documentation and code sharing to facilitate development.
Generated by the language model.

FAQ

TL;DR: On OpenBK7231T, first-boot AP uses 192.168.4.1, and "we are not using BLE at all" yet; add BLE via the SDK. [Elektroda, p.kaczmarek2, post #19970953] Why it matters: This FAQ helps developers add BLE scanning/advertising to WBL3/BK7231T smart lights while keeping MQTT control.

Quick Facts

What’s the current BLE status in OpenBK7231T?

BLE exists in Bekken SDKs, but OpenBK7231T firmware doesn’t use BLE now. "We are not using BLE at all. WiFi only." Configure WiFi and MQTT via the Web panel instead. If you need BLE, integrate it from the Tuya BK7231T SDK into your build. [Elektroda, p.kaczmarek2, post #19970953]

How can I add basic BLE advertising on WBL3/BK7231T?

Use the Tuya BK7231T SDK. Include the BLE driver header and initialize the BLE stack during system startup. Configure raw advertising data and start advertising.
  1. Include ble.h and link BLE modules.
  2. Call BLE init early (after clocks/OS ready).
  3. Set adv payload, interval, then start advertising. Check rwip.c for stack boot sequence. [Elektroda, p.kaczmarek2, post #19982842]

How do I change the advertising packet to iBeacon format?

Build the AD payload using Manufacturer Specific Data (type 0xFF). Use Apple company ID 0x004C with prefix 0x02 0x15, then add UUID, Major, Minor, and Tx power. Set ADV_NONCONN_IND if you only broadcast. Many SDKs provide raw advertising setters for this format. [Nordic Semiconductor, 2015]

How do I scan my watches and relay the serial in my advert?

Enable passive scanning and parse manufacturer data from each report. Filter for your watches’ pattern and extract the serial number. Update your own advertising payload to include that serial in the manufacturer field. This matches the target of scanning hundreds of watches. [Elektroda, manivalaguru, post #19973956]

How do I configure WiFi SSID and MQTT today (without BLE)?

Connect to the device’s temporary AP and open the Web panel. The AP IP is 192.168.4.1. If DHCP fails, set your computer to 192.168.4.15/24 and reconnect. Enter SSID, WiFi password, and MQTT parameters from the browser interface. [Elektroda, p.kaczmarek2, post #19970953]

Can WiFi MQTT run while BLE is scanning or advertising?

Concurrency may be limited on BK7231T. "I am not sure if it's possible to use both WiFi and BLE at once." Plan to duty-cycle scanning or advertising if needed. Validate performance in your firmware and consider fallbacks. [Elektroda, p.kaczmarek2, post #19982842]

Why am I limited to 20 characters, and how do I increase it?

Default ATT MTU is 23 bytes, leaving 20 bytes of application payload. Increase MTU with an MTU exchange, and enable Data Length Extension if supported. Many stacks then allow up to 247-byte notifications. Segment data if the peer negotiates a smaller MTU. [Bluetooth SIG, 2015]

How do I send BLE GATT notifications to a phone?

Create a characteristic with Notify and a CCCD. On connect, wait for the client to enable notifications. Call the SDK’s notify function whenever data updates. Respect the negotiated MTU and fragment larger payloads as needed. [Nordic Semiconductor, 2020]

Where should I initialize BLE, and can I do it in main?

The BLE stack boots under the RW IP layer. You can trigger application-level init from main after system init, but keep RW tasks intact. Use ble.h for the API surface and review rwip.c for startup order. [Elektroda, p.kaczmarek2, post #19982842]

What if DHCP fails on the provisioning AP?

Use a static IP to reach the device portal. Set your computer to 192.168.4.15 with mask 255.255.255.0, then browse to 192.168.4.1. Complete WiFi and MQTT configuration there. This resolves first-boot DHCP issues. [Elektroda, p.kaczmarek2, post #19970953]

How can I get help from maintainers while adding BLE?

Share your codebase so maintainers can inspect and reproduce. Provide a repository or gist and describe steps to test. "Where is your codebase, I would need to see it." This accelerates targeted guidance. [Elektroda, p.kaczmarek2, post #19998591]

Is OTA firmware update covered for this use-case?

OTA is part of your plan, but the thread doesn’t detail it. The maintainer focuses on WiFi features and suggests using the available SDK to extend features. Implement OTA using the SDK’s facilities when ready. [Elektroda, p.kaczmarek2, post #19996448]

I only need advertising now—what’s the fastest path?

Start with raw advertising only. Skip GATT until MTU and notifications are ready. Use the SDK’s ble.h to set payload and timing, then start advertising. Add scanning next, and integrate MQTT afterward. This reduces complexity early. [Elektroda, p.kaczmarek2, post #19982842]

Is there a starter example I can follow?

Developers referenced a my_mqtt_demo as a starting point for BLE. Adapt it to initialize BLE in main and to modify your advertising payload. Pair it with your existing MQTT PWM light control. [Elektroda, manivalaguru, post #19969749]
Generated by the language model.
ADVERTISEMENT