|
SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (ModusToolbox)
|
Functions | |
| bool | ble_nus_init (const ble_nus_config_t *cfg) |
| เริ่มต้น AIROC stack แล้วเริ่มการกระจายสัญญาณ (advertising) การเรียกในช่วงบูตต้องเป็นของ task จ่ายไฟชิป | |
| int | ble_nus_send (const uint8_t *data, size_t len) |
| ส่งไบต์ออกทาง NUS TX คืน -1 เว้นแต่เชื่อมต่ออยู่และเปิด notification ไว้ มี weak stub อยู่แล้วตั้งแต่ก่อน init | |
| ble_nus_state_t | ble_nus_get_state (void) |
| อ่านค่า state โดยไม่ต้องจับ lock ปลอดภัยตั้งแต่ก่อน init เฟิร์มแวร์เลือกวนถามค่านี้แทนการเชื่อ callback | |
| void | ble_nus_deinit (void) |
| หยุดแบบ soft: ยุติการกระจายสัญญาณและตัด link แต่คง AIROC host stack ไว้ให้ทำงานต่อ | |
| void | ble_nus_rearm_advertising (void) |
| เปิดการกระจายสัญญาณใหม่บน stack ที่ init ไว้แล้ว เป็น idempotent จากทุกสถานะ | |
| const char * | ble_nus_get_adv_name (void) |
| พอยน์เตอร์ไปยังชื่อ Bento-XXXX สำหรับการกระจายสัญญาณซึ่งเป็น static คืน NULL จนกว่าจะคลี่ค่า BD address ได้ | |
| void | ble_nus_passkey_cb (const char *passkey_6_digits) |
| callback แบบ weak สำหรับ passkey ของการจับคู่ (pairing) ยังไม่ถูกเรียกใช้ในบิลด์นี้ | |
| void | ble_nus_get_diagnostics (ble_nus_diag_t *out) |
| เติม snapshot ข้อมูลวินิจฉัย (diagnostics) ที่ผู้เรียกเป็นเจ้าของ — คือบล็อก _diag.ble ของ bento.fw.query | |
8 ฟังก์ชัน: transport ble_nus_* ได้แก่ init, deinit, send, get_state, get_adv_name, rearm_advertising, passkey_cb และ get_diagnostics คอมไพล์เฉพาะเมื่อ ENABLE_PAGE_BENTO_BUDDY=1 (ค่าตั้งต้นคือ 0, proj_cm33_ns/Makefile:64, :305) ให้ build ใหม่หลังจาก make getlibs — ดู Flag gate (อ่านก่อน)
การประกาศ: ble_nus.h ส่วนการนำไปสร้างจริงใน ble_nus.c ถูกเก็บไว้ใน libbento_secure.a 2 ฟังก์ชันในกลุ่มนี้มี weak stub อยู่ใน ble_nus.c (ble_nus_send ที่ :65 และ ble_nus_get_state ที่ :68) เพื่อให้ translation unit อ้างถึงได้ก่อนที่ stack จะมีอยู่ นิยามตัวจริง (:878, :964) จะชนะเมื่อคอมโพเนนต์ BLE ถูกลิงก์เข้ามา
| bool ble_nus_init | ( | const ble_nus_config_t * | cfg | ) |
เริ่มต้น AIROC stack แล้วเริ่มการกระจายสัญญาณ (advertising) การเรียกในช่วงบูตต้องเป็นของ task จ่ายไฟชิป
Initialize the AIROC BLE host stack, register NUS GATT service, and start advertising. Returns false on stack init failure (check UART log).
| int ble_nus_send | ( | const uint8_t * | data, |
| size_t | len ) |
ส่งไบต์ออกทาง NUS TX คืน -1 เว้นแต่เชื่อมต่ออยู่และเปิด notification ไว้ มี weak stub อยู่แล้วตั้งแต่ก่อน init
Send a notification on NUS TX characteristic. Fragmented into MTU-sized chunks internally. Thread-safe (enqueues to BLE task). Returns bytes queued, or -1 if disconnected / not initialized.
| ble_nus_state_t ble_nus_get_state | ( | void | ) |
อ่านค่า state โดยไม่ต้องจับ lock ปลอดภัยตั้งแต่ก่อน init เฟิร์มแวร์เลือกวนถามค่านี้แทนการเชื่อ callback
Current connection state (polled from UI layer).
| void ble_nus_deinit | ( | void | ) |
หยุดแบบ soft: ยุติการกระจายสัญญาณและตัด link แต่คง AIROC host stack ไว้ให้ทำงานต่อ
Soft-stop: stop advertising + drop any active GATT link, but keep the AIROC host stack alive. Pair with ble_nus_rearm_advertising to toggle the link without re-running the heavy stack init/deinit cycle (which crashed CM33 when invoked from the IPC RX task — see ISSUE-029).
| void ble_nus_rearm_advertising | ( | void | ) |
เปิดการกระจายสัญญาณใหม่บน stack ที่ init ไว้แล้ว เป็น idempotent จากทุกสถานะ
Re-arm undirected-high advertising on a stack that's already been initialized once via ble_nus_init. Idempotent — safe to call from any state (skips the start_advertisements call if state isn't OFF).
| const char * ble_nus_get_adv_name | ( | void | ) |
พอยน์เตอร์ไปยังชื่อ Bento-XXXX สำหรับการกระจายสัญญาณซึ่งเป็น static คืน NULL จนกว่าจะคลี่ค่า BD address ได้
Pointer to the static "Bento-XXXX" advertising name (lifetime = process). Returns NULL until ble_nus_init has resolved the local BD address and built the suffix.
| void ble_nus_passkey_cb | ( | const char * | passkey_6_digits | ) |
callback แบบ weak สำหรับ passkey ของการจับคู่ (pairing) ยังไม่ถูกเรียกใช้ในบิลด์นี้
Weak callback for a pairing passkey notification.
NOT REACHED IN THIS BUILD, and no passkey is ever shown. Pairing is configured as Just Works: ble_nus.c sets local_io_cap = BTM_IO_CAPABILITIES_NONE (NoInputNoOutput) auth_req = BTM_LE_AUTH_REQ_SC_BOND (no MITM bit) and a NoInputNoOutput association never raises BTM_PASSKEY_NOTIFICATION_EVT, so this callback is not invoked.
The DisplayOnly + 6-digit passkey flow it was written for is NOT YET IMPLEMENTED. The hook is kept so the integration layer (e.g. bento_buddy_task.c) can forward the code to the CM55 UI once that flow ships. The default implementation is a no-op.
| void ble_nus_get_diagnostics | ( | ble_nus_diag_t * | out | ) |
เติม snapshot ข้อมูลวินิจฉัย (diagnostics) ที่ผู้เรียกเป็นเจ้าของ — คือบล็อก _diag.ble ของ bento.fw.query