Example #1
0
int test_wrong_set_channel(uint8_t channel)
{
    if (at86rf231_set_channel(channel) != 0) {
        printf("Channel %d should yield error -1.\n", channel);
        return 0;
    }
    return 1;
}
Example #2
0
int test_right_set_channel(void)
{
    uint8_t channel = at86rf231_get_channel();

    if (channel == 26) {
        channel = 11;
    }
    else {
        channel++;
    }

    if (at86rf231_set_channel(channel) == 0) {
        printf("Channel %d should not yield error -1.\n", channel);
        return 0;
    }
    return 1;
}
Example #3
0
/*
 * @brief Sets the radio channel for any transceiver device
 *
 * @param t         The transceiver device
 * @param channel   The channel to be set
 *
 * @return The radio channel AFTER calling the set command, -1 on error
 */
static int32_t set_channel(transceiver_type_t t, void *channel)
{
    /* cppcheck: c is read depending on enabled modules */
    /* cppcheck-suppress unreadVariable */
    uint8_t c = *((uint8_t *)channel);

    switch (t) {
        case TRANSCEIVER_CC1100:
#if (defined(MODULE_CC110X) || defined(MODULE_CC110X_LEGACY))
            return cc110x_set_channel(c);
#elif MODULE_CC110X_LEGACY_CSMA
            return cc1100_set_channel(c);
#else
            return -1;
#endif
#ifdef MODULE_CC2420

        case TRANSCEIVER_CC2420:
            return cc2420_set_channel(c);
#endif
#ifdef MODULE_MC1322X

        case TRANSCEIVER_MC1322X:
            maca_set_channel(c);
            return c; ///< TODO: should be changed!implement get channel
#endif
#ifdef MODULE_NATIVENET

        case TRANSCEIVER_NATIVE:
            return nativenet_set_channel(c);
#endif
#ifdef MODULE_AT86RF231

        case TRANSCEIVER_AT86RF231:
            return at86rf231_set_channel(c);
#endif

        default:
            return -1;
    }
}