Esempio n. 1
0
void zg_scan_start()
{
	scan_cnt = 0;
    tZGScanReq* ptr = (tZGScanReq*)&zg_buf[3];

    zg_buf[0] = ZG_CMD_WT_FIFO_MGMT;
    zg_buf[1] = ZG_MAC_TYPE_MGMT_REQ;
    zg_buf[2] = ZG_MAC_SUBTYPE_MGMT_SCAN;

    // Number of usec to delay before transmitting a probe
    // request following the channel change event
    ptr->probeDelay = ( uint16_t ) HSTOZGS( ( uint16_t ) 20);
    // the minimum time to spend on each channel in units
    // of TU (1024 usec)
    ptr->minChannelTime = ( uint16_t ) HSTOZGS(( uint16_t ) 400);
    // Maximum time to spend on each channel in units
    // of TU (1024 usec)
    ptr->maxChannelTime = ( uint16_t ) HSTOZGS( ( uint16_t ) 800);
    // Bssid to restrict the scan too. Or ff:ff:ff:ff:ff:ff
    // to not restrict the scan by bssid
    ptr->bssid[0] = 0xFF;
    ptr->bssid[1] = 0xFF;
    ptr->bssid[2] = 0xFF;
    ptr->bssid[3] = 0xFF;
    ptr->bssid[4] = 0xFF;
    ptr->bssid[5] = 0xFF;
    // Type of networks to be scanned. 1==Infrastructure, 2==Ad-hoc, 3==Any
    ptr->bss = 3;
    // Scan Type. 1==Active (probe requests), 2==Passive (just listens)
    ptr->snType = 1;
    // set ssid length to 0 to do discovery scan
    ptr->ssidLen = 0;
    // State based scan only scans a single channel at a time
    ptr->chnlLen = 11;
    // Zero-terminated list of channels to scan
    //ptr->channelList[0] = 3;
    //ptr->channelList[1] = 6;
    //ptr->channelList[2] = 11;
    //ptr->channelList[3] = 0;
    uint8_t b;
    for ( b=0; b<11; b++ ){
        ptr->channelList[b] = b+1;
    }
    ptr->channelList[13] = 0;
    // Actually send command to zg2100 over SPI
    spi_transfer( zg_buf, 65, 1 );

    zg_buf[0] = ZG_CMD_WT_FIFO_DONE;
    spi_transfer(zg_buf, 1, 1);

    //zg_drv_state = DRV_STATE_IDLE;
}
Esempio n. 2
0
tZGU8
adHocConnRequest( void * const ptrRequest, tZGVoidInput *appOpaquePtr)
{
    tZGAdhocConnectReqPtr ptrConn = (tZGAdhocConnectReqPtr)ptrRequest;

    ptrConn->timeout = HSTOZGS( (tZGU16) 50);            /* *10 msec */
    ptrConn->beaconPrd = HSTOZGS( (tZGU16) 100);
    ptrConn->channel = APPCXT.bssDesc.channel;           /* Use the channel found in scan */
    memcpy( (void *) ptrConn->bssid, (const void *) APPCXT.bssDesc.bssid, kZGMACAddrLen);

    ptrConn->ssidLen = ZG_SSID_LEN();
    memcpy( (void *) ptrConn->ssid, (const void *) ZG_GET_SSID(), ptrConn->ssidLen);

    ZG_PUTRSUART("Connect ...\n\r");

    return ( sizeof(tZGAdhocConnectReq) );
}
Esempio n. 3
0
tZGU8
adHocDisconnRequest( void * const ptrRequest, tZGVoidInput *appOpaquePtr)
{
    tZGDisconnectReqPtr ptrDisconn = (tZGDisconnectReqPtr)ptrRequest;

    ptrDisconn->reasonCode = HSTOZGS( (tZGU16) 1);   /* 1: "Unspecified", 3: "STA left BSS and is deauthenticated" */
    ptrDisconn->disconnect = 1;                      /* Upon completion, MAC shall enter (0) joined state (1) idle state */
    ptrDisconn->txFrame = 0;                         /* MAC shall (0) do nothing, or (1) tx a deauth frame */

    ZG_PUTRSUART("Disconnect...\n\r");

    APPCXT.bConnected = kZGBoolFalse;
    APPCXT.FSM.bSilent =  kZGBoolFalse;

    return ( sizeof(tZGDisconnectReq) );

}
Esempio n. 4
0
tZGU8
adHocStartRequest( void * const ptrRequest, tZGVoidInput *appOpaquePtr)
{
    tZGAdhocStartReqPtr ptrStart = (tZGAdhocStartReqPtr)ptrRequest;

    /* choose the first channel in ordered list for network start */
    if ( ZG_GET_ACTIVE_CHANNELS() == 0u )
    {
        ZGSYS_MODULE_ASSERT(1, (ROM FAR char *)"Adhoc StartReq: empty channel list\n\r");
    }
    else
        ptrStart->channel = ZG_CHANNEL(0);

    ptrStart->beaconPrd = HSTOZGS( (tZGU16) 100);
    ptrStart->capInfo[0] = kZGAdhocMgrCapBitIbss; /* was | kZGAdhocMgrCapBitShortPreamble;  0x22 */

    /* If in WEP mode, set the corresponding bit. */
    if ( ZG_GET_ENC_TYPE() == (tZGU8)kKeyTypeWep )
    {
        ptrStart->capInfo[0] = ptrStart->capInfo[0] | kZGAdhocMgrCapBitPrivacy;
    }

    ptrStart->capInfo[1] = 0;
    ptrStart->ssidLen = ZG_SSID_LEN();
    memcpy( (void *) ptrStart->ssid, (const void*) ZG_GET_SSID(), ptrStart->ssidLen);

    /* These values are part of the adhoc network beacon */
    /* and are part of the "basic rate" set, not to be */
    /* confused with supported rate set */
    ptrStart->dataRateLen = 2;
    ptrStart->dataRates[0] = 0x82; /* 1Mbps */
    ptrStart->dataRates[1] = 0x84; /* 2Mbps */

    ZG_PUTRSUART("Start ...\n\r");

    return ( sizeof(tZGAdhocStartReq) );
}