Data Pass-through Channel Service

Last Updated on : 2024-10-15 03:12:09download

Integration of standard Bluetooth Low Energy (LE) protocol provides data pass-through channel services for MCU and mobile app under Bluetooth LE connection. Thus, meet customized requirements and implement direct communication between the two parties.

Overview

Thanks to the generic Bluetooth module, the data pass-through channel service enables the MCU to directly establish a communication channel with the mobile app over Bluetooth, helping meet the varied development needs of the MCU.

Scenarios:

  • Complex protocol interaction scenarios where direct communication with the mobile app or panel is required.
  • Scenarios that require coordination with custom panel logic.
  • Certain services that are specific to a line of business.

Applicable firmware: Currently, only BF6H Bluetooth LE generic firmware supports this service, and other firmware will be available soon.

Related protocols

Enable/disable data pass-through channel (0xC400)

  • This channel is disabled by default. When a product needs to use this channel, you can run the command to enable it. This channel supports transparent transmission of data reporting and sending. The module does not process specific data, but directly transmits the raw data to the app for processing.
  • After enabling the mobile message notification feature, for the iOS scenario, the module will automatically initiate a request for pairing over Bluetooth and request to enable notifications after the module establishes a connection with the Tuya app. Users also need to authorize notifications on their iOS devices to ensure system messages can be properly sent to the MCU through the pass-through channel.
  • An error will be returned if the data pass-through channel is used before it is enabled.
  • When the device is unbound or reset locally, this setting will return to the default disabled state.

MCU -> module:

Field Bytes Description
Header 2 0x55
0xAA
Version number 1 0x00
Command (CMD) 1 0xC4
Data length (Len) 2 0x02
Subcommand 1 0x00
DATA 1 Config
CRC8 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Description of config:

  • Bit 0: Enable/disable the channel. A value of 0 means it is disabled, and a value of 1 means it is enabled.
  • Bit 1: Enable/disable the mobile message notification feature. A value of 0 means it is disabled, and a value of 1 means it is enabled.
  • Bit 2 to bit 7: reserved. Set the values to 0.

Module -> MCU:

Field Bytes Description
Header 2 0x55
0xAA
Version number 1 0x00
Command (CMD) 1 0xC4
Data length (Len) 2 0x02
Subcommand 1 0x00
DATA 1
  • 0x00: Success
  • 0x01: Failure
  • 0x02: Length error
  • 0x03: Feature disabled
CRC8 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Transmit data through the pass-through channel (0xC401)

This channel supports two-way data transparent transmission. The module does not process specific data, but directly transmits the raw data to the app for processing. Typically, this channel is used in conjunction with custom logic in a panel or app.

MCU <-> module:

Field Bytes Description
Header 2 0x55
0xAA
Version number 1 0x00
Command (CMD) 1 0xC4
Data length (Len) 2 Upper 8 bits
Lower 8 bits
Subcommand 1 0x01
DATA Len-1 RAW_DATA: The raw data.
CRC8 1 Start from the header, add up all the bytes, and then divide the sum by 256 to get the remainder.

Example

Here are some examples of implementation through the data pass-through channel service.

Message notification

When the mobile phone receives a message notification, the module will send the following data in the specified format through the data pass-through channel.

Data format of message notification (data is sent through the data pass-through channel)
Field name TYPE DATA_LENGTH DATA
Field length 1 byte 2 bytes n byte(s)
Field value n
The message notification is represented in type-length-data (TLD) format. The specific fields are as follows:
TYPE: The notification type.
DATA_LENGTH: The length of notification content, in big-endian format.
DATA: The notification content.
Type, upper four bits Sub-type, lower four bits Values of type Notification type DATA_LENGTH DATA
0000
Message notification-originally defined
0001 0x01 Phone call The type with 1 byte.

0x01: incoming call
0x02: answer
0x03: hang up
Phone number (Unicode encoding)
This field is available only when the type is incoming call.
0010 0x02 SMS message Unicode encoding: uses 2 bytes for 1 character.
For example, the Unicode code of the Chinese character 今 is \u4eca, and the transmission sequence is 0xCA, 0x4E.
0011 0x03 Tencent QQ
0100 0x04 WeChat
0101 0x05 Facebook
0110 0x06 Messenger
0111 0x07 Twitter
1000 0x08 WhatsApp
1001 0x09 Instagram
1010 0x0A LinkedIn
1011 0x0B Viber
1100 0x0C LINE
1101 0x0D Skype
1110 0x0E Outlook
1111 0x0F Others
0011
Message notification-new
0001 0x31 WhatsApp Business Unicode encoding: uses 2 bytes for 1 character.
For example, the Unicode code of the Chinese character 今 is \u4eca, and the transmission sequence is 0xCA, 0x4E.
0010 0x32 Email
0011 0x33 Calendar
0100 0x34 KakaoTalk
0101 0x35 VKontakte
0110 0x36 Tumblr
0111 0x37 Snapchat
1000 0x38 Telegram
1001 0x39 YouTube
1010 0x3A Pinterest
1011 0x3B TikTok
1100 0x3C Gmail
1101 0x3D Tuya

Example of message notification:

  • WeChat: It’s really hot today

    55 AA 00 C4 00 0C 01 04 00 08 CA 4E 29 59 1F 77 ED 70 68

  • Hang up calls (03 indicates hang up):

    55 AA 00 C4 00 05 01 01 00 01 03 CE

  • Incoming call (01 indicates incoming call): 15000000000

    55 AA 00 C4 00 19 01 01 00 17 01 31 00 35 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 0C

FAQs

Q: In mobile message notification applications, what are the precautions in MCU programming?

A: Whenever the application layer receives the message notification switch DP data as ‘on’, both the pass-through channel and the mobile message notification service must be enabled through the pass-through channel switch (0xC400). For the iOS scenario, after receiving the command to turn on, the module will send a pairing request to the phone and request system notification permissions. Users need to confirm in the panel pop-up to use the message notification feature properly.

Additionally, when the device is unbound, users should follow the app’s pop-up prompts to unpair Bluetooth in the system Bluetooth settings. Otherwise, the device might experience connection issues.

Support and help

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