Hello everybody
I am trying to do a active scan and I have tried different methods without success.
First at all, I am using the sample Application and I would like to use the DemoB - Pro device, because after the scan I will decide if the device is a coordinator or end device.
First I have tried with ZmacScanReq. I can see the other device when it is debugging (in zmac_cb.c event MAC_MLME_SCAN_CNF) but I do not know how to get the information and/or register the event. I think the event go to the NWK layer but not to my application. The same happens with MAC_MlmeScanReq.
I have also tried with ZDP_MgmtNwkDiscReq and the following configuration:
afStatus_t scanResult;
zAddrType_t destAddr;
uint32 ScanChannels = 0x07FFF800;
byte ScanDuration = BEACON_ORDER_30_MSEC;
byte StartIndex=0x00;
byte SecurityEnable = 0;
destAddr.addrMode = Addr16Bit;
destAddr.addr.shortAddr = 0xFFFF; // Coordinator
scanResult = ZDP_MgmtNwkDiscReq(&destAddr,ScanChannels,ScanDuration,StartIndex,SecurityEnable);
I have register the event: ZDO_RegisterForZDOMsg( SampleApp_TaskID, Mgmt_NWK_Disc_req ) and set the flags ZDO_MGMT_NWKDISC_REQUEST &
ZDO_MGMT_NWKDISC_RESPONSE in the devices.
But when the device has not started the network, always scanResult= 0xc2 (ZNwkInvalidRequest??) and in the other case, scanResult = afStatus_SUCCESS the application never receives a message and the application does not pass through zmac_cb.c, so I cannot see if it detects the other device.
And finally, I have tried with NLME_NwkDiscReq2:
ZStatus_t scanResult;
NLME_ScanFields_t scanDef;
scanDef.channels = 0x07FFF800;
scanDef.duration = BEACON_ORDER_30_MSEC;
scanDef.scanType = ZMAC_ACTIVE_SCAN;
scanDef.scanApp = NLME_DISC_SCAN;
scanResult = NLME_NwkDiscReq2( &scanDef );
With this method I cannot see the other device and I do not know if I have to register an event or when to call ZDO_NetworkDiscoveryConfirmCB(), I have a timer (9 Sec) but I do not get any device =(
I am absolutely lost, so If someone can help me or tell me what I am doing wrong or where I can get more information, it would be really great!!
Thanks a lot
Jeimy