Malunga neZigbee EZSP UART

Umbhali:TorchIoTBootCamp
Ikhonkco: https://zhuanlan.zhihu.com/p/339700391
Ivela:Quora

1. Intshayelelo

I-Silicon Labs inikezele ngesisombululo + seNCP yoyilo lwesango leZigbee. Kolu lwakhiwo, umamkeli unokunxibelelana ne-NCP nge-UART okanye i-SPI interface. Okuqhelekileyo, i-UART isetyenziswa njengoko ilula kakhulu kune-SPI.

I-Silicon Labs nayo ibonelele ngeprojekthi yesampula yenkqubo yokusingatha, eyisampuliZ3GatewayHost. Isampulu iqhuba kwindlela efana ne-Unix. Abanye abathengi banokufuna isampulu yomkhosi enokuthi isebenze kwi-RTOS, kodwa ngelishwa, akukho sampuli ye-RTOS esekwe ngoku. Abasebenzisi kufuneka baphuhlise inkqubo yabo yokusingatha ngokusekelwe kwi-RTOS.

Kubalulekile ukuqonda iprothokholi yesango le-UART phambi kokuba uphuhlise inkqubo yokusingatha eyenzelwe wena. Kuzo zombini i-NCP esekwe kwi-NCP kunye ne-SPI esekelwe kwi-NCP, umamkeli usebenzisa iprothokholi ye-EZSP ukunxibelelana ne-NCP.EZSPimfutshane kuIprotokholi yothotho ye-EmberZnet, kwaye ichazwe kuyoUG100. Kwi-NCP esekwe kwi-UART, iprothokholi esezantsi iyaphunyezwa ukuthwala idatha ye-EZSP ngokuthembekileyo ngaphezulu kwe-UART, yiyo leyo.ULUTHUprotocol, mfutshane yeAsynchronous Uthotho Umamkeli. Ukufumana iinkcukacha ezithe vetshe malunga ne-ASH, nceda ujonge kuUG101kwayeUG115.

Ubudlelwane phakathi kwe-EZSP ne-ASH bunokubonakaliswa ngalo mzobo ulandelayo:

1

Ifomathi yedatha ye-EZSP kunye ne-ASH protocol ingabonakaliswa ngalo mzobo ulandelayo:

2

Kweli phepha, sizakwazisa inkqubo yokwenza isakhelo sedatha ye-UART kunye nezinye izakhelo eziphambili ezisetyenziswa rhoqo kwisango leZigbee.

2. Ukwenza isakhelo

Inkqubo eqhelekileyo yokubeka isakhelo ingabonakaliswa yile tshathi ilandelayo:

3

Kule tshathi, idatha ithetha isakhelo se-EZSP. Ngokubanzi, iinkqubo zokuqulunqa zezi: |Hayi|Inyathelo|Reference|

|:-|:-|:-|

|1|Gcwalisa isakhelo se-EZSP|UG100|

|2|Uhlengahlengiso lweDatha|Icandelo 4.3 le-UG101|

|3|Yongeza i-Control Byte|Chap2 kunye neChap3 ye UG101|

|4|Bala i-CRC|iCandelo 2.3 le-UG101|

|5|Byte Stuffing|Icandelo 4.2 le-UG101|

|6|Yongeza iflegi yokuphela|Icandelo 2.4 le-UG101|

2.1. Gcwalisa isakhelo se-EZSP

Ifomathi yesakhelo se-EZSP ibonisiwe kwiSahluko sesi-3 se-UG100.

4

Nika ingqalelo ukuba le fomati inokutshintsha xa i-SDK iphuculwa. Xa ifomathi itshintsha, siya kuyinika inombolo entsha yenguqulelo. Inombolo yenguqulo ye-EZSP yakutshanje yi-8 xa eli nqaku libhalwa (EmberZnet 6.8).

Njengoko ifomathi yesakhelo se-EZSP inokwahluka phakathi kweenguqulelo ezahlukeneyo, kukho imfuneko enyanzelekileyo yokuba umamkeli kunye ne-NCPKUFUNEKAsebenza ngohlobo olufanayo lwe-EZSP. Ngaphandle koko, abakwazi ukunxibelelana njengoko kulindelekile.

