Spaces:
Running
Running
Download index.html from CSNET/e9d9vsuowkj: direct link, hf CLI and curl.
- Browser
- Download file 56.9 kB
-
https://huggingface.co/spaces/CSNET/e9d9vsuowkj/resolve/main/index.html
- Command line
-
hf download hf://spaces/CSNET/e9d9vsuowkj/index.html
-
curl -L -o index.html https://huggingface.co/spaces/CSNET/e9d9vsuowkj/resolve/main/index.html
56.9 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>คู่มือ JBand V4 SDK</title> | |
| <style> | |
| :root { | |
| --bg-primary: #1a1a2e; | |
| --bg-secondary: #16213e; | |
| --bg-card: #0f3460; | |
| --text-primary: #eaeaea; | |
| --text-secondary: #a0a0a0; | |
| --accent: #e94560; | |
| --accent-secondary: #00d9ff; | |
| --border: #2a2a4a; | |
| --code-bg: #0d1117; | |
| --success: #4ade80; | |
| --warning: #fbbf24; | |
| } | |
| * { margin: 0; padding: 0; box-sizing: border-box; } | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; | |
| background: var(--bg-primary); | |
| color: var(--text-primary); | |
| line-height: 1.6; | |
| font-size: 14px; | |
| } | |
| .container { max-width: 1200px; margin: 0 auto; padding: 15px; } | |
| header { | |
| background: var(--bg-secondary); | |
| padding: 12px 20px; | |
| border-bottom: 2px solid var(--accent); | |
| display: flex; | |
| align-items: center; | |
| gap: 20px; | |
| position: sticky; | |
| top: 0; | |
| z-index: 100; | |
| } | |
| header h1 { | |
| font-size: 1.3em; | |
| color: var(--accent); | |
| white-space: nowrap; | |
| } | |
| header .info { | |
| font-size: 0.8em; | |
| color: var(--text-secondary); | |
| } | |
| .search-box { | |
| flex: 1; | |
| max-width: 300px; | |
| } | |
| .search-box input { | |
| width: 100%; | |
| padding: 6px 12px; | |
| border: 1px solid var(--border); | |
| border-radius: 15px; | |
| background: var(--bg-primary); | |
| color: var(--text-primary); | |
| font-size: 0.85em; | |
| } | |
| nav { | |
| background: var(--bg-card); | |
| padding: 8px 15px; | |
| display: flex; | |
| flex-wrap: wrap; | |
| gap: 5px; | |
| font-size: 0.8em; | |
| border-bottom: 1px solid var(--border); | |
| } | |
| nav a { | |
| color: var(--text-primary); | |
| text-decoration: none; | |
| padding: 4px 10px; | |
| border-radius: 12px; | |
| background: var(--bg-secondary); | |
| transition: background 0.2s; | |
| } | |
| nav a:hover { background: var(--accent); } | |
| section { | |
| margin: 15px 0; | |
| background: var(--bg-secondary); | |
| border-radius: 8px; | |
| border: 1px solid var(--border); | |
| } | |
| .section-header { | |
| background: var(--bg-card); | |
| padding: 10px 15px; | |
| cursor: pointer; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| } | |
| .section-header h2 { | |
| color: var(--accent-secondary); | |
| font-size: 1.1em; | |
| } | |
| .section-header .toggle { font-size: 1em; } | |
| .section-header.collapsed .toggle { transform: rotate(-90deg); } | |
| .section-content { padding: 15px; } | |
| .section-content.hidden { display: none; } | |
| table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.85em; } | |
| th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); } | |
| th { background: var(--bg-card); color: var(--accent-secondary); font-weight: 600; } | |
| tr:hover { background: rgba(233, 69, 96, 0.1); } | |
| code { | |
| background: var(--code-bg); | |
| padding: 1px 6px; | |
| border-radius: 3px; | |
| font-family: 'Monaco', 'Menlo', monospace; | |
| font-size: 0.85em; | |
| color: var(--accent-secondary); | |
| } | |
| pre { | |
| background: var(--code-bg); | |
| padding: 12px; | |
| border-radius: 6px; | |
| overflow-x: auto; | |
| margin: 10px 0; | |
| border: 1px solid var(--border); | |
| font-size: 0.85em; | |
| } | |
| pre code { padding: 0; background: none; } | |
| .usecase { | |
| background: var(--bg-card); | |
| border-radius: 8px; | |
| margin: 15px 0; | |
| border: 1px solid var(--border); | |
| overflow: hidden; | |
| } | |
| .usecase-header { | |
| background: linear-gradient(90deg, var(--accent), #c73e54); | |
| padding: 10px 15px; | |
| color: white; | |
| font-weight: 600; | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .usecase-header .icon { font-size: 1.2em; } | |
| .usecase-content { padding: 15px; } | |
| .usecase-steps { | |
| display: grid; | |
| gap: 10px; | |
| } | |
| .step { | |
| background: var(--bg-secondary); | |
| padding: 10px; | |
| border-radius: 6px; | |
| border-left: 3px solid var(--accent-secondary); | |
| } | |
| .step-num { | |
| display: inline-block; | |
| width: 20px; | |
| height: 20px; | |
| background: var(--accent-secondary); | |
| color: #000; | |
| border-radius: 50%; | |
| text-align: center; | |
| line-height: 20px; | |
| font-size: 0.75em; | |
| font-weight: bold; | |
| margin-right: 8px; | |
| } | |
| .grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px; } | |
| .card { | |
| background: var(--bg-card); | |
| padding: 12px; | |
| border-radius: 6px; | |
| border: 1px solid var(--border); | |
| } | |
| .card h4 { color: var(--accent); margin-bottom: 8px; font-size: 0.95em; } | |
| .badge { | |
| display: inline-block; | |
| padding: 2px 8px; | |
| border-radius: 10px; | |
| font-size: 0.7em; | |
| font-weight: 600; | |
| } | |
| .badge-green { background: var(--success); color: #000; } | |
| .badge-yellow { background: var(--warning); color: #000; } | |
| .badge-red { background: var(--accent); color: #fff; } | |
| .badge-blue { background: var(--accent-secondary); color: #000; } | |
| .info-box { | |
| background: var(--bg-card); | |
| padding: 10px 15px; | |
| border-radius: 6px; | |
| margin: 10px 0; | |
| border-left: 3px solid var(--accent-secondary); | |
| font-size: 0.9em; | |
| } | |
| .warning-box { | |
| background: rgba(251, 191, 36, 0.1); | |
| padding: 10px 15px; | |
| border-radius: 6px; | |
| margin: 10px 0; | |
| border-left: 3px solid var(--warning); | |
| font-size: 0.9em; | |
| } | |
| .cmd-badge { | |
| font-family: monospace; | |
| background: var(--accent); | |
| color: white; | |
| padding: 2px 6px; | |
| border-radius: 3px; | |
| font-size: 0.8em; | |
| } | |
| .highlight { background: rgba(233, 69, 96, 0.3); } | |
| @media (max-width: 768px) { | |
| header { flex-wrap: wrap; } | |
| .search-box { max-width: 100%; order: 3; } | |
| nav { justify-content: center; } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <header> | |
| <h1>คู่มือ JBand V4 SDK</h1> | |
| <span class="info">Flutter | โปรโตคอล 2208A | แพ็กเก็ต 16 ไบต์</span> | |
| <div class="search-box"> | |
| <input type="text" id="search" placeholder="ค้นหา..." onkeyup="searchContent()"> | |
| </div> | |
| </header> | |
| <nav> | |
| <a href="#quick-ref">คู่มือด่วน</a> | |
| <a href="#connection">การเชื่อมต่อ</a> | |
| <a href="#uc-realtime">การตรวจสอบแบบเรียลไทม์</a> | |
| <a href="#uc-sleep">การติดตามการนอน</a> | |
| <a href="#uc-workout">การออกกำลังกาย</a> | |
| <a href="#uc-history">การซิงค์ประวัติ</a> | |
| <a href="#uc-notifications">การแจ้งเตือน</a> | |
| <a href="#uc-settings">การตั้งค่า</a> | |
| <a href="#protocol">โปรโตคอล</a> | |
| <a href="#commands">คำสั่งทั้งหมด</a> | |
| <a href="#constants">ค่าคงที่</a> | |
| </nav> | |
| <div class="container"> | |
| <!-- QUICK REFERENCE --> | |
| <section id="quick-ref"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>Quick Reference</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="grid-2"> | |
| <div class="card"> | |
| <h4>BLE UUIDs</h4> | |
| <table> | |
| <tr><td>Service</td><td><code>0000fff0-...-00805f9b34fb</code></td></tr> | |
| <tr><td>Write</td><td><code>0000fff6-...</code></td></tr> | |
| <tr><td>Notify</td><td><code>0000fff7-...</code></td></tr> | |
| </table> | |
| </div> | |
| <div class="card"> | |
| <h4>Packet Format</h4> | |
| <code>[CMD][Data x14][CRC]</code> = 16 bytes<br> | |
| CRC = sum(bytes 0-14) & 0xFF | |
| </div> | |
| <div class="card"> | |
| <h4>Key Files</h4> | |
| <table> | |
| <tr><td><code>ble_sdk.dart</code></td><td>SDK methods</td></tr> | |
| <tr><td><code>device_cmd.dart</code></td><td>Command codes</td></tr> | |
| <tr><td><code>resolve_util.dart</code></td><td>Response parsers</td></tr> | |
| </table> | |
| </div> | |
| <div class="card"> | |
| <h4>Data Encoding</h4> | |
| <table> | |
| <tr><td>Time</td><td>BCD (23→0x23)</td></tr> | |
| <tr><td>Integers</td><td>Little-endian</td></tr> | |
| <tr><td>Temp</td><td>raw/10 = °C</td></tr> | |
| <tr><td>Cal/Dist</td><td>raw/100</td></tr> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- CONNECTION --> | |
| <section id="connection"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>การใช้งาน: การเชื่อมต่ออุปกรณ์</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="usecase"> | |
| <div class="usecase-header"> | |
| <span class="icon">🔗</span> | |
| เชื่อมต่อและเริ่มต้นอุปกรณ์ | |
| </div> | |
| <div class="usecase-content"> | |
| <div class="usecase-steps"> | |
| <div class="step"> | |
| <span class="step-num">1</span> | |
| <strong>สแกน</strong> - กรองตามชื่อที่ขึ้นต้นด้วย "J" หรือ service UUID fff0 | |
| </div> | |
| <div class="step"> | |
| <span class="step-num">2</span> | |
| <strong>เชื่อมต่อ</strong> - เชื่อมต่อ BLE, ค้นหา services | |
| </div> | |
| <div class="step"> | |
| <span class="step-num">3</span> | |
| <strong>เปิดการแจ้งเตือน</strong> - สมัครรับข้อมูลจาก fff7 characteristic | |
| </div> | |
| <div class="step"> | |
| <span class="step-num">4</span> | |
| <strong>ซิงค์เวลา</strong> - <code class="cmd-badge">0x01</code> SetDeviceTime | |
| </div> | |
| <div class="step"> | |
| <span class="step-num">5</span> | |
| <strong>อ่านข้อมูลอุปกรณ์</strong> - แบตเตอรี่, เวอร์ชัน, MAC | |
| </div> | |
| </div> | |
| <pre><code>// หลังจากเชื่อมต่อสำเร็จ | |
| await sendCommand(BleSDK.SetDeviceTime(DateTime.now())); // 0x01 | |
| await sendCommand(BleSDK.GetDeviceBatteryLevel()); // 0x13 | |
| await sendCommand(BleSDK.GetDeviceVersion()); // 0x27 | |
| await sendCommand(BleSDK.GetDeviceMacAddress()); // 0x22 | |
| // เสริม: ตั้งค่าโปรไฟล์ผู้ใช้เพื่อคำนวณแคลอรี่ให้แม่นยำ | |
| await sendCommand(BleSDK.SetPersonalInfo(MyPersonalInfo( | |
| sex: 1, // 1=ชาย, 0=หญิง | |
| age: 30, | |
| height: 175, // ซม. | |
| weight: 70, // กก. | |
| )));</code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- USE CASE: REAL-TIME MONITORING --> | |
| <section id="uc-realtime"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>การใช้งาน: การตรวจสอบสุขภาพแบบเรียลไทม์</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="usecase"> | |
| <div class="usecase-header"> | |
| <span class="icon">💓</span> | |
| อัตราการเต้นของหัวใจ, จำนวนก้าว, SpO2, อุณหภูมิ แบบสด | |
| </div> | |
| <div class="usecase-content"> | |
| <p><strong>วิธีการทำงาน:</strong> เปิดการสตรีม → อุปกรณ์ส่งข้อมูลต่อเนื่อง → แยกวิเคราะห์และแสดงผล</p> | |
| <h4 style="margin-top:15px;">ตัวเลือกที่ 1: การสตรีมกิจกรรมต่อเนื่อง</h4> | |
| <table> | |
| <tr><th>คำสั่ง</th><th>รหัส</th><th>ข้อมูลที่ส่งมา</th></tr> | |
| <tr> | |
| <td><code>RealTimeStep(true, true)</code></td> | |
| <td><code class="cmd-badge">0x09</code></td> | |
| <td>จำนวนก้าว, แคลอรี่, ระยะทาง, อัตราการเต้นของหัวใจ, อุณหภูมิ (ต่อเนื่อง)</td> | |
| </tr> | |
| </table> | |
| <pre><code>// เริ่มการสตรีมแบบเรียลไทม์ | |
| await sendCommand(BleSDK.RealTimeStep(true, true)); // enable, tempEnable | |
| // อุปกรณ์ส่งการตอบกลับ 0x09 ต่อเนื่อง: | |
| // โครงสร้างการตอบกลับ (24+ ไบต์): | |
| // [0] = 0x09 (คำสั่ง) | |
| // [1-4] = จำนวนก้าว (int32, little-endian) | |
| // [5-8] = แคลอรี่ (int32, /100 สำหรับ kcal) | |
| // [9-12] = ระยะทาง (int32, /100 สำหรับเมตร) | |
| // [13-16] = ระยะเวลา (วินาที) | |
| // [17-20] = เวลาที่ใช้งาน | |
| // [21] = อัตราการเต้นของหัวใจ (BPM) ← สำคัญ! | |
| // [22-23] = อุณหภูมิ (raw/10 = °C) | |
| void onDataReceived(List<int> data) { | |
| if (data[0] == 0x09) { | |
| final steps = _parseInt32(data, 1); | |
| final calories = _parseInt32(data, 5) / 100.0; | |
| final heartRate = data[21]; // BPM | |
| final temp = (data[22] + (data[23] << 8)) / 10.0; // °C | |
| updateUI(steps: steps, hr: heartRate, temp: temp, cal: calories); | |
| } | |
| } | |
| // หยุดการสตรีม | |
| await sendCommand(BleSDK.stopGo());</code></pre> | |
| <h4 style="margin-top:15px;">ตัวเลือกที่ 2: การวัดเมื่อต้องการ</h4> | |
| <table> | |
| <tr><th>การวัด</th><th>ประเภท</th><th>ระยะเวลา</th><th>คำสั่ง</th></tr> | |
| <tr><td>SpO2 (ออกซิเจนในเลือด)</td><td>3</td><td>~30 วินาที</td><td><code class="cmd-badge">0x28</code></td></tr> | |
| <tr><td>อัตราการเต้นของหัวใจ</td><td>2</td><td>~15 วินาที</td><td><code class="cmd-badge">0x28</code></td></tr> | |
| <tr><td>HRV</td><td>1</td><td>~60 วินาที</td><td><code class="cmd-badge">0x28</code></td></tr> | |
| <tr><td>อุณหภูมิ</td><td>4</td><td>~10 วินาที</td><td><code class="cmd-badge">0x28</code></td></tr> | |
| </table> | |
| <pre><code>// เริ่มการวัด SpO2 | |
| await sendCommand(BleSDK.HealthMeasurementWithDataType(3, true)); | |
| // รอการเรียกกลับ (MeasurementOxygenCallback = "65") | |
| // การตอบกลับมีเปอร์เซ็นต์ SpO2 | |
| // หยุดการวัด | |
| await sendCommand(BleSDK.HealthMeasurementWithDataType(3, false));</code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- USE CASE: SLEEP TRACKING --> | |
| <section id="uc-sleep"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>การใช้งาน: การติดตามการนอน</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="usecase"> | |
| <div class="usecase-header"> | |
| <span class="icon">😴</span> | |
| การตรวจจับและวิเคราะห์การนอนอัตโนมัติ | |
| </div> | |
| <div class="usecase-content"> | |
| <div class="info-box"> | |
| <strong>วิธีการทำงาน:</strong> อุปกรณ์ตรวจจับการนอนอัตโนมัติผ่านเซ็นเซอร์การเคลื่อนไหว + HR | |
| ไม่มีคำสั่งเพื่อ "เริ่ม" การติดตาม เก็บข้อมูล ~14 คืน (FIFO) ซิงค์ข้อมูลเมื่อผู้ใช้เปิดแอป | |
| </div> | |
| <h4>ค่าขั้นตอนการนอน</h4> | |
| <table> | |
| <tr><th>ค่า</th><th>ขั้นตอน</th><th>สีที่แนะนำ</th></tr> | |
| <tr><td><code>0</code></td><td>ตื่น</td><td>🟠 ส้ม</td></tr> | |
| <tr><td><code>1</code></td><td>นอนไม่ลึก</td><td>🔵 น้ำเงินอ่อน</td></tr> | |
| <tr><td><code>2</code></td><td>นอนหลับลึก</td><td>🟣 น้ำเงินเข้ม</td></tr> | |
| <tr><td><code>3</code></td><td>นอน REM</td><td>🟣 ม่วง</td></tr> | |
| </table> | |
| <h4>ดึงข้อมูลการนอน</h4> | |
| <pre><code>// คำสั่ง: 0x53 | โหมด: 0=ล่าสุด, 2=ต่อ, 99=ลบ | |
| Future<List<SleepRecord>> fetchAllSleepData() async { | |
| List<Map> allRecords = []; | |
| bool hasMore = true; | |
| int mode = 0; // เริ่มจากล่าสุด | |
| while (hasMore) { | |
| await sendCommand(BleSDK.GetDetailSleepDataWithMode(mode)); | |
| final response = await waitForResponse(0x53); | |
| // โครงสร้างการตอบกลับ: | |
| // DataType: "26" (GetDetailSleepData) | |
| // End: true/false | |
| // Data: { date, arraySleepQuality, sleepUnitLength } | |
| allRecords.addAll(response['Data']); | |
| hasMore = response['End'] != true; | |
| mode = 2; // โหมดต่อ | |
| } | |
| return allRecords.map((r) => SleepRecord.fromMap(r)).toList(); | |
| }</code></pre> | |
| <h4>แยกวิเคราะห์และวิเคราะห์การนอน</h4> | |
| <pre><code>class SleepRecord { | |
| final String date; // "2025-12-10 23:30:00" | |
| final List<int> stages; // [1, 1, 2, 2, 2, 1, 0, ...] | |
| final int unitMinutes; // 5 หรือ 1 (ความยาวช่วงเวลา) | |
| // คุณสมบัติที่คำนวณ | |
| int get totalMinutes => stages.length * unitMinutes; | |
| String get duration => '${totalMinutes ~/ 60}ชม ${totalMinutes % 60}นาที'; | |
| int get deepMinutes => stages.where((s) => s == 2 || s == 3).length * unitMinutes; | |
| int get lightMinutes => stages.where((s) => s == 1).length * unitMinutes; | |
| int get awakeMinutes => stages.where((s) => s == 0).length * unitMinutes; | |
| int get efficiency => totalMinutes > 0 | |
| ? ((totalMinutes - awakeMinutes) / totalMinutes * 100).round() | |
| : 0; | |
| String get quality { | |
| if (efficiency >= 85) return 'ยอดเยี่ยม'; | |
| if (efficiency >= 70) return 'ดี'; | |
| if (efficiency >= 50) return 'ปานกลาง'; | |
| return 'ไม่ดี'; | |
| } | |
| } | |
| // สร้างการแสดงผลไทม์ไลน์การนอน | |
| Widget buildSleepTimeline(List<int> stages) { | |
| return Row( | |
| children: stages.map((stage) => Expanded( | |
| child: Container( | |
| height: 20, | |
| color: _getStageColor(stage), | |
| ), | |
| )).toList(), | |
| ); | |
| } | |
| Color _getStageColor(int stage) { | |
| switch (stage) { | |
| case 0: return Colors.orange; // ตื่น | |
| case 1: return Colors.lightBlue; // ไม่ลึก | |
| case 2: return Colors.indigo; // ลึก | |
| case 3: return Colors.purple; // REM | |
| default: return Colors.grey; | |
| } | |
| }</code></pre> | |
| <h4>โครงสร้างข้อมูลการตอบกลับ</h4> | |
| <table> | |
| <tr><th>รูปแบบ</th><th>ไบต์</th><th>ช่วงเวลา</th><th>ระยะเวลาสูงสุด</th></tr> | |
| <tr><td>34 ไบต์</td><td>[3-8]=วันที่, [9]=ความยาว, [10-33]=ขั้นตอน</td><td>5 นาที</td><td>~2 ชั่วโมง/ระเบียน</td></tr> | |
| <tr><td>130 ไบต์</td><td>[3-8]=วันที่, [9]=ความยาว, [10-129]=ขั้นตอน</td><td>1 นาที</td><td>~2 ชั่วโมง/ระเบียน</td></tr> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- USE CASE: WORKOUT TRACKING --> | |
| <section id="uc-workout"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>การใช้งาน: การติดตามการออกกำลังกายและกิจกรรม</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="usecase"> | |
| <div class="usecase-header"> | |
| <span class="icon">🏃</span> | |
| โหมดหลายกีฬาและเซสชันการออกกำลังกาย | |
| </div> | |
| <div class="usecase-content"> | |
| <h4>ประเภทโหมดกีฬา</h4> | |
| <table> | |
| <tr><th>โหมด</th><th>ชื่อ</th><th>โหมด</th><th>ชื่อ</th><th>โหมด</th><th>ชื่อ</th></tr> | |
| <tr><td>0</td><td>เดิน</td><td>4</td><td>ว่ายน้ำ</td><td>8</td><td>กระโดดเชือก</td></tr> | |
| <tr><td>1</td><td>วิ่ง</td><td>5</td><td>บาสเก็ตบอล</td><td>9</td><td>โยคะ</td></tr> | |
| <tr><td>2</td><td>ปั่นจักรยาน</td><td>6</td><td>ฟุตบอล</td><td>10</td><td>เครื่องเยียว</td></tr> | |
| <tr><td>3</td><td>เดินป่า</td><td>7</td><td>แบดมินตัน</td><td>11</td><td>พายเรือ</td></tr> | |
| </table> | |
| <h4>เริ่มเซสชันการออกกำลังกาย</h4> | |
| <pre><code>// เริ่มโหมดการออกกำลังกาย | |
| await sendCommand(BleSDK.EnterActivityMode( | |
| 1, // activityMode: 1=วิ่ง | |
| 1 // workMode: 1=เริ่ม | |
| )); | |
| // สำคัญ: ส่ง heartbeat ทุก 1 วินาทีเพื่อรักษาเซสชัน! | |
| Timer.periodic(Duration(seconds: 1), (timer) async { | |
| if (!isExercising) { | |
| timer.cancel(); | |
| return; | |
| } | |
| await sendCommand(BleSDK.sendHeartPackage( | |
| currentDistance, // float: ระยะทางรวม | |
| elapsedSeconds, // int: ระยะเวลา | |
| rssi // int: ความแรงสัญญาณ | |
| )); | |
| }); | |
| // อุปกรณ์ส่งการตอบกลับ 0x18 พร้อมอัตราการเต้นหัวใจแบบเรียลไทม์ระหว่างการออกกำลังกาย | |
| void onDataReceived(List<int> data) { | |
| if (data[0] == 0x18) { | |
| final heartRate = data[1]; | |
| final steps = _parseInt32(data, 2); | |
| final calories = _parseFloat(data, 6); | |
| final duration = _parseInt32(data, 10); | |
| updateWorkoutUI(hr: heartRate, steps: steps, cal: calories); | |
| } | |
| } | |
| // หยุดการออกกำลังกาย | |
| await sendCommand(BleSDK.EnterActivityMode(1, 0)); // workMode: 0=หยุด</code></pre> | |
| <h4>ดึงประวัติการออกกำลังกาย</h4> | |
| <pre><code>// คำสั่ง: 0x5C | ระเบียน: 25 ไบต์แต่ละระเบียน | |
| final records = await fetchHistory(BleSDK.GetActivityModeDataWithMode); | |
| // ฟิลด์การตอบกลับต่อระเบียน: | |
| // date, mode, modeName, heartRate, durationMinutes, steps, pace, calories, distance | |
| records.forEach((r) { | |
| print('${r['date']}: ${r['modeName']} - ${r['durationMinutes']}นาที, ' | |
| '${r['steps']} ก้าว, อัตราการเต้นหัวใจเฉลี่ย ${r['heartRate']}'); | |
| });</code></pre> | |
| <div class="warning-box"> | |
| ⚠️ <strong>จำเป็นต้องรักษาการเชื่อมต่อ:</strong> เมื่อสร้อยข้อมือเข้าสู่โหมดหลายกีฬาผ่านแอป, | |
| คุณต้องส่งแพ็กเก็ต heartbeat (0x17) ทุก 1 วินาที มิฉะนั้นสร้อยข้อมือจะออกจากโหมดกีฬาอัตโนมัติ | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- USE CASE: HISTORY SYNC --> | |
| <section id="uc-history"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>การใช้งาน: การซิงค์ข้อมูลประวัติ</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="usecase"> | |
| <div class="usecase-header"> | |
| <span class="icon">📊</span> | |
| รูปแบบการดึงข้อมูลจำนวนมาก | |
| </div> | |
| <div class="usecase-content"> | |
| <div class="info-box"> | |
| <strong>การแบ่งหน้า:</strong> อุปกรณ์ส่งคืนสูงสุด ~50 ระเบียนต่อคำขอ | |
| ตรวจสอบ <code>End: true/false</code> ในการตอบกลับ ใช้โหมด <code>0x02</code> เพื่อต่อ | |
| </div> | |
| <h4>ประเภทประวัติที่มี</h4> | |
| <table> | |
| <tr><th>ข้อมูล</th><th>รหัส</th><th>เมธอด SDK</th><th>ระเบียน</th><th>การเก็บ</th></tr> | |
| <tr><td>จำนวนก้าวรายวัน</td><td><code class="cmd-badge">0x51</code></td><td><code>GetTotalActivityDataWithMode</code></td><td>27 ไบต์</td><td>~14 วัน</td></tr> | |
| <tr><td>จำนวนก้าวรายละเอียด</td><td><code class="cmd-badge">0x52</code></td><td><code>GetDetailActivityDataWithMode</code></td><td>25 ไบต์</td><td>~7 วัน</td></tr> | |
| <tr><td>การนอน</td><td><code class="cmd-badge">0x53</code></td><td><code>GetDetailSleepDataWithMode</code></td><td>34/130 ไบต์</td><td>~14 คืน</td></tr> | |
| <tr><td>อัตราการเต้นหัวใจ</td><td><code class="cmd-badge">0x54</code></td><td><code>GetDynamicHRWithMode</code></td><td>24 ไบต์</td><td>~7 วัน</td></tr> | |
| <tr><td>อัตราการเต้นหัวใจเดี่ยว</td><td><code class="cmd-badge">0x55</code></td><td><code>GetStaticHRWithMode</code></td><td>10 ไบต์</td><td>แตกต่างกัน</td></tr> | |
| <tr><td>การทดสอบ HRV</td><td><code class="cmd-badge">0x56</code></td><td><code>GetHRVDataWithMode</code></td><td>15 ไบต์</td><td>แตกต่างกัน</td></tr> | |
| <tr><td>การออกกำลังกาย</td><td><code class="cmd-badge">0x5C</code></td><td><code>GetActivityModeDataWithMode</code></td><td>25 ไบต์</td><td>~20 เซสชัน</td></tr> | |
| <tr><td>ออกซิเจนในเลือด</td><td><code class="cmd-badge">0x60</code></td><td><code>GetBloodOxygen</code></td><td>10 ไบต์</td><td>แตกต่างกัน</td></tr> | |
| <tr><td>อุณหภูมิ</td><td><code class="cmd-badge">0x62</code></td><td><code>GetTemperature_historyDataWithMode</code></td><td>11 ไบต์</td><td>แตกต่างกัน</td></tr> | |
| </table> | |
| <h4>รูปแบบการซิงค์ทั่วไป</h4> | |
| <pre><code>// ฟังก์ชันดึงประวัติที่ใช้ซ้ำได้ | |
| Future<List<Map>> fetchHistory(Uint8List Function(int) cmdBuilder) async { | |
| List<Map> allRecords = []; | |
| bool hasMore = true; | |
| int mode = 0; // 0=ล่าสุด, 2=ต่อ, 99=ลบ | |
| while (hasMore) { | |
| await sendCommand(cmdBuilder(mode)); | |
| final response = await waitForResponse(); | |
| if (response['Data'] != null) { | |
| allRecords.addAll(response['Data'] as List); | |
| } | |
| hasMore = response['End'] != true; | |
| mode = 2; // ดึงข้อมูลต่อ | |
| await Future.delayed(Duration(milliseconds: 200)); // จำกัดอัตรา | |
| } | |
| return allRecords; | |
| } | |
| // ตัวอย่างการใช้งาน: | |
| final sleepData = await fetchHistory(BleSDK.GetDetailSleepDataWithMode); | |
| final hrData = await fetchHistory(BleSDK.GetDynamicHRWithMode); | |
| final stepData = await fetchHistory(BleSDK.GetTotalActivityDataWithMode); | |
| final workouts = await fetchHistory(BleSDK.GetActivityModeDataWithMode);</code></pre> | |
| <h4>กลยุทธ์การซิงค์เบื้องหลัง</h4> | |
| <pre><code>// กำหนดการซิงค์เป็นระยะด้วย WorkManager | |
| await Workmanager().registerPeriodicTask( | |
| 'health-sync', | |
| 'syncHealthData', | |
| frequency: Duration(hours: 1), | |
| constraints: Constraints( | |
| networkType: NetworkType.connected, | |
| requiresBatteryNotLow: true, | |
| ), | |
| ); | |
| // หรือซิงค์เวลานอน (03:00 น. รายวัน) | |
| await Workmanager().registerOneOffTask( | |
| 'sleep-sync', | |
| 'syncSleepData', | |
| initialDelay: _getDelayUntil3AM(), | |
| );</code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- USE CASE: NOTIFICATIONS --> | |
| <section id="uc-notifications"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>การใช้งาน: การแจ้งเตือนและการเตือน</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="usecase"> | |
| <div class="usecase-header"> | |
| <span class="icon">🔔</span> | |
| ส่งการแจ้งเตือนไปยังอุปกรณ์ | |
| </div> | |
| <div class="usecase-content"> | |
| <h4>ประเภทการแจ้งเตือน</h4> | |
| <table> | |
| <tr><th>ประเภท</th><th>ค่า</th><th>ประเภท</th><th>ค่า</th></tr> | |
| <tr><td>สายโทรศัพท์</td><td><code>0</code></td><td>Twitter</td><td><code>7</code></td></tr> | |
| <tr><td>WeChat</td><td><code>1</code></td><td>VK</td><td><code>8</code></td></tr> | |
| <tr><td>SMS</td><td><code>2</code></td><td>WhatsApp</td><td><code>9</code></td></tr> | |
| <tr><td>Facebook</td><td><code>3</code></td><td>หยุดสายโทร</td><td><code>0xFF</code></td></tr> | |
| <tr><td>Telegram</td><td><code>4</code></td><td></td><td></td></tr> | |
| </table> | |
| <pre><code>// ส่งการแจ้งเตือนไปยังอุปกรณ์ (สูงสุด 60 ไบต์ข้อความ) | |
| await sendCommand(BleSDK.setNotifyData(Notifier( | |
| type: Notifier.Data_WhatApp, // 9 | |
| info: 'ข้อความใหม่จาก John' | |
| ))); | |
| // การแจ้งเตือนสายโทรเข้า | |
| await sendCommand(BleSDK.setNotifyData(Notifier( | |
| type: Notifier.Data_Tel, // 0 | |
| info: 'แม่' | |
| ))); | |
| // หยุดสายโทรเข้า (ผู้ใช้ปฏิเสธ/รับ) | |
| await sendCommand(BleSDK.setNotifyData(Notifier( | |
| type: Notifier.Data_Stop_Tel, // 0xFF | |
| info: '' | |
| ))); | |
| // กระตุ้นการสั่น (เช่น สำหรับการเตือนแบบกำหนดเอง) | |
| await sendCommand(BleSDK.MotorVibrationWithTimes(3)); // สั่น 3 ครั้ง</code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- USE CASE: SETTINGS --> | |
| <section id="uc-settings"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>การใช้งาน: การตั้งค่าอุปกรณ์</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="usecase"> | |
| <div class="usecase-header"> | |
| <span class="icon">⚙️</span> | |
| การปลุก, เป้าหมาย, การตรวจสอบอัตโนมัติ | |
| </div> | |
| <div class="usecase-content"> | |
| <h4>ตั้งค่าการปลุก</h4> | |
| <pre><code>// ตั้งค่าการปลุกได้สูงสุด 5 รายการ | |
| final alarms = [ | |
| Clock( | |
| number: 0, | |
| type: 1, // 1=ปกติ, 2=ยา, 3=น้ำ | |
| hour: 7, minute: 30, | |
| weeks: ['0','1','1','1','1','1','0'], // จันทร์-ศุกร์ | |
| content: 'ตื่นนอน', | |
| enable: true, | |
| ), | |
| ]; | |
| await sendCommand(BleSDK.setClockData(alarms)); | |
| // อ่านการปลุก | |
| await sendCommand(BleSDK.GetAlarmClock(0)); // 0=อ่าน, 99=ลบทั้งหมด | |
| // ลบการปลุกทั้งหมด | |
| await sendCommand(BleSDK.deleteAllClock());</code></pre> | |
| <h4>ตั้งค่าเป้าหมายจำนวนก้าว</h4> | |
| <pre><code>await sendCommand(BleSDK.SetStepGoal(10000)); // 10,000 ก้าว | |
| final goal = await sendCommand(BleSDK.GetStepGoal());</code></pre> | |
| <h4>การตรวจสอบอัตราการเต้นหัวใจอัตโนมัติ</h4> | |
| <pre><code>// กำหนดการวัดอัตราการเต้นหัวใจอัตโนมัติ | |
| await sendCommand(BleSDK.SetAutomaticHRMonitoring(MyAutomaticHRMonitoring( | |
| open: 2, // 0=ปิด, 1=ต่อเนื่อง, 2=ช่วงเวลา | |
| startHour: 8, startMinute: 0, | |
| endHour: 22, endMinute: 0, | |
| week: 127, // ทุกวัน (pow(2,0)+pow(2,1)+...+pow(2,6)) | |
| time: 30, // ทุก 30 นาที | |
| type: 1, // 1=HR, 2=SpO2, 3=Temp, 4=HRV | |
| ))); | |
| // อ่านการตั้งค่าปัจจุบัน | |
| await sendCommand(BleSDK.GetAutomaticHRMonitoring(1)); // type=1 สำหรับ HR</code></pre> | |
| <h4>การเตือนการนั่งเป็นเวลานาน</h4> | |
| <pre><code>await sendCommand(BleSDK.SetSedentaryReminder(MySedentaryReminder( | |
| startHour: 9, startMinute: 0, | |
| endHour: 18, endMinute: 0, | |
| week: 62, // จันทร์-ศุกร์ (pow(2,1)+...+pow(2,5)) | |
| intervalTime: 60, // เตือนทุก 60 นาที | |
| leastStep: 100, // ข้ามถ้าผู้ใช้เดิน 100+ ก้าว | |
| enable: true, | |
| )));</code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- PROTOCOL DETAILS --> | |
| <section id="protocol"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>รายละเอียดโปรโตคอล</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <h4>โครงสร้างแพ็กเก็ต</h4> | |
| <pre><code>┌──────┬──────────────────────────────┬─────┐ | |
| │ [0] │ [1] [2] [3] ... [13] [14] │[15] │ | |
| │ CMD │ Payload (14 bytes) │ CRC │ | |
| └──────┴──────────────────────────────┴─────┘ | |
| การคำนวณ CRC: | |
| int crc = 0; | |
| for (int i = 0; i < 15; i++) crc += packet[i]; | |
| packet[15] = crc & 0xFF;</code></pre> | |
| <h4>การเข้ารหัส BCD (สำหรับค่าเวลา)</h4> | |
| <pre><code>// Decimal to BCD: 23 → 0x23 | |
| int toBcd(int v) => int.parse(v.toString(), radix: 16); | |
| // BCD to Decimal: 0x23 → 23 | |
| int fromBcd(int b) => ((b >> 4) * 10) + (b & 0x0F); | |
| // ตัวอย่างแพ็กเก็ตเวลา: 2024-12-11 16:30:45 | |
| // [0x01, 0x24, 0x12, 0x11, 0x16, 0x30, 0x45, 0, 0, 0, 0, 0, 0, 0, 0, CRC]</code></pre> | |
| <h4>การแยกวิเคราะห์จำนวนเต็ม Little-Endian</h4> | |
| <pre><code>int parseInt32(List<int> data, int offset) { | |
| return data[offset] | | |
| (data[offset+1] << 8) | | |
| (data[offset+2] << 16) | | |
| (data[offset+3] << 24); | |
| } | |
| // ตัวอย่าง: [0x10, 0x27, 0x00, 0x00] ที่ offset 1 | |
| // = 0x10 + 0x2700 = 10000</code></pre> | |
| <h4>การตรวจจับท้ายประวัติ</h4> | |
| <pre><code>bool isEndOfData(List<int> data) { | |
| return data.length >= 2 && | |
| data[data.length - 1] == 0xFF && | |
| data[data.length - 2] == data[0]; // CMD + 0xFF | |
| } | |
| // ตัวอย่าง: ท้ายข้อมูลการนอน = [..., 0x53, 0xFF]</code></pre> | |
| </div> | |
| </section> | |
| <!-- ALL COMMANDS --> | |
| <section id="commands"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>คู่มือคำสั่งทั้งหมด</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <table> | |
| <tr><th>คำสั่ง</th><th>รหัส</th><th>เมธอด SDK</th><th>ประเภท</th></tr> | |
| <tr><td>ตั้งเวลา</td><td><code>0x01</code></td><td><code>SetDeviceTime()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>ตั้งข้อมูลผู้ใช้</td><td><code>0x02</code></td><td><code>SetPersonalInfo()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>ตั้งข้อมูลอุปกรณ์</td><td><code>0x03</code></td><td><code>SetDeviceInfo()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>อ่านข้อมูลอุปกรณ์</td><td><code>0x04</code></td><td><code>GetDeviceInfo()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>เปิดกิจกรรม</td><td><code>0x09</code></td><td><code>RealTimeStep()</code></td><td><span class="badge badge-green">สตรีม</span></td></tr> | |
| <tr><td>ตั้งเป้าหมาย</td><td><code>0x0B</code></td><td><code>SetStepGoal()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>รีเซ็ตโรงงาน</td><td><code>0x12</code></td><td><code>Reset()</code></td><td><span class="badge badge-red">อันตราย</span></td></tr> | |
| <tr><td>อ่านแบตเตอรี่</td><td><code>0x13</code></td><td><code>GetDeviceBatteryLevel()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>สภาพอากาศ</td><td><code>0x15</code></td><td><code>WeatherData</code></td><td><span class="badge badge-yellow">ส่ง</span></td></tr> | |
| <tr><td>แพ็กเก็ตหัวใจ</td><td><code>0x17</code></td><td><code>sendHeartPackage()</code></td><td><span class="badge badge-green">สตรีม</span></td></tr> | |
| <tr><td>ข้อมูลการออกกำลังกาย</td><td><code>0x18</code></td><td>อุปกรณ์ส่ง</td><td><span class="badge badge-green">สตรีม</span></td></tr> | |
| <tr><td>เริ่มการออกกำลังกาย</td><td><code>0x19</code></td><td><code>EnterActivityMode()</code></td><td><span class="badge badge-green">สตรีม</span></td></tr> | |
| <tr><td>อ่าน MAC</td><td><code>0x22</code></td><td><code>GetDeviceMacAddress()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>ตั้งนาฬิกาปลุก</td><td><code>0x23</code></td><td><code>setClockData()</code></td><td><span class="badge badge-yellow">การตั้งค่า</span></td></tr> | |
| <tr><td>ตั้งการเตือนนั่งนาน</td><td><code>0x25</code></td><td><code>SetSedentaryReminder()</code></td><td><span class="badge badge-yellow">การตั้งค่า</span></td></tr> | |
| <tr><td>อ่านการเตือนนั่งนาน</td><td><code>0x26</code></td><td><code>GetSedentaryReminder()</code></td><td><span class="badge badge-yellow">การตั้งค่า</span></td></tr> | |
| <tr><td>อ่านเวอร์ชัน</td><td><code>0x27</code></td><td><code>GetDeviceVersion()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>การวัด</td><td><code>0x28</code></td><td><code>HealthMeasurementWithDataType()</code></td><td><span class="badge badge-green">สตรีม</span></td></tr> | |
| <tr><td>ตั้ง HR อัตโนมัติ</td><td><code>0x2A</code></td><td><code>SetAutomaticHRMonitoring()</code></td><td><span class="badge badge-yellow">การตั้งค่า</span></td></tr> | |
| <tr><td>อ่าน HR อัตโนมัติ</td><td><code>0x2B</code></td><td><code>GetAutomaticHRMonitoring()</code></td><td><span class="badge badge-yellow">การตั้งค่า</span></td></tr> | |
| <tr><td>รีเซ็ต MCU</td><td><code>0x2E</code></td><td><code>MCUReset()</code></td><td><span class="badge badge-red">อันตราย</span></td></tr> | |
| <tr><td>การสั่น</td><td><code>0x36</code></td><td><code>MotorVibrationWithTimes()</code></td><td><span class="badge badge-yellow">ส่ง</span></td></tr> | |
| <tr><td>อ่านชื่อ</td><td><code>0x3E</code></td><td><code>GetDeviceName()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>อ่านเวลา</td><td><code>0x41</code></td><td><code>GetDeviceTime()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>อ่านข้อมูลผู้ใช้</td><td><code>0x42</code></td><td><code>GetPersonalInfo()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>เข้า OTA</td><td><code>0x47</code></td><td><code>enterOTA()</code></td><td><span class="badge badge-red">อันตราย</span></td></tr> | |
| <tr><td>อ่านเป้าหมาย</td><td><code>0x4B</code></td><td><code>GetStepGoal()</code></td><td><span class="badge badge-blue">การตั้งค่า</span></td></tr> | |
| <tr><td>แจ้งเตือน</td><td><code>0x4D</code></td><td><code>setNotifyData()</code></td><td><span class="badge badge-yellow">ส่ง</span></td></tr> | |
| <tr><td>อ่านจำนวนก้าวรวม</td><td><code>0x51</code></td><td><code>GetTotalActivityDataWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่านจำนวนก้าวละเอียด</td><td><code>0x52</code></td><td><code>GetDetailActivityDataWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่านการนอน</td><td><code>0x53</code></td><td><code>GetDetailSleepDataWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่าน HR ประวัติ</td><td><code>0x54</code></td><td><code>GetDynamicHRWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่าน HR เดี่ยว</td><td><code>0x55</code></td><td><code>GetStaticHRWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่าน HRV</td><td><code>0x56</code></td><td><code>GetHRVDataWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่านนาฬิกาปลุก</td><td><code>0x57</code></td><td><code>GetAlarmClock()</code></td><td><span class="badge badge-yellow">การตั้งค่า</span></td></tr> | |
| <tr><td>อ่าน GPS</td><td><code>0x5A</code></td><td><code>GetActivityModeDataWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่านการออกกำลังกาย</td><td><code>0x5C</code></td><td><code>GetActivityModeDataWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่าน O2 ในเลือด</td><td><code>0x60</code></td><td><code>GetBloodOxygen()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่านอุณหภูมิประวัติ</td><td><code>0x62</code></td><td><code>GetTemperature_historyDataWithMode()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| <tr><td>อ่าน SpO2 อัตโนมัติ</td><td><code>0x66</code></td><td><code>GetAutoBloodOxygen()</code></td><td><span class="badge badge-green">ประวัติ</span></td></tr> | |
| </table> | |
| </div> | |
| </section> | |
| <!-- CONSTANTS --> | |
| <section id="constants"> | |
| <div class="section-header" onclick="toggleSection(this)"> | |
| <h2>ค่าคงที่การตอบกลับ</h2> | |
| <span class="toggle">▼</span> | |
| </div> | |
| <div class="section-content"> | |
| <div class="grid-2"> | |
| <div class="card"> | |
| <h4>ค่า DataType (BleConst)</h4> | |
| <table> | |
| <tr><td>GetDeviceTime</td><td>"0"</td></tr> | |
| <tr><td>SetDeviceTime</td><td>"1"</td></tr> | |
| <tr><td>GetPersonalInfo</td><td>"2"</td></tr> | |
| <tr><td>GetDeviceInfo</td><td>"4"</td></tr> | |
| <tr><td>GetDeviceBatteryLevel</td><td>"9"</td></tr> | |
| <tr><td>GetDeviceMacAddress</td><td>"10"</td></tr> | |
| <tr><td>GetDeviceVersion</td><td>"11"</td></tr> | |
| <tr><td>GetDeviceName</td><td>"15"</td></tr> | |
| <tr><td>GetAlarmClock</td><td>"18"</td></tr> | |
| <tr><td>RealTimeStep</td><td>"23"</td></tr> | |
| <tr><td>GetTotalActivityData</td><td>"24"</td></tr> | |
| <tr><td>GetDetailSleepData</td><td>"26"</td></tr> | |
| <tr><td>GetDynamicHR</td><td>"27"</td></tr> | |
| <tr><td>GetActivityModeData</td><td>"29"</td></tr> | |
| <tr><td>EnterActivityMode</td><td>"30"</td></tr> | |
| <tr><td>GetHRVData</td><td>"42"</td></tr> | |
| <tr><td>Blood_oxygen</td><td>"55"</td></tr> | |
| <tr><td>MeasurementOxygenCallback</td><td>"65"</td></tr> | |
| </table> | |
| </div> | |
| <div class="card"> | |
| <h4>คีย์ฟิลด์ข้อมูล (DeviceKey)</h4> | |
| <table> | |
| <tr><td colspan="2"><strong>กิจกรรม</strong></td></tr> | |
| <tr><td>Step</td><td>จำนวนก้าว</td></tr> | |
| <tr><td>Calories</td><td>kcal</td></tr> | |
| <tr><td>Distance</td><td>เมตร</td></tr> | |
| <tr><td>HeartRate</td><td>BPM</td></tr> | |
| <tr><td>TempData</td><td>°C</td></tr> | |
| <tr><td colspan="2"><strong>การนอน</strong></td></tr> | |
| <tr><td>ArraySleep</td><td>อาร์เรย์ขั้นตอน</td></tr> | |
| <tr><td>sleepUnitLength</td><td>1 หรือ 5 นาที</td></tr> | |
| <tr><td colspan="2"><strong>สุขภาพ</strong></td></tr> | |
| <tr><td>Blood_oxygen</td><td>SpO2 %</td></tr> | |
| <tr><td>HRV</td><td>ความแปรผัน</td></tr> | |
| <tr><td>Stress</td><td>ระดับความเครียด</td></tr> | |
| <tr><td colspan="2"><strong>อุปกรณ์</strong></td></tr> | |
| <tr><td>BatteryLevel</td><td>0-100%</td></tr> | |
| <tr><td>MacAddress</td><td>สตริงเลขฐานสิบหก</td></tr> | |
| <tr><td>DeviceVersion</td><td>เฟิร์มแวร์</td></tr> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <footer style="text-align: center; padding: 20px; color: var(--text-secondary); font-size: 0.8em;"> | |
| คู่มือ JBand V4 SDK | Flutter | blesdk2025_plugin | โปรโตคอล 2208A | |
| </footer> | |
| </div> | |
| <script> | |
| function toggleSection(header) { | |
| header.classList.toggle('collapsed'); | |
| header.nextElementSibling.classList.toggle('hidden'); | |
| } | |
| function searchContent() { | |
| const q = document.getElementById('search').value.toLowerCase(); | |
| document.querySelectorAll('table tr, .usecase, .card, .step').forEach(el => { | |
| const match = !q || el.textContent.toLowerCase().includes(q); | |
| el.style.display = match ? '' : 'none'; | |
| el.classList.toggle('highlight', match && q); | |
| }); | |
| } | |
| document.querySelectorAll('nav a').forEach(a => { | |
| a.addEventListener('click', e => { | |
| e.preventDefault(); | |
| document.querySelector(a.getAttribute('href'))?.scrollIntoView({behavior:'smooth'}); | |
| }); | |
| }); | |
| </script> | |
| <script defer src="https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon='{"version":"2024.11.0","token":"17ecdf4758f74c79aa71ac15e977d0df","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}' crossorigin="anonymous"></script> | |
| <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script> | |
| </body> | |
| </html> |