Example #1
0
int
cc2420_send_data_ack(u16_t mac)
{
  struct hdr_802_15 h;

  PRINTF("send_data_ack to %u.%u\n", mac & 0xff, mac >> 8);

  h.len = MAC_HDR_LEN + 2; /* Including footer[2]. */
  h.fc0 = FC0_TYPE_DATA | FC0_INTRA_PAN;
  h.fc1 = FC1_DST_16 | FC1_SRC_16;

  h.src = uip_hostaddr.u16[1];
  h.dst = mac;

  return cc2420_send(&h, 10, NULL, 0);
}
Example #2
0
/*
 * @brief Sends a radio packet to the receiver
 *
 * @param t     The transceiver device
 * @param pkt   Generic pointer to the packet (use ieee802154_packet_t for
 *              AT86RF231, CC2420, and MC1322X)
 *
 * @return A negative value if operation failed, 0 or the number of bytes sent otherwise.
 */
static int8_t send_packet(transceiver_type_t t, void *pkt)
{
    int8_t res = -1;
#if MODULE_AT86RF231 || MODULE_CC2420 || MODULE_MC1322X
    ieee802154_packet_t *p = (ieee802154_packet_t *)pkt;
    DEBUG("transceiver: Send packet to ");
#if ENABLE_DEBUG

    for (size_t i = 0; i < 8; i++) {
        printf("%02x ", p->frame.dest_addr[i]);
    }

    printf("\n");
#endif
#else
    radio_packet_t *p = (radio_packet_t *)pkt;
    DEBUG("transceiver: Send packet to %" PRIu16 "\n", p->dst);
    for (size_t i = 0; i < p->length; i++) {
        DEBUG("%02x ", p->data[i]);
    }

    DEBUG("\n");
#endif

#if (defined(MODULE_CC110X) || defined(MODULE_CC110X_LEGACY))
    cc110x_packet_t cc110x_pkt;
#endif
#ifdef MODULE_MC1322X
    maca_packet_t *maca_pkt = maca_get_free_packet();
#endif

#ifdef MODULE_CC2420
    cc2420_packet_t cc2420_pkt;
#endif

#ifdef MODULE_AT86RF231
    at86rf231_packet_t at86rf231_pkt;
#endif

    switch (t) {
        case TRANSCEIVER_CC1100:
#if (defined(MODULE_CC110X) || defined(MODULE_CC110X_LEGACY))
            cc110x_pkt.length = p->length + CC1100_HEADER_LENGTH;
            cc110x_pkt.address = p->dst;
            cc110x_pkt.flags = 0;
            memcpy(cc110x_pkt.data, p->data, p->length);
            res = cc110x_send(&cc110x_pkt);
#elif MODULE_CC110X_LEGACY_CSMA
            memcpy(cc1100_pkt, p->data, p->length);

            res = cc1100_send_csmaca(p->dst, 4, 0, (char *) cc1100_pkt, p->length);
            DEBUG("transceiver: snd_ret (%u) = %i\n", p->length, res);
#else
            puts("Unknown transceiver");
#endif
            break;
#ifdef MODULE_CC2420

        case TRANSCEIVER_CC2420:
            memcpy(&cc2420_pkt.frame, &p->frame, sizeof(ieee802154_frame_t));
            cc2420_pkt.length = p->frame.payload_len + IEEE_802154_FCS_LEN;
            res = cc2420_send(&cc2420_pkt);
            break;
#endif
#ifdef MODULE_MC1322X

        case TRANSCEIVER_MC1322X:
            maca_pkt->length = p->length;
            memcpy(maca_pkt->data, &p->frame, p->length);
            maca_set_tx_packet(maca_pkt);
            res = 1;
            break;
#endif
#ifdef MODULE_NATIVENET

        case TRANSCEIVER_NATIVE:
            res = nativenet_send(p);
            break;
#endif
#ifdef MODULE_AT86RF231

        case TRANSCEIVER_AT86RF231:
            memcpy(&at86rf231_pkt.frame, &p->frame, sizeof(ieee802154_frame_t));
            at86rf231_pkt.length = p->frame.payload_len + IEEE_802154_FCS_LEN;
            res = at86rf231_send(&at86rf231_pkt);
            break;
#endif

        default:
            puts("Unknown transceiver");
            break;
    }

    return res;
}
Example #3
0
static int _send(netdev_t *netdev, const iolist_t *iolist)
{
    cc2420_t *dev = (cc2420_t *)netdev;
    return (int)cc2420_send(dev, iolist);
}
Example #4
0
static int _send(netdev2_t *netdev, const struct iovec *vector, int count)
{
    cc2420_t *dev = (cc2420_t *)netdev;
    return (int)cc2420_send(dev, vector, count);
}