$npx -y skills add easyzoom/aix-skills --skill mqtt-embedded-integrationUse when integrating, porting, configuring, or debugging embedded MQTT clients, brokers, keepalive, QoS, TLS transport, reconnects, or publish-subscribe issues
| 1 | # MQTT Embedded Integration |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Use this skill for MCU MQTT clients by separating network link, TCP/TLS transport, MQTT session state, topic design, QoS, keepalive, and reconnect policy. MQTT success requires more than one successful publish. |
| 6 | |
| 7 | ## When To Use |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - The user wants MQTT on an MCU or embedded device. |
| 12 | - The task involves MQTT connect, publish, subscribe, keepalive, QoS, Last Will, retained messages, broker auth, TLS, reconnect, or offline buffering. |
| 13 | - The issue is connection drops, no messages, duplicate messages, memory growth, TLS failure, or reconnect storms. |
| 14 | |
| 15 | Do not use this skill when basic IP connectivity is not working. Use `lwip-integration` or platform network debugging first. |
| 16 | |
| 17 | ## First Questions |
| 18 | |
| 19 | Ask for: |
| 20 | |
| 21 | - MQTT library/client and version. |
| 22 | - Network stack, RTOS, transport, and whether TLS is used. |
| 23 | - Broker address, port, auth method, and certificate model without asking for secrets. |
| 24 | - Client ID, topics, QoS levels, keepalive, and reconnect policy. |
| 25 | - Current logs, broker logs, packet capture, or error codes. |
| 26 | - RAM budget and maximum payload size. |
| 27 | |
| 28 | ## Integration Checklist |
| 29 | |
| 30 | 1. Prove network first. |
| 31 | Confirm DNS/IP, TCP connect, and broker reachability before MQTT debugging. |
| 32 | |
| 33 | 1. Configure identity. |
| 34 | Client ID must be unique and stable enough for the product. |
| 35 | |
| 36 | 1. Bound payloads and buffers. |
| 37 | Topic length, payload size, QoS queues, and offline buffers must fit RAM. |
| 38 | |
| 39 | 1. Set keepalive and reconnect policy. |
| 40 | Avoid reconnect storms; use backoff and clear session behavior intentionally. |
| 41 | |
| 42 | 1. Add TLS deliberately. |
| 43 | Validate time, CA storage, certificate chain, SNI, and heap usage. |
| 44 | |
| 45 | 1. Verify broker behavior. |
| 46 | Test subscribe, publish, QoS behavior, retained messages, and Last Will if used. |
| 47 | |
| 48 | ## Common Failures |
| 49 | |
| 50 | - Two devices use the same client ID and kick each other off. |
| 51 | - TLS fails because device time is invalid. |
| 52 | - Keepalive too short for poor networks. |
| 53 | - QoS 1 duplicates are not handled idempotently. |
| 54 | - Offline queue grows without bounds. |
| 55 | - Topic wildcards subscribe to too much traffic for MCU RAM. |
| 56 | |
| 57 | ## Verification |
| 58 | |
| 59 | Before claiming MQTT works: |
| 60 | |
| 61 | - State client library, broker transport, TLS/auth mode, client ID policy, and keepalive. |
| 62 | - Confirm connect, subscribe, publish, disconnect, and reconnect behavior. |
| 63 | - Confirm max payload and buffer limits. |
| 64 | - Confirm TLS certificate/time handling if TLS is used. |
| 65 | - Confirm secrets were not logged or stored in examples. |
| 66 | |
| 67 | ## Example |
| 68 | |
| 69 | User: |
| 70 | |
| 71 | ```text |
| 72 | MCU MQTT 能连上但过一会儿就掉线。 |
| 73 | ``` |
| 74 | |
| 75 | Agent: |
| 76 | |
| 77 | 1. Asks for client library, keepalive, network stack, broker logs, TLS state, and reconnect policy. |
| 78 | 1. Checks ping/keepalive and duplicate client ID before changing payload logic. |
| 79 | 1. Verifies reconnect with backoff and subscription restoration. |