Kaituhi:TorchIoTBootCamp
Hononga: https://zhuanlan.zhihu.com/p/339700391
Mai: Quora
1. Kupu Whakataki
Kua tukuna e Silicon Labs he otinga manaaki + NCP mo te hoahoa kuaha Zigbee. I roto i tenei hoahoanga, ka taea e te kaihautu te korero ki te NCP ma te atanga UART, SPI ranei. Ko te nuinga, ka whakamahia te UART na te mea he maamaa ake i te SPI.
Kua tukuna ano e Silicon Labs tetahi kaupapa tauira mo te kaupapa manaaki, koinei te tauiraZ3GatewayHost
. Ka rere te tauira i runga i te punaha rite Unix. Kei te hiahia etahi o nga kaihoko ki tetahi tauira kaihautu ka taea te whakahaere i runga i te RTOS, engari kaore he tauira kaihautu RTOS mo tenei wa. Me whakawhanake nga kaiwhakamahi i a raatau ake kaupapa manaaki i runga i te RTOS.
He mea nui kia mohio koe ki te kawa kuaha UART i mua i te whakawhanake i tetahi kaupapa kaihautu. Mo nga NCP e rua i runga i te UART me te NCP i runga i te SPI, ka whakamahia e te kaihautu te kawa EZSP ki te korero ki te NCP.EZSPhe poto moKawa Rangatū EmberZnet, a kua tautuhia i rotoUG100. Mo te NCP e ahu mai ana i te UART, ka whakatinanahia he kawa paparanga raro hei kawe pono i nga raraunga EZSP ki runga UART, koinei teASHkawa, poto moKaihautū Rangatū Tukutahi. Mo etahi atu korero mo ASH, tirohia koaUG101aUG115.
Ko te hononga i waenga i te EZSP me te ASH ka taea te whakaatu ma te hoahoa e whai ake nei:
Ko te whakatakotoranga raraunga o te EZSP me te kawa ASH ka taea te whakaatu ma te hoahoa e whai ake nei:
I tenei wharangi, ka whakamohiohia e matou te tukanga o te hanga i nga raraunga UART me etahi papa matua e whakamahia pinepine ana ki te kuaha Zigbee.
2. Hangahanga
Ka taea te whakaatu i te mahinga anga whanui ma te tūtohi e whai ake nei:
I tenei tūtohi, ko te tikanga o te raraunga ko te anga EZSP. I te nuinga o te waa, ko nga tukanga hangahanga ko: |Kao|Taahiraa|Totorotoro|
|:-|:-|:-|
|1|Whakakiia te Tāpare EZSP|UG100|
|2|Raraunga Raraunga|Wahanga 4.3 o UG101|
|3|Taapirihia te Paita Mana|Chap2 me Chap3 o UG101|
|4|Tātaihia te CRC|Wāhanga 2.3 o UG101|
|5|Paita Paita|Wahanga 4.2 o UG101|
|6|Taapirihia te Kara Whakamutunga|Wahanga 2.4 o UG101|
2.1. Whakakiia te Tāpare EZSP
Ko te whakatakotoranga anga EZSP e whakaatuhia ana i te Wae 3 o UG100.
Kia mahara ka huri pea tenei whakatakotoranga ina whakamohoa te SDK. Ina huri te whakatakotoranga, ka hoatu e matou he nama putanga hou. Ko te nama putanga hou o EZSP ko 8 i te wa e tuhia ana tenei tuhinga (EmberZnet 6.8).
I te mea he rereke pea te whakatakotoranga anga EZSP i waenga i nga momo putanga rereke, he whakaritenga whakahau ma te kaihautu me te NCPMEmahi ki te putanga EZSP taua. Ki te kore, kare e taea e ratou te korero i runga i te whakaaro.
Hei whakatutuki i tera, ko te whakahau tuatahi i waenga i te kaihautu me te NCP me te whakahau putanga. I etahi atu kupu, me tango e te kaihautu te putanga EZSP o te NCP i mua i etahi atu korero. Mena he rereke te putanga EZSP ki te putanga EZSP o te taha kaihautu, me whakakore te korero.
Ko te hiahia nui kei muri i tenei ko te whakatakotoranga o te whakahau putanga ka taeaKAUA E HURI. Ko te whakatakotoranga whakahau putanga EZSP kei raro nei:
链接:https://zhuanlan.zhihu.com/p/339700391
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
2.2. Te Raraunga Raraunga
Ko te tukanga matapōkere taipitopito e whakaahuatia ana i te waahanga 4.3 o UG101. Ka matapōkeretia te anga EZSP katoa. Ko te matapōkeretanga ko te motuhake-OR te anga EZSP me te raupapa pseudo-tupurangi.
Kei raro ko te algorithm o te whakaputa i te raupapa pseudo-tupurangi.
- rand0 = 0×42
- Mena he 0 te moka 0 o te randi, randi+1 = randi >> 1
- mena he 1 te moka 0 o te randi, randi+1 = (randi >> 1) ^ 0xB8
2.3. Tāpirihia te Paita Mana
Ko te paita mana he raraunga paita kotahi, me tapiri ki te upoko o te anga. Ka whakaatuhia te whakatakotoranga ki te ripanga i raro nei:
Katoa, e 6 nga momo paita whakahaere. Ko nga mea tuatahi e toru e whakamahia ana mo nga papa noa me nga raraunga EZSP, tae atu ki te DATA, ACK me NAK. Ko nga mea whakamutunga e toru ka whakamahia kaore he raraunga EZSP noa, tae atu ki te RST, RSTACK me te HAPA.
Ko te whakatakotoranga o te RST, RSTACK me te HAPA e whakaahuatia ana i te waahanga 3.1 ki te 3.3.
2.4. Tātaihia te CRC
Ka tatauhia he CRC moka-16 i runga i nga paita mai i te paita mana tae noa ki te mutunga o nga raraunga. Ko te CRCCCITT paerewa (g(x) = x16 + x12 + x5 + 1) kua arawhiti ki te 0xFFFF. Ko te paita tino nui kei mua i te paita tino iti rawa (te aratau nui-endian).
2.5. Paita Whakapiri
I whakaahuahia i te waahanga 4.2 o UG101, kei reira etahi uara paita kua rahuitia mo te kaupapa motuhake. Ka kitea enei uara i te ripanga e whai ake nei:
Ina puta enei uara ki te anga, ka mahia he maimoatanga motuhake ki nga raraunga. – Whakauruhia te paita mawhiti 0x7D ki mua i te paita kua rahuitia – Whakahokia te bit5 o taua paita kua rahuitia
Kei raro nei etahi tauira o tenei algorithm:
2.6. Tāpirihia te Kara Whakamutunga
Ko te mahi whakamutunga ko te taapiri i te haki mutunga 0x7E ki te pito o te anga. I muri i tera, ka taea te tuku i nga raraunga ki te tauranga UART.
3. Tukatuka Whakakore
Ka tae mai nga raraunga mai i te UART, me mahi nga mahi whakamuri ki te wetewete.
4. Tohutoro
Wā tuku: Feb-08-2022