Author: TorchIoTBootCamp
Link: https://zhuanlan.zhihu.com/p/339700391
Ntawm: Quora
1. Taw qhia
Silicon Labs tau muab tus tswv tsev + NCP kev daws teeb meem rau Zigbee rooj vag tsim. Hauv cov qauv no, tus tswv tsev tuaj yeem sib txuas lus nrog NCP los ntawm UART lossis SPI interface. Feem ntau, UART yog siv raws li nws yooj yim dua li SPI.
Silicon Labs kuj tau muab cov qauv ua piv txwv rau qhov kev pab tswv yim, uas yog cov qauvZ3GatewayHost
. Cov qauv khiav ntawm Unix zoo li system. Qee cov neeg siv khoom yuav xav tau tus qauv tswv tsev uas tuaj yeem khiav ntawm RTOS, tab sis hmoov tsis, tsis muaj RTOS raws li tus tswv tsev qauv rau lub sijhawm. Cov neeg siv yuav tsum tau tsim lawv tus kheej qhov kev pab cuam raws li RTOS.
Nws yog ib qho tseem ceeb kom nkag siab txog UART gateway raws tu qauv ua ntej tsim ib qho kev pab cuam tus tswv tsev. Rau ob qho UART raws NCP thiab SPI raws NCP, tus tswv tsev siv EZSP raws tu qauv los sib txuas lus nrog NCP.EZSPyog luv rauEmberZnet Serial raws tu qauv, thiab nws yog txhais nyob rau hauvUG 100. Rau UART raws NCP, cov txheej txheem qis dua yog siv los nqa EZSP cov ntaub ntawv ntseeg siab tshaj UART, uas yogASHraws tu qauv, luv rauAsynchronous Serial Host. Yog xav paub ntxiv txog ASH, thov mus saibUG 101thiabSIB 115.
Kev sib raug zoo ntawm EZSP thiab ASH tuaj yeem ua piv txwv los ntawm daim duab hauv qab no:
Cov ntaub ntawv hom ntawv ntawm EZSP thiab ASH raws tu qauv tuaj yeem piav qhia los ntawm daim duab hauv qab no:
Hauv nplooj ntawv no, peb yuav qhia txog cov txheej txheem ntawm kev tsim cov ntaub ntawv UART thiab qee qhov tseem ceeb uas nquag siv hauv Zigbee rooj vag.
2. Kev teeb tsa
Cov txheej txheem txheej txheem dav dav tuaj yeem piav qhia los ntawm daim ntawv qhia hauv qab no:
Hauv daim ntawv qhia no, cov ntaub ntawv txhais tau tias EZSP ncej. Feem ntau, cov txheej txheem framing yog: |No|Step|Reference|
|:-|:-|:-|
|1|Fill the EZSP Frame|UG100|
|2|Data Randomization|Section 4.3 of UG101|
|3|Add the Control Byte|Chap2 and Chap3 of UG101|
|4|Xau CRC|Section 2.3 of UG101|
|5|Byte Stuffing|Section 4.2 of UG101|
|6|Add the End Flag|Section 2.4 of UG101|
2.1. Sau EZSP Ncej
EZSP thav duab hom yog qhia hauv Tshooj 3 ntawm UG100.
Nco ntsoov tias hom ntawv no yuav hloov pauv thaum SDK hloov kho dua tshiab. Thaum cov hom hloov pauv, peb yuav muab tus lej tshiab rau nws. Qhov tseeb EZSP version naj npawb yog 8 thaum tsab xov xwm no tau sau (EmberZnet 6.8).
Raws li EZSP thav duab hom yuav txawv ntawm cov qauv sib txawv, muaj qhov yuav tsum tau ua kom tus tswv tsev thiab NCPYuav tsumua haujlwm nrog tib EZSP version. Txwv tsis pub, lawv tsis tuaj yeem sib txuas lus raws li xav tau.
Txhawm rau ua tiav qhov ntawd, thawj cov lus txib ntawm tus tswv tsev thiab NCP yuav tsum yog cov lus txib version. Hauv lwm lo lus, tus tswv tsev yuav tsum tau rov qab EZSP version ntawm NCP ua ntej lwm yam kev sib txuas lus. Yog tias EZSP version txawv nrog EZSP version ntawm tus tswv tsev, kev sib txuas lus yuav tsum raug rho tawm.
Lub implicit yuav tsum tau tom qab no yog cov hom ntawv version hais kom ua tauTSIS TXHOB HLOOV. EZSP version hais kom ua hom ntawv zoo li hauv qab no:
Ib: https://zhuanlan.zhihu.com/p/339700391
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
2.2. Cov ntaub ntawv Randomization
Cov txheej txheem randomization kom ntxaws tau piav qhia hauv ntu 4.3 ntawm UG101. Tag nrho EZSP ncej yuav raug randomized. Qhov randomization yog kom tshwj xeeb-los yog EZSP thav duab thiab pseudo-random sequence.
Hauv qab no yog cov algorithm ntawm kev tsim cov pseudo-random sequence.
- luas = 0 x 42
- Yog tias me ntsis 0 ntawm randi yog 0, randi + 1 = randi >> 1
- yog tias ntsis 0 ntawm randi yog 1, randi + 1 = (randi >> 1) ^ 0xB8
2.3. Ntxiv cov Control Byte
Tus tswj byte yog ib cov ntaub ntawv ib byte, thiab yuav tsum tau ntxiv rau lub taub hau ntawm tus ncej. Cov hom ntawv tau piav qhia nrog cov lus hauv qab no:
Tag nrho, muaj 6 hom tswj bytes. Thawj peb yog siv rau cov thav ntawv ntau nrog EZSP cov ntaub ntawv, suav nrog DATA, ACK thiab NAK. Qhov peb kawg yog siv yam tsis muaj EZSP cov ntaub ntawv, suav nrog RST, RSTACK thiab ERROR.
Cov hom ntawv ntawm RST, RSTACK thiab ERROR tau piav qhia hauv ntu 3.1 txog 3.3.
2.4. xam CRC
16-ntsis CRC yog xam ntawm bytes los ntawm kev tswj byte mus txog thaum kawg ntawm cov ntaub ntawv. Tus qauv CRCCCITT (g(x) = x16 + x12 + x5 + 1) yog pib rau 0xFFFF. Qhov tseem ceeb tshaj plaws byte ua ntej qhov tsawg kawg nkaus byte (loj-endian hom).
2.5. Byte khoom
Raws li tau piav qhia hauv ntu 4.2 ntawm UG101, muaj qee qhov tshwj xeeb byte qhov tseem ceeb siv rau lub hom phiaj tshwj xeeb. Cov txiaj ntsig no tuaj yeem pom hauv cov lus hauv qab no:
Thaum cov nuj nqis no tshwm sim hauv tus ncej, kev kho tshwj xeeb yuav ua rau cov ntaub ntawv. - Ntxig qhov kev khiav tawm byte 0x7D nyob rau hauv pem hauv ntej ntawm cov byte reserved - Rov qab cov bit5 ntawm qhov reserved byte
Hauv qab no yog ib co piv txwv ntawm no algorithm:
2.6. Ntxiv qhov kawg Chij
Cov kauj ruam kawg yog ntxiv tus chij kawg 0x7E mus rau qhov kawg ntawm tus ncej. Tom qab ntawd, cov ntaub ntawv tuaj yeem xa mus rau UART chaw nres nkoj.
3. De-framing txheej txheem
Thaum cov ntaub ntawv tau txais los ntawm UART, peb tsuas yog yuav tsum ua cov kauj ruam rov qab los txiav txim siab nws.
4. Cov ntaub ntawv
Post lub sij hawm: Feb-08-2022