Umwanditsi : TorchIoTBootCamp
Ihuza : https: //zhuanlan.zhihu.com/p/339700391
Kuva : Quora
1. Intangiriro
Silicon Labs yatanze umushyitsi + NCP igisubizo cyo gushushanya amarembo ya Zigbee. Muri ubu bwubatsi, uwakiriye ashobora kuvugana na NCP binyuze muri UART cyangwa SPI. Mubisanzwe, UART ikoreshwa nkuko byoroshye cyane kuruta SPI.
Silicon Labs nayo yatanze icyitegererezo cyumushinga wakiriye, nicyitegererezoZ3GatewayHost
. Icyitegererezo gikora kuri sisitemu isa na Unix. Abakiriya bamwe bashobora kwifuza icyitegererezo cyakirwa kuri RTOS, ariko ikibabaje ni uko nta cyitegererezo cya RTOS gishingiye kuri ubu. Abakoresha bakeneye guteza imbere gahunda yabo yo kubakira ishingiye kuri RTOS.
Ni ngombwa gusobanukirwa protokole ya UART mbere yo gutegura progaramu yihariye. Kuri UART ishingiye kuri NCP na SPI ishingiye kuri NCP, uwakiriye akoresha protocole ya EZSP kugirango avugane na NCP.EZSPni ngufi kuriPorokireri ya EmberZnet, kandi byasobanuwe muriUG100. Kuri UART ishingiye kuri NCP, protocole yo hasi yashyizwe mubikorwa kugirango itware EZSP amakuru yizewe hejuru ya UART, nibyoASHprotocole, ngufi kuriIkirangantego gikurikirana. Kubindi bisobanuro bijyanye na ASH, nyamuneka rebaUG101naUG115.
Isano iri hagati ya EZSP na ASH irashobora kugaragazwa nigishushanyo gikurikira:
Imiterere yamakuru ya EZSP na protocole ya ASH irashobora kugereranwa nigishushanyo gikurikira:
Kuriyi page, tuzamenyekanisha inzira yo gushiraho amakuru ya UART hamwe namakadiri yingenzi akoreshwa kenshi mumarembo ya Zigbee.
2
Igikorwa rusange cyo gushushanya gishobora kugaragazwa nimbonerahamwe ikurikira:
Muri iyi mbonerahamwe, amakuru asobanura ikadiri ya EZSP. Muri rusange, uburyo bwo gutegura ni: | Oya | Intambwe | Reba |
|: - |: - |: - |
| 1 | Uzuza Ikadiri ya EZSP | UG100 |
| 2 | Guhindura amakuru | Igice cya 4.3 cya UG101 |
| 3 | Ongeraho Igenzura Byte | Chap2 na Chap3 ya UG101 |
| 4 | Kubara CRC | Igice cya 2.3 cya UG101 |
| 5 | Ibintu bya Byte | Igice cya 4.2 cya UG101 |
| 6 | Ongeraho Ibendera ryanyuma | Igice cya 2.4 cya UG101 |
2.1. Uzuza ikadiri ya EZSP
Imiterere ya EZSP imiterere igaragara mugice cya 3 cya UG100.
Witondere ko iyi format ishobora guhinduka mugihe SDK izamuye. Iyo imiterere ihindutse, tuzayiha nimero nshya. Umubare wa verisiyo ya EZSP iheruka ni 8 mugihe iyi ngingo yanditse (EmberZnet 6.8).
Nka format ya EZSP imiterere ishobora kuba itandukanye hagati yuburyo butandukanye, hari itegeko risabwa ko nyiricyubahiro na NCPTugombakora hamwe na verisiyo imwe ya EZSP. Bitabaye ibyo, ntibashobora kuvugana nkuko byari byitezwe.
Kugirango ubigereho, itegeko ryambere hagati ya host na NCP rigomba kuba verisiyo ya verisiyo. Muyandi magambo, uwakiriye agomba kugarura verisiyo ya EZSP ya NCP mbere yandi makuru yose. Niba verisiyo ya EZSP itandukanye na EZSP verisiyo yakiriye, itumanaho rigomba kuvaho.
Ibisabwa bidasubirwaho inyuma yibi nuko imiterere ya verisiyo ya command ishoboraNTIMUHINDURE. Imiterere ya verisiyo ya EZSP ni nkiyi hepfo:
链接: https: //zhuanlan.zhihu.com/p/339700391
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
2.2. Kumenyekanisha amakuru
Uburyo burambuye bwo gutoranya ibintu byasobanuwe mu gice cya 4.3 cya UG101. Ikadiri yose ya EZSP izahinduka. Guhitamo ni ukwihariye-CYANGWA EZSP ikadiri na pseudo-random.
Hasi ni algorithm yo kubyara pseudo-random.
- rand0 = 0 × 42
- niba bit 0 ya randi ari 0, randi + 1 = randi >> 1
- niba bit 0 ya randi ari 1, randi + 1 = (randi >> 1) ^ 0xB8
2.3. Ongeraho Igenzura Byte
Igenzura byte ni imwe ya byte data, kandi igomba kongerwaho kumutwe wikadiri. Imiterere igaragazwa nimbonerahamwe ikurikira:
Ubwose, hari ubwoko 6 bwo kugenzura bytes. Bitatu byambere bikoreshwa kumurongo usanzwe hamwe namakuru ya EZSP, harimo DATA, ACK na NAK. Bitatu byanyuma bikoreshwa nta makuru ya EZSP asanzwe, harimo RST, RSTACK na ERROR.
Imiterere ya RST, RSTACK na ERROR yasobanuwe mu gice cya 3.1 kugeza 3.3.
2.4. Kubara CRC
CRC ya 16-biti ibarwa kuri bytes kuva kugenzura byte kugeza iherezo ryamakuru. Bisanzwe CRCCCITT (g (x) = x16 + x12 + x5 + 1) yatangijwe kuri 0xFFFF. Byte byingenzi byte ibanziriza byibuze byte (uburyo bunini bwa endian).
2.5. Byte Ibintu
Nkuko byasobanuwe mu gice cya 4.2 cya UG101, hari bimwe byabitswe byte agaciro gakoreshwa kubintu byihariye. Indangagaciro zishobora kuboneka mu mbonerahamwe ikurikira:
Mugihe izo ndangagaciro zigaragara murwego, ubuvuzi budasanzwe buzakorerwa amakuru. - Shyiramo guhunga byte 0x7D imbere ya byte yabitswe - Hindura bit5 yiyo byte yabitswe
Hano hari ingero zimwe ziyi algorithm:
2.6. Ongeraho Ibendera ryanyuma
Intambwe yanyuma nukwongeramo ibendera ryanyuma 0x7E kumpera yikadiri. Nyuma yibyo, amakuru arashobora koherezwa ku cyambu cya UART.
3. Gutegura inzira
Iyo amakuru yakiriwe muri UART, dukeneye gukora intambwe zinyuranye kugirango tuyifate.
4. Reba
Igihe cyo kohereza: Gashyantare-08-2022