Beispiel #1
0
/**
 * @brief Application task handler
 */
static void app_task(void)
{
    uint8_t number_of_bytes_to_be_transmitted;
	uint8_t stop_data;
   if(Wireshark_Settings == INIT_STATE)
   {
        uint8_t input_channel = sio_getchar();
        sniffer_config_select(CHANNEL_SELECT_ID,input_channel);
        Wireshark_Settings = SET_START;
   }

   if(Wireshark_Settings == SET_START)
   {
        number_of_bytes_to_be_transmitted = sio_getchar();
        if(number_of_bytes_to_be_transmitted == 0x01)
        {
           sniffer_config_select(START_CAPTURE_ID,number_of_bytes_to_be_transmitted);
           Wireshark_Settings = WS_RESTART;
           sio_rx_data[0] = INIT_VALUE;
        }
   }

   if(Wireshark_Settings == WS_RESTART)
   {
        number_of_bytes_to_be_transmitted = pal_sio_rx(SIO_CHANNEL, sio_rx_data, 1);
        if((number_of_bytes_to_be_transmitted  == 1) && (sio_rx_data[0] == 0x02))
        {
                sio_rx_data[0] = INIT_VALUE;
                Wireshark_Settings = INIT_STATE;
                stop_data = STOP_CAP;
                while((number_of_bytes_to_be_transmitted = pal_sio_tx(SIO_CHANNEL, &stop_data, 1)) !=1);
        }
   }
}
Beispiel #2
0
/**
 * @brief Application task
 */
static void app_task(void)
{
    uint8_t number_of_bytes_to_be_transmitted;

    if (tx_state == TX_IDLE)
    {
        number_of_bytes_to_be_transmitted = pal_sio_rx(SIO_CHANNEL, sio_rx_data, MAX_APP_DATA_LENGTH);

        // If bytes are received via UART/USB, transmit the bytes.
        if (number_of_bytes_to_be_transmitted > 0)
        {
            pal_led(LED_START, LED_TOGGLE);        // indicate data processing
            tx_state = TX_ONGOING;

            tx_buffer[PL_POS_SEQ_NUM]++;

            /* Check for maximum allowed IEEE 802.15.4 frame length. */
            if (number_of_bytes_to_be_transmitted > aMaxMACSafePayloadSize)
            {
                number_of_bytes_to_be_transmitted = aMaxMACSafePayloadSize;
            }

            /* Update mpdu length within frame. */
            tx_buffer[0] = number_of_bytes_to_be_transmitted + FRAME_OVERHEAD;

            /* Copy MSDU (actual MAC payload) into frame. */
            /*
             * Note: Usually the MSDU is copied beginning from the end of
             * the frame. Since the header is always the same for this
             * application, the start of the MSDU is always the same position.
             * Therefore the payload copying is done from the beginning.
             */
            memcpy(&tx_buffer[LENGTH_FIELD_LEN + FRAME_OVERHEAD  - FCS_LEN],
                    sio_rx_data,
                    number_of_bytes_to_be_transmitted);

            tal_tx_frame(tx_buffer, CSMA_UNSLOTTED, true);
        }
    }
    else if (tx_state == TX_RETRY)
    {
        tx_state = TX_ONGOING;

        /* Retransmit the previous frame until frame transmission was successful. */
        tal_tx_frame(tx_buffer, CSMA_UNSLOTTED, true);
    }
}