Ejemplo n.º 1
0
static void send_packet(handler_arg_t arg)
{
    // Set IDLE
    phy_idle(platform_phy);

    // Prepare the packet and place
    phy_prepare_packet(&tx_packet);

    // Create a payload
    tx_packet.length = snprintf((char*) tx_packet.data, PHY_MAX_TX_LENGTH,
            "Packet from %02x:%02x:%02x, count=%u", uid->uid8[9], uid->uid8[10],
            uid->uid8[11], tx_count);

    // Perform a CCA
    int32_t cca;
    phy_cca(platform_phy, &cca);

    if (cca)
    {
        // Channel is clear
        // Send
        phy_tx_now(platform_phy, &tx_packet, tx_done);
        printf("Sending Packet, count=%u\n", tx_count);

        // Increment counter
        tx_count++;
    }
    else
    {
        printf("TX aborted, channel is busy\n");
        enter_rx(NULL);
    }
}
Ejemplo n.º 2
0
/*judge whether the channel is idle */
static bool_t channel_is_idle(void)
{
    return phy_cca();
}