|
SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (ModusToolbox)
|
Functions | |
| void | nus_protocol_init (void) |
| init ครั้งเดียวสำหรับใช้ภายใน — ble_nus_init() ทำให้แล้ว ห้ามเรียกโดยตรง | |
| void | nus_on_rx_bytes (const uint8_t *buf, size_t len) |
| ป้อนไบต์จาก NUS RX ให้ตัวประกอบเฟรม ใช้ newline คั่นเฟรม ล้นที่ 4 KB แล้ว RESYNC | |
| void | nus_protocol_tick (uint32_t now_ms) |
| watchdog แบบ keepalive 30 s ที่ทำงานเชิงรับ ให้เรียกที่ราว 10 Hz ไม่มีผู้เรียกที่ใดเลย | |
| void | nus_protocol_send_permission (const char *id, size_t id_len, int decision_approve) |
| ส่งเฟรม permission ของ id คำถามยืนยันที่เก็บไว้ หลังจากมีการตัดสินใจของมนุษย์แล้ว ไม่มีผู้เรียกที่ใดเลย | |
| void | nus_protocol_set_link_encrypted (int encrypted) |
| เป็นของภายใน stack: ถูกตั้งค่าจาก handler ของ BTM_ENCRYPTION_STATUS_EVT | |
| int | nus_protocol_get_link_encrypted (void) |
| อ่าน flag ว่า link เข้ารหัสอยู่หรือไม่ เป็น prototype ที่กู้กลับมา — อยู่ใน bento_secure_undeclared.h | |
| void | nus_fp_char_begin (const char *json, const jsmntok_t *toks, int n) |
| verb char_begin ของ folder-push: เปิดโฟลเดอร์ staging เรียกจาก dispatcher เท่านั้น | |
| void | nus_fp_file (const char *json, const jsmntok_t *toks, int n) |
| verb file: เริ่มไฟล์ใหม่ในโฟลเดอร์ staging การตรวจพาธปฏิเสธการไต่ไดเรกทอรี | |
| void | nus_fp_chunk (const char *json, const jsmntok_t *toks, int n) |
| verb chunk: สตรีมฟิลด์ base64 "d" ลง LittleFS ผ่าน decoder ที่เก็บสถานะไว้ | |
| void | nus_fp_file_end (const char *json, const jsmntok_t *toks, int n) |
| verb file_end: เขียนค่าที่ decoder ค้างไว้ลงจริงแล้วปิดไฟล์ | |
| void | nus_fp_char_end (const char *json, const jsmntok_t *toks, int n) |
| verb char_end: commit แบบอะตอมิก — เปลี่ยนชื่อ staging เป็น /buddy/<name>/ หรือลบทิ้ง | |
| int | nus_fp_is_active (void) |
| คืนค่าที่ไม่ใช่ศูนย์ในช่วงระหว่าง char_begin กับ char_end ใช้เลื่อนงานหนักอื่นออกไประหว่างการโอนข้อมูล | |
| int | nus_fp_device_write_bytes (const uint8_t *b, size_t n) |
| sink ของ decoder ที่เขียนลงไฟล์ staging ที่เปิดอยู่ เป็น prototype ที่กู้กลับมา ไม่ใช่จุดเข้าใช้งาน | |
| void | nus_b64_init (nus_b64_state_t *s, nus_b64_sink_t sink, void *ctx) |
| รีเซ็ตสถานะ decoder ที่ผู้เรียกเป็นเจ้าของแล้วต่อ sink เข้าไป ไม่มีการพักข้อมูลทั้งก้อนไว้ใน RAM | |
| int | nus_b64_feed (nus_b64_state_t *s, const uint8_t *b64, size_t len) |
| ป้อนข้อความ base64 ทีละ chunk สถานะจะพา quantum ขนาด 4 อักขระที่ถูกแบ่งข้าม chunk ไปด้วย | |
| int | nus_b64_flush (nus_b64_state_t *s) |
| เขียนค่าที่ค้างท้ายลงจริง ให้เรียกตอน file_end | |
16 ฟังก์ชัน: nus_protocol_* กับ nus_on_rx_bytes verb ของ folder-push ในกลุ่ม nus_fp_* และตัวถอดรหัส base64 nus_b64_* คอมไพล์เฉพาะเมื่อ ENABLE_PAGE_BENTO_BUDDY=1 (ค่าตั้งต้นคือ 0, proj_cm33_ns/Makefile:64, :305) ให้ build ใหม่หลังจาก make getlibs — ดู Flag gate (อ่านก่อน)
การประกาศ: nus_protocol.h, nus_folder_push.h (มี #include "vendor/jsmn.h" ซึ่งไม่มีอยู่ในชุด include ของ dist — หมายเหตุเรื่องการแพ็กเกจ header), nus_base64.h และ bento_secure_undeclared.h สำหรับ prototype ที่กู้กลับมา 2 ตัว (nus_protocol_get_link_encrypted, nus_fp_device_write_bytes) ส่วนการนำไปสร้างจริงใน nus_protocol.c / nus_folder_push.c / nus_base64.c ถูกเก็บไว้ใน libbento_secure.a เกือบทั้งหมดในกลุ่มนี้เป็นกลไกภายในของเส้นทาง RX เอง: ble_nus.c ป้อนไบต์เข้าสู่ nus_on_rx_bytes() ชั้น protocol แจงข้อมูลแล้วส่งเฟรมที่มี "cmd" ต่อให้ nus_commands_dispatch() และ verb ของ folder-push เข้าถึงได้จาก dispatcher นั้นเท่านั้น
| void nus_protocol_init | ( | void | ) |
init ครั้งเดียวสำหรับใช้ภายใน — ble_nus_init() ทำให้แล้ว ห้ามเรียกโดยตรง
| void nus_on_rx_bytes | ( | const uint8_t * | buf, |
| size_t | len ) |
ป้อนไบต์จาก NUS RX ให้ตัวประกอบเฟรม ใช้ newline คั่นเฟรม ล้นที่ 4 KB แล้ว RESYNC
| void nus_protocol_tick | ( | uint32_t | now_ms | ) |
watchdog แบบ keepalive 30 s ที่ทำงานเชิงรับ ให้เรียกที่ราว 10 Hz ไม่มีผู้เรียกที่ใดเลย
| void nus_protocol_send_permission | ( | const char * | id, |
| size_t | id_len, | ||
| int | decision_approve ) |
ส่งเฟรม permission ของ id คำถามยืนยันที่เก็บไว้ หลังจากมีการตัดสินใจของมนุษย์แล้ว ไม่มีผู้เรียกที่ใดเลย
| void nus_protocol_set_link_encrypted | ( | int | encrypted | ) |
เป็นของภายใน stack: ถูกตั้งค่าจาก handler ของ BTM_ENCRYPTION_STATUS_EVT
|
extern |
อ่าน flag ว่า link เข้ารหัสอยู่หรือไม่ เป็น prototype ที่กู้กลับมา — อยู่ใน bento_secure_undeclared.h
| void nus_fp_char_begin | ( | const char * | json, |
| const jsmntok_t * | toks, | ||
| int | n ) |
verb char_begin ของ folder-push: เปิดโฟลเดอร์ staging เรียกจาก dispatcher เท่านั้น
| void nus_fp_file | ( | const char * | json, |
| const jsmntok_t * | toks, | ||
| int | n ) |
verb file: เริ่มไฟล์ใหม่ในโฟลเดอร์ staging การตรวจพาธปฏิเสธการไต่ไดเรกทอรี
| void nus_fp_chunk | ( | const char * | json, |
| const jsmntok_t * | toks, | ||
| int | n ) |
verb chunk: สตรีมฟิลด์ base64 "d" ลง LittleFS ผ่าน decoder ที่เก็บสถานะไว้
| void nus_fp_file_end | ( | const char * | json, |
| const jsmntok_t * | toks, | ||
| int | n ) |
verb file_end: เขียนค่าที่ decoder ค้างไว้ลงจริงแล้วปิดไฟล์
| void nus_fp_char_end | ( | const char * | json, |
| const jsmntok_t * | toks, | ||
| int | n ) |
verb char_end: commit แบบอะตอมิก — เปลี่ยนชื่อ staging เป็น /buddy/<name>/ หรือลบทิ้ง
| int nus_fp_is_active | ( | void | ) |
คืนค่าที่ไม่ใช่ศูนย์ในช่วงระหว่าง char_begin กับ char_end ใช้เลื่อนงานหนักอื่นออกไประหว่างการโอนข้อมูล
|
extern |
sink ของ decoder ที่เขียนลงไฟล์ staging ที่เปิดอยู่ เป็น prototype ที่กู้กลับมา ไม่ใช่จุดเข้าใช้งาน
| void nus_b64_init | ( | nus_b64_state_t * | s, |
| nus_b64_sink_t | sink, | ||
| void * | ctx ) |
รีเซ็ตสถานะ decoder ที่ผู้เรียกเป็นเจ้าของแล้วต่อ sink เข้าไป ไม่มีการพักข้อมูลทั้งก้อนไว้ใน RAM
| int nus_b64_feed | ( | nus_b64_state_t * | s, |
| const uint8_t * | b64, | ||
| size_t | len ) |
ป้อนข้อความ base64 ทีละ chunk สถานะจะพา quantum ขนาด 4 อักขระที่ถูกแบ่งข้าม chunk ไปด้วย
| int nus_b64_flush | ( | nus_b64_state_t * | s | ) |
เขียนค่าที่ค้างท้ายลงจริง ให้เรียกตอน file_end