45 #include "sys/clock.h" 47 #include "sys/cooja_mt.h" 52 #define LOG_MODULE "Cooja" 53 #define LOG_LEVEL LOG_LEVEL_MAIN 55 #include "lib/random.h" 56 #include "lib/simEnvChange.h" 63 #include "dev/cooja-radio.h" 64 #include "dev/button-sensor.h" 65 #include "dev/pir-sensor.h" 66 #include "dev/vib-sensor.h" 67 #include "dev/moteid.h" 72 #include "services/rpl-border-router/rpl-border-router.h" 73 #if BUILD_WITH_ORCHESTRA 82 #error CLASSNAME is undefined, required by platform.c 84 #define COOJA__QUOTEME(a,b,c) COOJA_QUOTEME(a,b,c) 85 #define COOJA_QUOTEME(a,b,c) a##b##c 86 #define COOJA_JNI_PATH Java_org_contikios_cooja_corecomm_ 87 #define Java_org_contikios_cooja_corecomm_CLASSNAME_init COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_init) 88 #define Java_org_contikios_cooja_corecomm_CLASSNAME_getMemory COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_getMemory) 89 #define Java_org_contikios_cooja_corecomm_CLASSNAME_setMemory COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_setMemory) 90 #define Java_org_contikios_cooja_corecomm_CLASSNAME_tick COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_tick) 91 #define Java_org_contikios_cooja_corecomm_CLASSNAME_setReferenceAddress COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_setReferenceAddress) 93 #if NETSTACK_CONF_WITH_IPV6 102 SIM_INTERFACE_NAME(moteid_interface);
103 SIM_INTERFACE_NAME(vib_interface);
104 SIM_INTERFACE_NAME(rs232_interface);
105 SIM_INTERFACE_NAME(simlog_interface);
106 SIM_INTERFACE_NAME(beep_interface);
107 SIM_INTERFACE_NAME(radio_interface);
108 SIM_INTERFACE_NAME(button_interface);
109 SIM_INTERFACE_NAME(pir_interface);
110 SIM_INTERFACE_NAME(clock_interface);
111 SIM_INTERFACE_NAME(leds_interface);
112 SIM_INTERFACE_NAME(cfs_interface);
113 SIM_INTERFACE_NAME(eeprom_interface);
114 SIM_INTERFACES(&vib_interface, &moteid_interface, &rs232_interface, &simlog_interface, &beep_interface, &radio_interface, &button_interface, &pir_interface, &clock_interface, &leds_interface, &cfs_interface, &eeprom_interface);
131 static struct cooja_mt_thread rtimer_thread;
132 static struct cooja_mt_thread process_run_thread;
135 void leds_arch_init(
void);
138 rtimer_thread_loop(
void *data)
154 memset(&addr, 0,
sizeof(linkaddr_t));
155 #if NETSTACK_CONF_WITH_IPV6 158 for(i = 0; i <
sizeof(
uip_lladdr.addr); i += 2) {
159 addr.u8[i + 1] = simMoteID & 0xff;
160 addr.u8[i + 0] = simMoteID >> 8;
164 addr.u8[0] = simMoteID & 0xff;
165 addr.u8[1] = simMoteID >> 8;
200 while(simProcessRunValue-- > 0) {
206 if(simDontFallAsleep) {
207 simDontFallAsleep = 0;
208 simProcessRunValue = 1;
217 process_run_thread_loop(
void *data)
220 simProcessRunValue = 1;
238 JNIEXPORT
void JNICALL
242 cooja_mt_start(&rtimer_thread, &rtimer_thread_loop, NULL);
243 cooja_mt_start(&process_run_thread, &process_run_thread_loop, NULL);
263 JNIEXPORT
void JNICALL
266 (*env)->SetByteArrayRegion(
271 (jbyte *) (((
long)rel_addr) + referenceVar)
290 JNIEXPORT
void JNICALL
293 jbyte *mem = (*env)->GetByteArrayElements(env, mem_arr, 0);
294 memcpy((
char*) (((
long)rel_addr) + referenceVar),
297 (*env)->ReleaseByteArrayElements(env, mem_arr, mem, 0);
319 JNIEXPORT
void JNICALL
322 simProcessRunValue = 0;
325 doActionsBeforeTick();
334 cooja_mt_exec(&rtimer_thread);
336 if(simProcessRunValue == 0) {
339 cooja_mt_exec(&process_run_thread);
343 doActionsAfterTick();
362 JNIEXPORT
void JNICALL
365 referenceVar = (((long)&referenceVar) - ((long)addr));
SENSORS & button_sensor
Exports global symbols for the sensor API.
uip_lladdr_t uip_lladdr
Host L2 address.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
void platform_main_loop()
The platform's main loop, if provided.
void platform_init_stage_two()
Stage 2 of platform driver initialisation.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
Node-id (simple 16-bit identifiers) handling.
A shell back-end for the serial port
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
void gpio_hal_init()
Initialise the GPIO HAL.
Header file for IPv6-related data structures.
void eeprom_init(void)
Initialize the EEPROM module.
Header file for the Packet queue buffer management
int etimer_pending(void)
Check if there are any non-expired event timers.
void platform_init_stage_three()
Final stage of platform driver initialisation.
int process_nevents(void)
Number of events waiting to be processed.
Header file for the uIP TCP/IP stack.
Generic serial I/O process header filer.
Include file for the Contiki low-layer network stack (NETSTACK)
Default definitions of C compiler quirk work-arounds.
Header file for the GPIO HAL.
Header file for the logging system
int process_run(void)
Run the system once - call poll handlers and process one event.
void platform_init_stage_one(void)
Basic (Stage 1) platform driver initialisation.
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.