@@ -7,9 +7,10 @@ import { SpinelCommandId } from "../src/spinel/commands";
7
7
import { SpinelPropertyId } from "../src/spinel/properties" ;
8
8
import { SPINEL_HEADER_FLG_SPINEL , encodeSpinelFrame } from "../src/spinel/spinel" ;
9
9
import { SpinelStatus } from "../src/spinel/statuses" ;
10
- import { MACAssociationStatus , decodeMACFrameControl , decodeMACHeader } from "../src/zigbee/mac" ;
10
+ import { MACAssociationStatus , type MACHeader , decodeMACFrameControl , decodeMACHeader } from "../src/zigbee/mac" ;
11
11
import { ZigbeeConsts } from "../src/zigbee/zigbee" ;
12
12
import { type ZigbeeNWKLinkStatus , ZigbeeNWKManyToOne , ZigbeeNWKStatus } from "../src/zigbee/zigbee-nwk" ;
13
+ import type { ZigbeeNWKGPHeader } from "../src/zigbee/zigbee-nwkgp" ;
13
14
import {
14
15
A_CHANNEL ,
15
16
A_EUI64 ,
@@ -546,40 +547,72 @@ describe("OT RCP Driver", () => {
546
547
const onStreamRawFrameSpy = vi . spyOn ( driver , "onStreamRawFrame" ) ;
547
548
const onZigbeeAPSACKRequestSpy = vi . spyOn ( driver , "onZigbeeAPSACKRequest" ) ;
548
549
const onZigbeeAPSFrameSpy = vi . spyOn ( driver , "onZigbeeAPSFrame" ) ;
549
- const processZigbeeNWKGPCommandFrameSpy = vi . spyOn ( driver , "processZigbeeNWKGPCommandFrame " ) ;
550
+ const processZigbeeNWKGPDataFrameSpy = vi . spyOn ( driver , "processZigbeeNWKGPDataFrame " ) ;
550
551
551
552
driver . parser . _transform ( makeSpinelStreamRaw ( 1 , NETDEF_ZGP_COMMISSIONING ) , "utf8" , ( ) => { } ) ;
552
553
await vi . runOnlyPendingTimersAsync ( ) ;
553
554
555
+ const expectedMACHeader : MACHeader = {
556
+ frameControl : {
557
+ frameType : 0x1 ,
558
+ securityEnabled : false ,
559
+ framePending : false ,
560
+ ackRequest : false ,
561
+ panIdCompression : false ,
562
+ seqNumSuppress : false ,
563
+ iePresent : false ,
564
+ destAddrMode : 0x2 ,
565
+ frameVersion : 0 ,
566
+ sourceAddrMode : 0x0 ,
567
+ } ,
568
+ sequenceNumber : 70 ,
569
+ destinationPANId : 0xffff ,
570
+ destination16 : 0xffff ,
571
+ destination64 : undefined ,
572
+ sourcePANId : 0xffff ,
573
+ source16 : undefined ,
574
+ source64 : undefined ,
575
+ auxSecHeader : undefined ,
576
+ superframeSpec : undefined ,
577
+ gtsInfo : undefined ,
578
+ pendAddr : undefined ,
579
+ commandId : undefined ,
580
+ headerIE : undefined ,
581
+ frameCounter : undefined ,
582
+ keySeqCounter : undefined ,
583
+ fcs : 0xffff ,
584
+ } ;
585
+ const expectedNWKGPHeader : ZigbeeNWKGPHeader = {
586
+ frameControl : {
587
+ frameType : 0x0 ,
588
+ protocolVersion : 3 ,
589
+ autoCommissioning : false ,
590
+ nwkFrameControlExtension : false ,
591
+ } ,
592
+ frameControlExt : undefined ,
593
+ sourceId : 0x0155f47a ,
594
+ endpoint : undefined ,
595
+ securityFrameCounter : undefined ,
596
+ micSize : 0 ,
597
+ payloadLength : 52 ,
598
+ mic : undefined ,
599
+ } ;
600
+
554
601
expect ( onStreamRawFrameSpy ) . toHaveBeenCalledTimes ( 1 ) ;
555
602
expect ( onZigbeeAPSACKRequestSpy ) . toHaveBeenCalledTimes ( 0 ) ;
556
603
expect ( onZigbeeAPSFrameSpy ) . toHaveBeenCalledTimes ( 0 ) ;
557
- expect ( processZigbeeNWKGPCommandFrameSpy ) . toHaveBeenCalledTimes ( 1 ) ;
604
+ expect ( processZigbeeNWKGPDataFrameSpy ) . toHaveBeenCalledTimes ( 1 ) ;
558
605
expect ( emitSpy ) . toHaveBeenCalledWith (
559
- "frame" ,
560
- 0x0155f47a & 0xffff ,
561
- undefined ,
562
- {
563
- frameControl : {
564
- frameType : 0x1 ,
565
- deliveryMode : 0x2 ,
566
- ackFormat : false ,
567
- security : false ,
568
- ackRequest : false ,
569
- extendedHeader : false ,
570
- } ,
571
- group : ZigbeeConsts . GP_GROUP_ID ,
572
- profileId : ZigbeeConsts . GP_PROFILE_ID ,
573
- clusterId : ZigbeeConsts . GP_CLUSTER_ID ,
574
- destEndpoint : ZigbeeConsts . GP_ENDPOINT ,
575
- sourceEndpoint : ZigbeeConsts . GP_ENDPOINT ,
576
- } ,
606
+ "gpFrame" ,
607
+ 0xe0 ,
577
608
Buffer . from ( [
578
- 1 , 70 , 4 , 0 , 0 , 122 , 244 , 85 , 1 , 0 , 0 , 0 , 0 , 0xe0 , 51 , 0x2 , 0x85 , 0xf2 , 0xc9 , 0x25 , 0x82 , 0x1d , 0xf4 , 0x6f , 0x45 , 0x8c , 0xf0 ,
579
- 0xe6 , 0x37 , 0xaa , 0xc3 , 0xba , 0xb6 , 0xaa , 0x45 , 0x83 , 0x1a , 0x11 , 0x46 , 0x23 , 0x0 , 0x0 , 0x4 , 0x16 , 0x10 , 0x11 , 0x22 , 0x23 , 0x18 ,
580
- 0x19 , 0x14 , 0x15 , 0x12 , 0x13 , 0x64 , 0x65 , 0x62 , 0x63 , 0x1e , 0x1f , 0x1c , 0x1d , 0x1a , 0x1b , 0x16 , 0x17 ,
609
+ 0x2 , 0x85 , 0xf2 , 0xc9 , 0x25 , 0x82 , 0x1d , 0xf4 , 0x6f , 0x45 , 0x8c , 0xf0 , 0xe6 , 0x37 , 0xaa , 0xc3 , 0xba , 0xb6 , 0xaa , 0x45 , 0x83 , 0x1a ,
610
+ 0x11 , 0x46 , 0x23 , 0x0 , 0x0 , 0x4 , 0x16 , 0x10 , 0x11 , 0x22 , 0x23 , 0x18 , 0x19 , 0x14 , 0x15 , 0x12 , 0x13 , 0x64 , 0x65 , 0x62 , 0x63 , 0x1e ,
611
+ 0x1f , 0x1c , 0x1d , 0x1a , 0x1b , 0x16 , 0x17 ,
581
612
] ) ,
582
- 0 , // rssi
613
+ expectedMACHeader ,
614
+ expectedNWKGPHeader ,
615
+ 0 ,
583
616
) ;
584
617
} ) ;
585
618
} ) ;
0 commit comments