Skip to content

Latest commit

 

History

History
371 lines (340 loc) · 12.2 KB

curtain3.md

File metadata and controls

371 lines (340 loc) · 12.2 KB

Curtain 3 BLE API

Broadcast Package

The following table describes the Service Data of SCAN_RSP.

SCAN RSP AD Structure
AD Structure 1 len Byte 0 0x09
type Byte 1 Service Data 0x16
data Byte 2~3 0xFD3D
Byte 4 Enc type Bit[7] NC
Device Type Bit [6:0] – Device Type,
‘[’Const Adv Mode,
‘{’Pair Mode
Byte 5 Status Bit [7] – Whether to allow connection
1- allowed, 0- not allowed
Bit [6] – Calibration situation
1-calibrated, 0-not calibrated, need to be calibrated
Bit [5-0] NC
Update utc flag Bit[7] NC
Battery Bit [6:0] – Battery capacity 0~100%
Byte 6 MotionState bit [7] - Movement status, 0-stationary, 1-movement
Position Bit [6:0] - The current position of the device (%)
Byte 7 LightLevel bit [7:4] - Light level (1-10)
DeviceChain bit [3:0] - Device chain length
Byte 8 LightLevel bit [7:4]-light level(1-10)
DeviceChain bit [3:0] - Device chain length
Byte 9 CrashType bit [7:0]-NC

Basic format of BLE communication data packet

  1. UUID related to communication.
  • Communication service UUID: cba20d00-224d-11e6-9fb8-0002a5d5c51b UUID TYPE: Vendor UUID types start at this index (128-bit)
  • RX characteristic UUID of the terminal sending data to the device: cba20002-224d-11e6-9fb8-0002a5d5c51b UUID TYPE: Vendor UUID types start at this index (128-bit) Char Attribute: RW Char Properties: notify
  • TX characteristic UUID of the device sending data to the terminal: cba20003-224d-11e6-9fb8-0002a5d5c51b UUID TYPE: Vendor UUID types start at this index (128-bit) Char Attribute: RW
  1. All two-way communication occurs after the BLE connection is established. The communication form is that the terminal first sends a REQ request packet to the device, and the device returns an RSP packet.

The terminal first sends the REQ request packet to the device. The basic format is as follows:

REQ Packet
Byte: 0 Magic Number 0x57 – (fixed value)
Byte: 1 Header Bit [7:6] – Version 0 – (fixed value)
Bit [5:4] – Encryption Mode 0 – no encryption
Bit [3:0] – command 0x02 – Get basic device information 0x0F – extended command
Byte: 2-19 Payload Depends on Command

The basic format of the RSP packet returned by the device to the terminal is as follows:

RSP Packet
Byte: 0 Response status 0x01 - OK, Action executed
0x02 - ERROR, Error while executing an Action
0x03 - BUSY, Device is busy now, please try later
0x04 - Communication protocol version incompatible
0x05 - Device does not support this Command
0x06 - Device's battery is low
0x0D - This command is not supported in the current mode
0x0E - Disconnected from the device that needs to stay connected
Byte: 1-19 Payload Depends on the Command to reply

0x02 Get the basic information of the device command

  • Used to obtain basic information about the device.
  • REQ Packet Payload is 0.
  • The Status byte of the RSP packet after successful execution is 0x01, and the Payload is:
RSP Packet Payload
Byte: 0 Bat Per The battery percentage
Byte: 1 FW Ver Firmware Version
Byte: 2 Chain Length Device Chain Length
Byte: 3 State 1 bit7-direction, 0: default (open to the left), 1: reverse
bit6-touch and go, 0: disable, 1: enable
bit5-lighting effect, 0: disable, 1: enable
bit4-reserved
bit3-fault, 0-none, 1-faulty
bit2:0-reserved
Byte: 4 State 2 bit3-Whether solar panel is plugged in, 0-No, 1-There is solar panel
bit2-calibrated, 0-not calibrated, 1-calibrated
bit1:0-motion status, 0-static, 1-open window, 2-close window
Byte: 5 Position Current location of the device (%)
Byte: 6 Timer Amount Number of timers

0x0F extended command

0x45 Curtain settings command

  • Set Curtain's unique settings.
Function code Function parameter code REQ Packet Payload
Byte: 0 Byte: 1 Byte: 2 Byte: 3
0x01-Action 0x05-unified action of device chain 0x00: high speed, 0x01: low speed The distance between the last position of the device and the starting position (%)
- REQ Packet returns different values with different commands.
REQ Packet RSP Packet
Functioncode Function parameter code Payload Byte: 0 Byte: 0 Byte: 1 Byte: 2
0x01-Action - - Command Status Device 0's current position in percentage Device 1's current position in percentage

0x46 Curtain get command

  • Get Curtain's unique settings.
  • Action mode A: 0-performance mode, 1-silent mode, other-invalid value, the default invalid value is 1 for all bit values.
  • Charging status A:
    • 0: Not charging
    • 1: Adapter charging
    • 2: Solar panel charging
    • 3: The adapter connection is full
    • 4: The solar panel connection is full
    • 5: The solar panel is connected and not charged when it is not fully charged
    • 6: Hardware error
Function Code Function Parameter Code REQ Packet Payload RSP Packet
Byte: 0 Byte: 1 Byte: 2 Byte: 3 Byte: 0 Byte: 1 Byte: 2 Byte: 3 Byte: 4 Byte: 5 Byte: 6 Byte: 7
0x04-Basic attributes 0x01-Summary information Command Status Device 0 bit7-direction, 0: default, 1: reverse bit6-touch and go, 0: disable, 1: enable bit5-light sensor, 0: disable, 1: enable bit4-reserved bit3-window mode, 0-window to the left, 1-window to the right bit2:0-reserved Device 1 bit7-direction, 0: default (open to the left), 1: reverse bit6-touch and go, 0: disable, 1: enable bit5-light sensor 0: disable, 1: enable bit4-reserved bit3-window mode, 0-open window to the left, 1-open window to the right bit2:0-reserved
0x02-Advanced page Device 0 battery power Device 0 Firmware version Device 0 State of charge A Device 1 battery power Device 1 Firmware version Device 1 State of charge A
0x81-Command status 0x01-Query the basic status of the device chain bit7-reserved bit6-delay action 0-none, 1-yes bit5:4-device chain head movement status, 0-static, 1-open window, 2-close window, bit3:0-the number of light sensing actions bit7:4-device chain head action mode A bit3:0-the number of device chain head timers Device chain length bit7-solar panel connected or not, 0-not connected, 1- connected; bit6:0-device 0's current location bit7-charing or not, 0-not charging, 1-charging; bit6:0-device 0's current battery level bit7-solar panel connected or not, 0-not connected, 1- connected; bit6:0-device 1's current location bit7-charing or not, 0-not charging, 1-charging; bit6:0-device 1's current battery level

CopyRight@2024 SWITCHBOT INC

Back to Home

Back to Device Types