Wolemba:TorchIoTBootCamp
Zotsatira: https://zhuanlan.zhihu.com/p/339700391
Kuchokera: Quora
1. Mawu Oyamba
Silicon Labs yapereka yankho la host + NCP pamapangidwe a Zigbee gateway. Pamamangidwe awa, wolandirayo amatha kulumikizana ndi NCP kudzera mu mawonekedwe a UART kapena SPI. Nthawi zambiri, UART imagwiritsidwa ntchito chifukwa ndiyosavuta kuposa SPI.
Silicon Labs yaperekanso chitsanzo cha pulojekiti yolandira alendo, yomwe ndi chitsanzoZ3GatewayHost
. Chitsanzocho chimayenda pa Unix-ngati system. Makasitomala ena atha kufuna zitsanzo zokhala nawo zomwe zitha kuthamanga pa RTOS, koma mwatsoka, palibe RTOS yotengera zitsanzo zapanthawiyo. Ogwiritsa ntchito ayenera kupanga pulogalamu yawoyawo yotengera RTOS.
Ndikofunikira kumvetsetsa njira yolowera pachipata cha UART musanapange pulogalamu yochitira makonda. Kwa onse a UART yochokera ku NCP ndi SPI yochokera ku NCP, wolandirayo amagwiritsa ntchito protocol ya EZSP kulumikizana ndi NCP.EZSPndi zazifupiEmberZnet seri Protocol, ndipo imafotokozedwa muUG100. Kwa UART yochokera ku NCP, njira yocheperako imayikidwa kuti inyamule deta ya EZSP modalirika pa UART, ndiyeASHprotocol, mwachiduleAsynchronous Serial Host. Kuti mumve zambiri za ASH, chonde onaniUG101ndiUG115.
Ubale pakati pa EZSP ndi ASH ukhoza kuwonetsedwa ndi chithunzi chotsatirachi:
Mawonekedwe a data a EZSP ndi protocol ya ASH atha kuwonetsedwa ndi chithunzi chotsatirachi:
Patsambali, tikuwonetsa njira yopangira data ya UART ndi mafelemu ena ofunikira omwe amagwiritsidwa ntchito pafupipafupi pachipata cha Zigbee.
2. Kujambula
Njira yopangira mafelemu imatha kuwonetsedwa ndi tchati chotsatirachi:
Mu tchatichi, deta ikutanthauza chimango cha EZSP. Nthawi zambiri, njira zopangira mafelemu ndi: |No|Step|Reference|
|:-|:-|:-|
| 1| Lembani EZSP Frame|UG100|
|2|Kusamutsa Zambiri|Gawo 4.3 la UG101|
|3|Add the Control Byte|Chap2 and Chap3 of UG101|
|4|Werengetsani CRC|Gawo 2.3 la UG101|
|5|Byte Stuffing|Gawo 4.2 la UG101|
|6|Onjezani Mbendera Yomaliza|Gawo 2.4 la UG101|
2.1. Lembani EZSP Frame
Mtundu wa chimango wa EZSP ukuwonetsedwa mu Chap 3 ya UG100.
Samalani kuti mtundu uwu ukhoza kusintha pamene SDK ikukweza. Pamene mawonekedwe asintha, tidzapereka nambala yatsopano. Nambala yaposachedwa ya EZSP ndi 8 pomwe nkhaniyi idalembedwa (EmberZnet 6.8).
Popeza mtundu wa EZSP ukhoza kukhala wosiyana pakati pa mitundu yosiyanasiyana, pali chofunikira kuti wolandila ndi NCPKUYENERAgwirani ntchito ndi mtundu womwewo wa EZSP. Apo ayi, sangathe kulankhulana monga momwe amayembekezera.
Kuti mukwaniritse izi, lamulo loyamba pakati pa wolandirayo ndi NCP liyenera kukhala lamulo la mtundu. Mwa kuyankhula kwina, wolandirayo ayenera kupezanso mtundu wa EZSP wa NCP musanayambe kulankhulana kwina kulikonse. Ngati mtundu wa EZSP uli wosiyana ndi mtundu wa EZSP wa mbali yolandila, kulumikizanako kuyenera kuthetsedwa.
Chofunikira chakumbuyo kwa izi ndikuti mawonekedwe amtundu wamtunduwu amathaOSASINTHA. Mtundu wamalamulo a mtundu wa EZSP uli pansipa:
Kuchokera ku: https://zhuanlan.zhihu.com/p/339700391
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处.
2.2. Kusintha kwa Data
Tsatanetsatane watsatanetsatane wafotokozedwa mu gawo 4.3 la UG101. Chojambula chonse cha EZSP chidzasinthidwa mwachisawawa. Kusintha kwachisawawa ndikungosankha-OR chimango cha EZSP ndi kutsata kwachisawawa.
Pansipa pali algorithm yopangira ma pseudo-random sequence.
- rand0 = 0 × 42
- if bit 0 of randi is 0, randi+1 = randi >> 1
- ngati 0 wa randi ndi 1, randi+1 = (randi >> 1) ^ 0xB8
2.3. Onjezani Control Byte
Control byte ndi data imodzi yokha, ndipo iyenera kuwonjezeredwa pamutu wa chimango. Mawonekedwe ake akufotokozedwa ndi tebulo ili m'munsimu:
Pazonse, pali mitundu 6 ya ma byte owongolera. Zoyamba zitatu zimagwiritsidwa ntchito pamafelemu wamba omwe ali ndi data ya EZSP, kuphatikiza DATA, ACK ndi NAK. Zitatu zomaliza zimagwiritsidwa ntchito popanda data wamba ya EZSP, kuphatikiza RST, RSTACK ndi ERROR.
Mawonekedwe a RST, RSTACK ndi ERROR akufotokozedwa mu gawo 3.1 mpaka 3.3.
2.4. Kuwerengera CRC
CRC ya 16-bit imawerengedwa pama byte kuchokera pa control byte mpaka kumapeto kwa data. CRCCCITT (g(x) = x16 + x12 + x5 + 1) yokhazikika imayambika ku 0xFFFF. Byte yofunika kwambiri imatsogola yocheperako kwambiri (big-endian mode).
2.5. Byte Stuffing
Monga tafotokozera mu gawo 4.2 la UG101, pali zinthu zina zosungidwa zomwe zimagwiritsidwa ntchito pazinthu zapadera. Makhalidwewa akupezeka patebulo ili:
Izi zikawoneka mu chimango, chithandizo chapadera chidzachitidwa ku deta. - Lowetsani byte 0x7D kutsogolo kwa byte yosungidwa - Bwezerani bit5 ya byte yosungidwayo
M'munsimu muli zitsanzo za algorithm iyi:
2.6. Onjezani Mbendera Yomaliza
Chomaliza ndikuwonjezera mbendera yomaliza 0x7E kumapeto kwa chimango. Pambuyo pake, deta ikhoza kutumizidwa ku doko la UART.
3. De-framing Njira
Deta ikalandilidwa kuchokera ku UART, timangofunika kuchita zosinthira kuti tiyizindikire.
4. Maumboni
Nthawi yotumiza: Feb-08-2022