Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Alarms

The CGD1 supports up to 16 independent alarm slots (indexed 0–15). Each alarm has a time, day-of-week repeat mask, and snooze setting.

Alarm Structure

AlarmEntry (5 bytes)

[Enabled] [HH] [MM] [Days] [Snooze]
FieldBytesDescription
Enabled10x01 = on, 0x00 = off
HH1Hour (0–23)
MM1Minute (0–59)
Days1Day bitmask (see below)
Snooze10x01 = on, 0x00 = off

An empty/unused slot has all bytes set to 0xFF: FF FF FF FF FF.

DayMask Bitmask

BitValueDay
00x01Monday
10x02Tuesday
20x04Wednesday
30x08Thursday
40x10Friday
50x20Saturday
60x40Sunday
-0x00Once (no repeat)

Common patterns:

NameValueDays
Every day0x7FMon–Sun
Weekdays0x3EMon–Fri
Weekends0x41Sat–Sun

Protocol

Set Alarm

Send 07 05 [ID] [Enabled] [HH] [MM] [Days] [Snooze] to Data Write.

ACK: 04 ff 05 00 00 (success)

Delete Alarm

Overwrite the slot with FF values: 07 05 [ID] FF FF FF FF FF

ACK: 04 ff 05 00 00 (success)

Read Alarms

Send 01 06 to Data Write.

Response: The device sends 6 packets on Data Notify, each carrying 3 alarm entries:

11 06 [Base Index] [Entry 1 (5B)] [Entry 2 (5B)] [Entry 3 (5B)]

Each packet is 18 bytes. All 16 slots are returned (empty slots have FF FF FF FF FF).

CLI Usage

Read all alarms

cgd1 alarm-list AA:BB:CC:DD:EE:FF

Set an alarm

cgd1 alarm-set AA:BB:CC:DD:EE:FF 3 07:30 --repeat 3e
ArgumentDescription
addressDevice MAC address
slotSlot index 0–15
timeAlarm time in HH:MM format
--repeatDay mask as hex (default: 7f = every day)
--no-snoozeDisable snooze for this alarm

Delete an alarm

cgd1 alarm-delete AA:BB:CC:DD:EE:FF 3

Library API

#![allow(unused)]
fn main() {
use cgd1_rs::{AlarmSlotIndex, ClockTime, DayMask};

// Set an alarm
device.set_alarm(
    AlarmSlotIndex::new(3)?,
    ClockTime::new(7, 30)?,
    DayMask::WEEKDAYS,
    true,  // enabled
    true,  // snooze
).await?;

// Read all alarms
let slots = device.read_alarms().await?;
for slot in &slots {
    if slot.is_empty() {
        continue;
    }
    println!(
        "Slot {}: {:02}:{:02} repeat={:#04x} enabled={} snooze={}",
        slot.index(),
        slot.entry().hour(),
        slot.entry().minute(),
        slot.entry().day_mask(),
        slot.entry().enabled(),
        slot.entry().snooze(),
    );
}

// Delete an alarm
device.delete_alarm(AlarmSlotIndex::new(3)?).await?;
}

DayMask Constants

The DayMask newtype provides common constants:

ConstantValueDescription
DayMask::ONCE0x00No repeat (one-shot)
DayMask::EVERY_DAY0x7FMonday through Sunday
DayMask::WEEKDAYS0x3EMonday through Friday
DayMask::WEEKENDS0x41Saturday and Sunday