1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/examples/ccn-lite-relay/main.c
Lucas Jenss 426170b064 Improve naming of thread stacksize/priority constants
As discussed in #2725, this commit renames a number of stacksize constants to
better convey their intended usage. In addition, constants for thread priority
are given a `THREAD_` prefix. Changes are:

* KERNEL_CONF_STACKSIZE_PRINTF renamed to THREAD_EXTRA_STACKSIZE_PRINTF
* KERNEL_CONF_STACKSIZE_DEFAULT renamed to THREAD_STACKSIZE_DEFAULT
* KERNEL_CONF_STACKSIZE_IDLE renamed to THREAD_STACKSIZE_IDLE
* KERNEL_CONF_STACKSIZE_MAIN renamed to THREAD_STACKSIZE_MAIN
* Move thread stacksizes from kernel.h to thread.h, since the prefix changed
* PRIORITY_MIN renamed to THREAD_PRIORITY_MIN
* PRIORITY_IDLE renamed to THREAD_PRIORITY_IDLE
* PRIORITY_MAIN renamed to THREAD_PRIORITY_MAIN
* Move thread priorities from kernel.h to thread.h since the prefix has changed
* MINIMUM_STACK_SIZE renamed to THREAD_STACKSIZE_MINIMUM for consistency
2015-05-21 00:14:23 +02:00

86 lines
1.6 KiB
C

/*
* Copyright (C) 2013 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup examples
* @{
*
* @file
* @brief CCN Lite relay example application
*
* @author Christian Mehlis <mehlis@inf.fu-berlin.de>
*
* @}
*/
// system
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
// riot
#include "thread.h"
#include "periph/rtc.h"
// ccn
#include "ccn_lite/ccnl-riot.h"
static kernel_pid_t _relay_pid = KERNEL_PID_UNDEF;
char t2_stack[THREAD_STACKSIZE_MAIN];
void set_address_handler(uint16_t a)
{
msg_t mesg;
transceiver_command_t tcmd;
tcmd.transceivers = TRANSCEIVER;
tcmd.data = &a;
mesg.content.ptr = (char *) &tcmd;
printf("trying to set address %" PRIu16 "\n", a);
mesg.type = SET_ADDRESS;
printf("transceiver_pid=%" PRIkernel_pid"\n", transceiver_pid);
msg_send_receive(&mesg, &mesg, transceiver_pid);
printf("got address: %" PRIu16 "\n", a);
}
void populate_cache(void)
{
msg_t m;
m.content.value = 0;
m.type = CCNL_RIOT_POPULATE;
msg_send(&m, _relay_pid);
}
void *second_thread(void *arg)
{
(void) arg;
set_address_handler(42);
populate_cache();
return NULL;
}
int main(void)
{
printf("CCN!\n");
_relay_pid = thread_getpid();
thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN + 1,
CREATE_STACKTEST, second_thread, NULL, "helper thread");
printf("starting ccn-lite relay...\n");
ccnl_riot_relay_start(NULL);
return 0;
}