Munyori:TorchIoTBootCamp
Link: https://zhuanlan.zhihu.com/p/339700391
Kubva: Quora
1. Nhanganyaya
Silicon Labs yakapa mugadziri + NCP mhinduro yeZigbee gedhi dhizaini. Muchivakwa ichi, muenzi anogona kutaurirana neNCP kuburikidza neUART kana SPI interface. Kazhinji kazhinji, UART inoshandiswa sezvo iri nyore kupfuura SPI.
Silicon Labs yakapawo muenzaniso wepurojekiti yechirongwa chekugamuchira, inova muenzanisoZ3GatewayHost
. Muenzaniso unomhanya pane Unix-senge system. Vamwe vatengi vangangoda sampu yevaenzi iyo inogona kumhanya paRTOS, asi zvinosuruvarisa, hapana RTOS yakavakirwa sampu yekugamuchira yenguva iripo. Vashandisi vanofanirwa kuvandudza yavo yega host chirongwa chakavakirwa paRTOS.
Izvo zvakakosha kuti unzwisise iyo UART gateway protocol usati wagadzira yakasarudzika chirongwa chekutambira. Kune ese ari maviri UART yakavakirwa NCP uye SPI yakavakirwa NCP, muridzi anoshandisa EZSP protocol kutaurirana neNCP.EZSPipfupi yeEmberZnet Serial Protocol, uye inotsanangurwa mukatiUG100. Kune UART yakavakirwa NCP, yakaderera layer protocol inoshandiswa kutakura EZSP data zvakavimbika pamusoro peUART, ndiyoASHprotocol, pfupi yeAsynchronous Serial Host. Kuti uwane rumwe ruzivo nezve ASH, ndapota tarisa kuneUG101uyeUG115.
Hukama huri pakati peEZSP neASH hunogona kuenzanisirwa nedhiyagiramu inotevera:
Iyo data fomati yeEZSP uye ASH protocol inogona kuenzanisirwa neinotevera dhayagiramu:
Mupeji rino, tichasuma maitiro ekugadzira iyo UART data uye mamwe makiyi mafuremu ayo anowanzo shandiswa muZigbee gedhi.
2. Frameing
Iyo general frameing process inogona kuenzanisirwa neinotevera chati:
Muchati ichi, data inoreva EZSP furemu. Kazhinji, maitiro ekuumba ndeaya: |Kwete|Nhanho|Reference|
|:-|:-|:-|
|1|Zadza EZSP Frame|UG100|
|2|Data Randomization|Chikamu 4.3 cheUG101|
|3|Wedzera Control Byte|Chap2 and Chap3 of UG101|
|4| Verenga iyo CRC|Chikamu 2.3 cheUG101|
|5|Byte Stuffing|Chikamu 4.2 cheUG101|
|6|Wedzera Mureza Wekupedzisira|Chikamu 2.4 cheUG101|
2.1. Zadza EZSP Frame
Iyo EZSP furemu fomati inoratidzwa muChap 3 yeUG100.
Chenjerera kuti iyi fomati inogona kuchinja kana SDK yakwidziridzwa. Kana iyo fomati yachinja, tichaipa iyo nhamba itsva yeshanduro. Iyo yazvino EZSP vhezheni nhamba ndeye 8 pakanyorwa chinyorwa ichi (EmberZnet 6.8).
Sezvo iyo EZSP furemu fomati ingave yakasiyana pakati peshanduro dzakasiyana, pane chinosungirwa kuti mugadziri uye NCPZVINOFANIRAshanda neiyo EZSP vhezheni. Zvikasadaro, havagone kutaurirana sezvinotarisirwa.
Kuti uite izvozvo, murairo wekutanga pakati pemugamuchiri neNCP unofanira kunge uri iwo vhezheni yekuraira. Nemamwe manzwi, muridzi anofanirwa kudzoreredza EZSP vhezheni yeNCP pamberi pekumwe kutaurirana. Kana vhezheni yeEZSP yakasiyana neiyo EZSP yedivi reanotambira, kutaurirana kunofanirwa kubviswa.
Izvo zvinodikanwa kuseri kweizvi ndezvekuti iyo fomati yevhezheni yekuraira inogonaUsambo CHINJA. Iyo EZSP vhezheni yekuraira fomati yakafanana pazasi:
Nhoroondo: https://zhuanlan.zhihu.com/p/339700391
來源:知乎
著作权归作者所有
2.2. Data Randomization
Iyo yakatsanangurwa randomisation maitiro inotsanangurwa muchikamu 4.3 cheUG101. Yese EZSP furemu ichave isina kurongeka. Iyo randomisation ndeye yakasarudzika-OR iyo EZSP furemu uye pseudo-random kutevedzana.
Pazasi pane algorithm yekugadzira iyo pseudo-random sequence.
- rand0 = 0×42
- kana bit 0 yerandi iri 0, randi+1 = randi >> 1
- kana chidimbu 0 cherandi chiri 1, randi+1 = (randi >> 1) ^ 0xB8
2.3. Wedzera iyo Control Byte
Iyo control byte ndeye imwe byte data, uye inofanirwa kuwedzerwa kumusoro wefuremu. Iyo fomati inoratidzwa netafura iri pazasi:
Pakazara, kune 6 marudzi ekudzora mabheti. Iwo matatu ekutanga anoshandiswa kune akajairika mafuremu ane EZSP data, kusanganisira DATA, ACK uye NAK. Iwo matatu ekupedzisira anoshandiswa pasina zvakajairika EZSP data, kusanganisira RST, RSTACK uye ERROR.
Maitiro eRST, RSTACK uye ERROR anotsanangurwa muchikamu 3.1 kusvika 3.3.
2.4. Verenga iyo CRC
Iyo 16-bit CRC inoverengerwa pamabhaiti kubva pakudzora byte kusvika pakupera kwedata. Iyo yakajairwa CRCCCITT (g(x) = x16 + x12 + x5 + 1) inotangwa ku 0xFFFF. Iyo inonyanya kukosha byte inotungamira isinganyanyi kukosha byte (big-endian modhi).
2.5. Byte Stuffing
Sezvinotsanangurwa muchikamu 4.2 cheUG101, kune mamwe akachengeterwa byte kukosha anoshandiswa kune yakakosha chinangwa. Izvi zvakakosha zvinogona kuwanikwa mutafura inotevera:
Kana izvi zvakakosha zvikaonekwa muchimiro, kurapwa kwakakosha kuchaitwa kune data. -Isa iyo yekupukunyuka byte 0x7D pamberi peyakachengetwa byte - Dzosera iyo bit5 yeiyo yakachengetwa byte
Pazasi pane mimwe mienzaniso yeiyi algorithm:
2.6. Wedzera Mureza Wokupedzisira
Nhanho yekupedzisira ndeyekuwedzera mureza wekupedzisira 0x7E kusvika kumagumo efuremu. Mushure meizvozvo, iyo data inogona kutumirwa kuchiteshi cheUART.
3. De-framing Process
Kana data ragamuchirwa kubva kuUART, isu tinongoda kuita nhanho dzekudzokera kumashure kuti tidzikise.
4. References
Nguva yekutumira: Feb-08-2022