Ukufezekisa oko, umyalelo wokuqala phakathi komkhosi kunye ne-NCP kufuneka ibe ngumyalelo wenguqulo. Ngamanye amazwi, umamkeli kufuneka afumane kwakhona inguqulelo ye-EZSP ye-NCP phambi kwalo naluphi na olunye unxibelelwano. Ukuba uguqulelo lwe-EZSP lwahlukile kuguqulelo lwe-EZSP lwecala lokusingatha, unxibelelwano maluyekwe.

Imfuno engacacanga emva koku yeyokuba ifomathi yoguqulelo lomyalelo inakoUNGAZE UTSHINTSHE. Ifomathi yomyalelo wenguqulo ye-EZSP inje ngasezantsi:

5

Iinkcazo zentsimi yepharamitha kunye nefomathi yempendulo yenguqulo inokufumaneka kwi-Chap 4 ye-UG100. Indawo yepharamitha yinguqulelo ye-EZSP yenkqubo yokusingatha. Xa eli nqaku libhaliwe, ngu-8.
7
作者:TorchIoTBootCamp
umthombo: https://zhuanlan.zhihu.com/p/339700391
来源: 知乎
著作权归作者所有

2.2. Data Randomization

Inkqubo ye-randomization eneenkcukacha ichazwe kwicandelo 4.3 le-UG101. Isakhelo sonke se-EZSP siya kwenziwa ngokungakhethiyo. I-randomization ikukuphela-OKANYE isakhelo se-EZSP kunye nolandelelwano olungenamkhethe.

Ngezantsi i-algorithm yokuvelisa ulandelelwano lwe-pseudo-random.

  • irandi0 = 0×42
  • ukuba bit 0 of randi ngu0, randi+1 = randi >> 1
  • ukuba bit 0 of randi ngu 1, randi+1 = (randi >> 1) ^ 0xB8

2.3. Yongeza i-Control Byte

I-byte yolawulo yidatha ye-byte enye, kwaye kufuneka ifakwe kwintloko yesakhelo. Ifomathi iboniswe ngetheyibhile engezantsi:

6

Zizonke, kukho iindidi ezi-6 zolawulo lwee-bytes. Ezithathu zokuqala zisetyenziselwa izakhelo eziqhelekileyo ezinedatha ye-EZSP, kuquka i-DATA, i-ACK kunye ne-NAK. Ezithathu zokugqibela zisetyenziswa ngaphandle kwedatha ye-EZSP eqhelekileyo, kuquka i-RST, i-RSTACK kunye ne-ERROR.

Ubume be-RST, i-RSTACK kunye ne-ERROR zichazwe kwicandelo 3.1 ukuya ku-3.3.

2.4. Bala i-CRC

I-CRC ye-16-bit ibalwa kwii-bytes ukusuka kwi-byte yokulawula kude kube sekupheleni kwedatha. Umgangatho we-CRCCCITT (g(x) = x16 + x12 + x5 + 1) uqaliswa ku-0xFFFF. Eyona byte ibalulekileyo yandulela eyona byte ibaluleke kakhulu (imowudi ye-endian enkulu).

2.5. Byte Stuffing

Njengoko kuchaziwe kwicandelo 4.2 le-UG101, kukho amaxabiso e-byte agciniweyo asetyenziselwa injongo eyodwa. La maxabiso anokufumaneka kolu luhlu lulandelayo:

7

Xa ezi xabiso zibonakala kwisakhelo, unyango olukhethekileyo luya kwenziwa kwidatha. -Faka i-byte yokubaleka 0x7D phambi kwe-byte egciniweyo-Buyela umva i-bit5 yaloo byte egciniweyo

Ngezantsi kukho imizekelo yale algorithm:

8

2.6. Yongeza iflegi yokuphela

Isinyathelo sokugqibela kukongeza iflegi yokuphela 0x7E ukuya ekupheleni kwesakhelo. Emva koko, idatha ingathunyelwa kwi-port ye-UART.

3. Inkqubo yokususa isakhelo

Xa idatha ifunyenwe kwi-UART, kufuneka nje senze amanyathelo abuya umva ukuyicacisa.

4. Iimbekiselo


Ixesha lokuposa: Feb-08-2022
Incoko ka-WhatsApp kwi-Intanethi!