示例#1
0
文件: main.c 项目: AnonMall/RIOT
static void riot_ccn_transceiver_start(kernel_pid_t _relay_pid)
{
    transceiver_init(TRANSCEIVER);
    int transceiver_pid = transceiver_start();
    DEBUG("transceiver on thread_id %d...\n", transceiver_pid);

    /* register for transceiver events */
    uint8_t reg = transceiver_register(TRANSCEIVER, _relay_pid);
    if (reg != 1) {
        DEBUG("transceiver register failed\n");
    }

    /* set channel to CCNL_CHAN */
    msg_t mesg;
    transceiver_command_t tcmd;
    int32_t c = CCNL_DEFAULT_CHANNEL;
    tcmd.transceivers = TRANSCEIVER;
    tcmd.data = &c;
    mesg.content.ptr = (char *) &tcmd;
    mesg.type = SET_CHANNEL;
    msg_send_receive(&mesg, &mesg, transceiver_pid);
    if (c == -1) {
        puts("[transceiver] Error setting/getting channel");
    }
    else {
        printf("[transceiver] Got channel: %" PRIi32 "\n", c);
    }
}
示例#2
0
文件: main.c 项目: benpicco/RIOT-old
int main(void) {
    int radio_pid;
    uint8_t i;
    for (i = 0; i < SND_BUFFER_SIZE; i++) { 
        memset(snd_buffer[i], i, CC1100_MAX_DATA_LENGTH);
    }
    thread_create(shell_stack_buffer, SHELL_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, shell_runner, "shell");
    radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio");
    transceiver_init(TRANSCEIVER_CC1100);
    transceiver_start();
    transceiver_register(TRANSCEIVER_CC1100, radio_pid);
    sender(NULL);

    printf("Config:\n");
    printf("\tid: %u\n", sysconfig.id);
    printf("\taddr: %u\n", sysconfig.radio_address);
    printf("\tchannel: %u\n", sysconfig.radio_channel);
   
   while (1) {
       extern void thread_print_all(void);
       thread_print_all();
       print_buffer(NULL);
       hwtimer_wait(50000);
   }
}
示例#3
0
文件: mac.c 项目: fjrk/RIOT
void sixlowpan_mac_init(transceiver_type_t type)
{
    int recv_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE,
                                 PRIORITY_MAIN - 2, CREATE_STACKTEST, recv_ieee802154_frame , "radio");
    transceiver_type = type;
    transceiver_init(transceiver_type);
    transceiver_start();
    transceiver_register(type, recv_pid);

    macdsn = rand() % 256;
}
示例#4
0
文件: main.c 项目: JiapengLi/RIOT
int main(void)
{
    int16_t a;
    msg_t mesg;
    transceiver_command_t tcmd;

    printf("\n\tmain(): initializing transceiver\n");
    transceiver_init(TRANSCEIVER_NATIVE);

    printf("\n\tmain(): starting transceiver\n");
    transceiver_start();

#ifndef SENDER
    printf("\n\tmain(): starting radio thread\n");
    kernel_pid_t radio_pid = thread_create(
            radio_stack_buffer, sizeof(radio_stack_buffer),
            PRIORITY_MAIN - 2, CREATE_STACKTEST,
            radio, NULL, "radio");
    transceiver_register(TRANSCEIVER_NATIVE, radio_pid);
#endif

#ifdef SENDER
    a = SENDER_ADDR;
#elif defined ADDR
    a = ADDR;
#else
    a = DEFAULT_RCV_ADDR;
#endif
    tcmd.transceivers = TRANSCEIVER_NATIVE;
    tcmd.data = &a;
    mesg.content.ptr = (char *) &tcmd;
    mesg.type = SET_ADDRESS;

    printf("[nativenet] trying to set address %" PRIi16 "\n", a);
    msg_send_receive(&mesg, &mesg, transceiver_pid);

#ifdef SENDER
    hwtimer_wait(HWTIMER_TICKS(SECOND));
    sender();
#else
    hwtimer_wait(HWTIMER_TICKS(WAIT_TIME * SECOND));
    receiving = 0;
    printf("Missed %u of %u packets after %u seconds\n", missed_cnt, (last_seq - first),  WAIT_TIME);
#endif

    return 0;
}
示例#5
0
int main(void) {
    int radio_pid;
    uint8_t i;
    for (i = 0; i < SND_BUFFER_SIZE; i++) { 
        memset(snd_buffer[i], i, CC1100_MAX_DATA_LENGTH);
    }
    thread_create(shell_stack_buffer, SHELL_STACK_SIZE, PRIORITY_MAIN-1, CREATE_STACKTEST, shell_runner, "shell");
    radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio");
    transceiver_init(TRANSCEIVER_CC1100);
    transceiver_start();
    transceiver_register(TRANSCEIVER_CC1100, radio_pid);
   
   while (1) {
//       LED_GREEN_TOGGLE;
       hwtimer_wait(1000 * 1000);
   }
}
示例#6
0
文件: main.c 项目: ShaneLan/RIOT
void init_transceiver(void)
{
    kernel_pid_t radio_pid = thread_create(
                        radio_stack_buffer,
                        sizeof(radio_stack_buffer),
                        PRIORITY_MAIN - 2,
                        CREATE_STACKTEST,
                        radio,
                        NULL,
                        "radio");

    uint16_t transceivers = TRANSCEIVER_DEFAULT;

    transceiver_init(transceivers);
    (void) transceiver_start();
    transceiver_register(transceivers, radio_pid);
}
示例#7
0
文件: ping.c 项目: AnonMall/RIOT
/* public interface functions */
void l2_ping_init(void)
{
    mutex_init(&ping_sender_mutex);
    kernel_pid_t l2_pkt_handler_pid = thread_create(l2_pkt_handler_stack_buffer,
                                                    RADIO_STACK_SIZE,
                                                    PRIORITY_MAIN - 2,
                                                    CREATE_STACKTEST,
                                                    l2_pkt_handler, NULL,
                                                    "l2_pkt_handler");
    uint16_t transceivers = TRANSCEIVER_DEFAULT;

#ifndef MODULE_NET_IF
    transceiver_init(transceivers);
    (void) transceiver_start();
#endif
    transceiver_register(transceivers, l2_pkt_handler_pid);
}
示例#8
0
void init_transceiver(void)
{
    kernel_pid_t radio_pid = thread_create(
                        radio_stack_buffer,
                        sizeof(radio_stack_buffer),
                        PRIORITY_MAIN - 2,
                        CREATE_STACKTEST,
                        radio,
                        NULL,
                        "radio");

    uint16_t transceivers = TRANSCEIVER_DEFAULT;

    transceiver_init(transceivers);
    transceiver_start();
    transceiver_register(transceivers, radio_pid);

    msg_t mesg;
    mesg.type = SET_CHANNEL;
    mesg.content.ptr = (char *) &tcmd;

    uint16_t c = 10;

    tcmd.transceivers = TRANSCEIVER_DEFAULT;
    tcmd.data = &c;
    printf("Set transceiver to channel %u\n", c);
    msg_send(&mesg, transceiver_pid);

    mesg.type = SET_MONITOR;
    mesg.content.ptr = (char *) &tcmd;

    uint16_t v = 1;

    tcmd.data = &v;
    printf("Set transceiver into monitor mode\n");
    msg_send(&mesg, transceiver_pid);
}
示例#9
0
文件: main.c 项目: Rossano/RIOT
int main(void)
{
    int iface;
    char *addr1_data = "abcdefgh", *addr2_data = "12345678";
    net_if_addr_t addr1 = {
        .addr_next = NULL,
        .addr_prev = NULL,
        .addr_protocol = NET_IF_L3P_IPV6_MULTICAST,
        .addr_data = (void *)addr1_data,
        .addr_len = (strlen(addr1_data) + 1) * 8
    };
    net_if_addr_t addr2 = {
        .addr_next = NULL,
        .addr_prev = NULL,
        .addr_protocol = NET_IF_L3P_IPV6_PREFIX,
        .addr_data = (void *)addr2_data,
        .addr_len = (strlen(addr2_data) + 1) * 8
    };
    uint16_t own = 1, target = 2;
    net_if_eui64_t eui64;

    iface = initialize_tests();

    if (!test_net_if_initialization(iface)) {
        printf("FAILED: test_net_if_initialization()\n");
        return -1;
    }

    if (!test_net_if_get_add_l3p_types(iface)) {
        printf("FAILED: test_net_if_get_add_l3p_types()\n");
        return -1;
    }

    if (!test_net_if_add_address(iface, &addr1, &addr2)) {
        printf("FAILED: test_net_if_add_address()\n");
        return -1;
    }

    if (!test_net_if_del_address(iface, &addr1, &addr2)) {
        printf("FAILED: test_net_if_del_address()\n");
        return -1;
    }

    if (!test_net_if_get_set_hardware_address(iface, own)) {
        printf("FAILED: test_net_if_get_set_hardware_address()\n");
        return -1;
    }

    if (!test_net_if_get_set_pan_id(iface)) {
        printf("FAILED: test_net_if_get_set_pan_id()\n");
        return -1;
    }

    if (!test_net_if_get_set_eui64(iface, &eui64, own)) {
        printf("FAILED: test_net_if_get_set_eui64()\n");
        return -1;
    }

    int count = net_if_send_packet(iface, target, "Test", 4);

    printf("Count was %i after net_if_send_packet()\n", count);

    printf("All test ran successfully.\n");

    return 0;
}

int initialize_tests(void)
{
    int iface;

#ifndef MODULE_AUTO_INIT
    transceiver_init(TRANSCEIVER);
    transceiver_start();
    net_if_init();
    iface = net_if_init_interface(0, TRANSCEIVER);
    return iface;
#else
    iface = -1;

    while ((iface = net_if_iter_interfaces(iface)) >= 0) {
        return iface;
    }

    return iface;
#endif
}

int test_net_if_initialization(int iface)
{
    net_if_addr_t *addr_ptr = NULL;

    if (net_if_get_l3p_types(iface)) {
        printf("FAILED: No L3 type expected on interface %d.\n", iface);
        return 0;
    }

    if (net_if_iter_addresses(iface + 1, &addr_ptr)) {
        printf("FAILED: Expected error on interface '%d'\n", iface + 1);
        return 0;
    }

    if (net_if_iter_addresses(iface, &addr_ptr)) {
        printf("FAILED: Expected error on interface '%d'\n", iface);
        return 0;
    }

    return 1;
}