TuyaOSBluetooth FrameworkProduct DevelopmentBluetooth Beacon Mesh Lighting (AK801)

Bluetooth Beacon Mesh Lighting (AK801)

Last Updated on : 2023-03-23 07:04:11download

This topic describes the features provided by the Bluetooth Beacon 2.0 Mesh Lighting Product Development Kit (AK801).

Release

Version Description
0.0.6 (applies to TuyaOS v3.6.3) Implement the basic features for a lighting product.

Description

  • Device pairing and reset.
    • The device turns on in cool white light at full brightness by default.
    • Repeating the on/off cycle five times can reset the device. If no operation is performed within three minutes, the device restores to the previous network state. If the device is reset with a beacon 2.0 remote control, network recovery is not possible.
  • The pairing state is indicated by the highest color temperature and full brightness, blinking at a frequency of 500 ms for 3 minutes.
  • On/off gradient in white mode and color mode.
  • Switch between white mode and color mode.
  • Light scenes support gradient mode and jumping mode. The breathing mode is created by combining the gradient mode and the scene unit of light-off effects.
  • Countdown timer. Powering on/off or turning on/off the light will cause the countdown to fail.
  • The music sync feature is implemented with the scene DP data.
  • Schedule lights locally.
    • The beacon 2.0 local scheduling defines that the system checks for tasks to execute every 10 seconds, with an error of less than one minute.
    • The local schedule data will be cleared when the power is disconnected.
    • Local scheduling only works for the control of light switches.
  • Power-on behavior.
  • Power-off memory.
  • Support pairing with beacon 2.0 physical remote controls. The pairing window period is 30 seconds after power on.
  • Support PWM driver and 5758D driver. You can switch between them using the macros DRIVER_PWM and DRIVER_5758D. When 5758D drives white and colored light (RGBCW), set the drive current to 6 mA and 27 mA for RGB and cool and warm white (CW) respectively.
  • Scene sync in a device group.
  • Product testing with a host.

Leaving the pid empty is suitable for OEM production. If you set the pid to a specific value, the application cannot be used for products with different pid values.

static beacon_dev_s beacon_dev = {
    .mac = {0xdc, 0x23, 0x4f, 0x02, 0x95, 0x6e},
    .authkey = "xxxxxxxxxxxxxxxx",
    .pid = "        ",
    .version = 0x11,
    .flag = 0x00,
    .kind = 0x1015,
    .state = STATE_NOT_PAIRED
};

The source code is compact due to limited RAM space. However, after adding the 5758D driver, there is no remaining code for implementing the feature of power-on behavior. You need to trade off specific features for your preferred one.

  • To use a field-programmable gate array (FPGA) for debugging, set BOARD_FPGA to 1.
  • To print logs for debugging, set APPLOG to 1. uart_putc is used for transmission. With APPLOG enabled, other features such as local music will be unavailable due to limited resources.

Architecture

Bluetooth Beacon Mesh Lighting (AK801)

Application logic

Bluetooth Beacon Mesh Lighting (AK801)

Things to note

  • AK801 has 2 KB RAM. Stacks, heaps, and global variables are stored in RAM.
    • The stack is set to 380 bytes by default.
    • You can check the .htm file for stack usage.
    • You can check the .map file for RAM usage.

If you have any problems with TuyaOS development, you can post your questions in the Tuya Developer Forum.