コード例 #1
0
ファイル: rpl.c プロジェクト: swp2013riot/RIOT
uint8_t rpl_init(transceiver_type_t trans, uint16_t rpl_address)
{
    mutex_init(&rpl_send_mutex);
    mutex_init(&rpl_recv_mutex);

    if(rpl_address == 0) {
        return SIXLOWERROR_ADDRESS;
    }

    /* initialize routing table */
    rpl_clear_routing_table();
    init_trickle();
    rpl_process_pid = thread_create(rpl_process_buf, RPL_PROCESS_STACKSIZE,
                                    PRIORITY_MAIN - 1, CREATE_STACKTEST,
                                    rpl_process, "rpl_process");

    /* INSERT NEW OBJECTIVE FUNCTIONS HERE */
    objective_functions[0] = rpl_get_of0();
    /* objective_functions[1] = rpl_get_of_ETX() */

    sixlowpan_init(trans, rpl_address, 0);
    /* Wir benötigen einen Link Local prefix, um unsere entsprechende Addresse im Netz abzufragen */
    ipv6_addr_t ll_address;
    ipv6_set_ll_prefix(&ll_address);
    ipv6_get_saddr(&my_address, &ll_address);
    set_rpl_process_pid(rpl_process_pid);

    return SUCCESS;

}
コード例 #2
0
ファイル: main.c プロジェクト: miri64/RIOT_playground
int main(void)
{
    shell_t shell;
    kernel_pid_t mac = basic_mac_init(mac_stack, BASIC_MAC_CONTROL_STACKSIZE,
                                      PRIORITY_MAIN - 1, CREATE_STACKTEST,
                                      "basic_mac_default", NETDEV_DEFAULT);
    sixlowpan = sixlowpan_init(mac, sixlowpan_stack, SIXLOWPAN_CONTROL_STACKSIZE,
                               PRIORITY_MAIN - 1, CREATE_STACKTEST,
                               "basic_mac_default");

    genrand_init(hwtimer_now());
    data_value = (uint8_t)(genrand_uint32() % 256);

    netapi_set_option(sixlowpan, NETAPI_CONF_SRC_LEN, &src_len, sizeof(size_t));
    netapi_get_option(sixlowpan, NETAPI_CONF_ADDRESS, &src, sizeof(uint16_t));

    (void) posix_open(uart0_handler_pid, 0);

    (void) puts("Welcome to RIOT!");

    shell_init(&shell, shell_command, UART0_BUFSIZE, uart0_readc, uart0_putc);

    shell_run(&shell);
    return 0;
}
コード例 #3
0
ファイル: sixlowborder.c プロジェクト: swp2013riot/RIOT
uint8_t border_initialize(transceiver_type_t trans, ipv6_addr_t *border_router_addr)
{
    ipv6_addr_t addr;

    serial_reader_pid = thread_create(
                            serial_reader_stack, READER_STACK_SIZE,
                            PRIORITY_MAIN - 1, CREATE_STACKTEST,
                            serial_reader_f, "serial_reader");

    if(border_router_addr == NULL) {
        border_router_addr = &addr;

        addr = flowcontrol_init();
    }

    /* only allow addresses generated accoding to
     * RFC 4944 (Section 6) & RFC 2464 (Section 4) from short address
     * -- for now
     */
    if(border_router_addr->uint16[4] != HTONS(IEEE_802154_PAN_ID ^ 0x0200) ||
       border_router_addr->uint16[5] != HTONS(0x00FF) ||
       border_router_addr->uint16[6] != HTONS(0xFE00)
      ) {
        return SIXLOWERROR_ADDRESS;
    }

    /* radio-address is 8-bit so this must be tested extra */
    if(border_router_addr->uint8[14] != 0) {
        return SIXLOWERROR_ADDRESS;
    }

    memcpy(&(abr_addr.uint8[0]), &(border_router_addr->uint8[0]), 16);

    sixlowpan_init(trans, border_router_addr->uint8[15], 1);

    ipv6_init_iface_as_router();

    return SUCCESS;
}
コード例 #4
0
ファイル: main.c プロジェクト: benpicco/RIOT-old
void init(char *str){
    char command;
    uint16_t r_addr;
    ipv6_addr_t std_addr;

    int res = sscanf(str, "init %c %hu", &command, &r_addr);

    if(res < 1){
        printf("Usage: init {h | r | a | e} radio_address\n");
        printf("\th\tinitialize as host\n");
        printf("\tr\tinitialize as router\n");
        printf("\ta\tinitialize as ad-hoc router\n");
        printf("\tb\tinitialize as border router\n\n");
        printf("\tradio_address must be an 8 bit integer\n");
    }

    ipv6_init_address(&std_addr,0xABCD,0,0,0,0x1034,0x00FF,0xFE00,r_addr);

    switch (command) {
        case 'h':
            printf("INFO: Initialize as host on radio address %hu\n", r_addr);
            if (r_addr > 255) {
                printf("ERROR: radio_address not an 8 bit integer\n");
                return;
            }
            sixlowpan_init(TRANSCEIVER_CC1100,r_addr,0);
            break;
        case 'r':
            printf("INFO: Initialize as router on radio address %hu\n", r_addr);
            if (r_addr > 255) {
                printf("ERROR: radio_address not an 8 bit integer\n");
                return;
            }
            sixlowpan_init(TRANSCEIVER_CC1100, r_addr,0);
            ipv6_init_iface_as_router();
            break;
        case 'a':
            printf("INFO: Initialize as adhoc router on radio address %hu\n", r_addr);
            if (r_addr > 255) {
                printf("ERROR: radio_address not an 8 bit integer\n");
                return;
            }
            sixlowpan_adhoc_init(TRANSCEIVER_CC1100, &std_addr, r_addr);
            break;
        case 'b':
            printf("INFO: Initialize as border router on radio address %hu\n", r_addr);
            if (r_addr > 255) {
                printf("ERROR: radio_address not an 8 bit integer\n");
                return;
            }
            res = border_initialize(TRANSCEIVER_CC1100, &std_addr);
            switch (res) {
                case (SUCCESS): printf("INFO: Border router initialized.\n"); break;
                case (SIXLOWERROR_ADDRESS): printf("ERROR: Illegal IP address: ");
                        ipv6_print_addr(&std_addr); break;
                default: printf("ERROR: Unknown error (%d).\n", res); break;
            }
            break;
        default:
            printf("ERROR: Unknown command '%c'\n", command);
            break;
    }
    tcp_send_pid = thread_create(	tcp_send_stack_buffer,
									SEND_TCP_THREAD_SIZE,
									PRIORITY_MAIN,
									CREATE_STACKTEST,
									send_tcp_thread,
									"send_tcp_thread");
}