Exemple #1
0
/*!
    \brief Entering raw Transmitter\Receiver mode in order to send raw data
           over the WLAN PHY

    This function shows how to send raw data, in this case ping packets over
    the air in transmitter mode.

    \param[in]      Channel - number on which the data will be sent
    \param[in]      rate    - Rate for tx
    \param[in]      numberOfPackets - packets to be send
    \param[in]      interval - interval between each packet, should be greater
                    than 50ms.

    \return         0 for success, -ve otherwise

    \warning        We must be disconnected from WLAN AP in order to succeed
                    changing to transmitter mode
*/
static _i32 TxContinues(_i16 channel, SlRateIndex_e rate,
                        _u16 numberOfPackets, DWORD interval)
{
    _i16 sd = -1;
    _i16 len = -1;
    _u32 retVal = -1;

    sd = sl_Socket(SL_AF_RF, SL_SOCK_RAW, channel);
    if(sd < 0)
    {
        printf("Error In Creating the Socket\n");
        ASSERT_ON_ERROR(sd);
    }

    printf("Transmitting pinging data...\n");
    len = sizeof(RawData_Ping);
    while(numberOfPackets > 0)
    {
        retVal = sl_Send(sd, RawData_Ping, len,
                         SL_RAW_RF_TX_PARAMS(channel, rate, POWER_LEVEL_TONE, PREAMBLE));
        ASSERT_ON_ERROR(retVal);

        Sleep(interval);
        numberOfPackets--;
    }
    printf("Transmitting complete.\n");

    retVal = sl_Close(sd);
    ASSERT_ON_ERROR(retVal);

    return SUCCESS;
}
Exemple #2
0
//*****************************************************************************
//
//! Tx_continuous
//!
//! This function
//!        1. Function for sending out pinging data on the
//!                channel given by the user.
//!
//! \return none
//
//*****************************************************************************
static int Tx_continuous(int iChannel,SlRateIndex_e rate,int iNumberOfPackets,
                                    int iTxPowerLevel,long dIntervalMiliSec)
{
    int iSoc;
    long lRetVal = -1;
    long ulIndex;

    iSoc = sl_Socket(SL_AF_RF,SL_SOCK_RAW,iChannel);
    ASSERT_ON_ERROR(iSoc);

    UART_PRINT("Transmitting data...\r\n");
    for(ulIndex = 0 ; ulIndex < iNumberOfPackets ; ulIndex++)
    {
        lRetVal = sl_Send(iSoc,RawData_Ping,sizeof(RawData_Ping),\
                   SL_RAW_RF_TX_PARAMS(iChannel,  rate, iTxPowerLevel, PREAMBLE));
        if(lRetVal < 0)
        {
            sl_Close(iSoc);
            ASSERT_ON_ERROR(lRetVal);
        }
        //Sleep(dIntervalMiliSec);
        MAP_UtilsDelay(4000000);
    }

    lRetVal = sl_Close(iSoc);
    ASSERT_ON_ERROR(lRetVal);

    UART_PRINT("Transmission complete.\r\n");
    return SUCCESS;
}