48#include "sys/cooja_mt.h"
53#define LOG_MODULE "Cooja"
54#define LOG_LEVEL LOG_LEVEL_MAIN
56#include "lib/random.h"
57#include "lib/simEnvChange.h"
64#include "dev/cooja-radio.h"
65#include "dev/button-sensor.h"
66#include "dev/pir-sensor.h"
67#include "dev/vib-sensor.h"
68#include "dev/moteid.h"
73#include "services/rpl-border-router/rpl-border-router.h"
74#if BUILD_WITH_ORCHESTRA
83#error CLASSNAME is undefined, required by platform.c
85#define COOJA__QUOTEME(a,b,c) COOJA_QUOTEME(a,b,c)
86#define COOJA_QUOTEME(a,b,c) a##b##c
87#define COOJA_JNI_PATH Java_org_contikios_cooja_corecomm_
88#define Java_org_contikios_cooja_corecomm_CLASSNAME_init COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_init)
89#define Java_org_contikios_cooja_corecomm_CLASSNAME_getMemory COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_getMemory)
90#define Java_org_contikios_cooja_corecomm_CLASSNAME_setMemory COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_setMemory)
91#define Java_org_contikios_cooja_corecomm_CLASSNAME_tick COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_tick)
92#define Java_org_contikios_cooja_corecomm_CLASSNAME_setReferenceAddress COOJA__QUOTEME(COOJA_JNI_PATH,CLASSNAME,_setReferenceAddress)
94#if NETSTACK_CONF_WITH_IPV6
103SIM_INTERFACE_NAME(moteid_interface);
104SIM_INTERFACE_NAME(vib_interface);
105SIM_INTERFACE_NAME(rs232_interface);
106SIM_INTERFACE_NAME(simlog_interface);
107SIM_INTERFACE_NAME(beep_interface);
108SIM_INTERFACE_NAME(radio_interface);
109SIM_INTERFACE_NAME(button_interface);
110SIM_INTERFACE_NAME(pir_interface);
111SIM_INTERFACE_NAME(clock_interface);
112SIM_INTERFACE_NAME(leds_interface);
113SIM_INTERFACE_NAME(cfs_interface);
114SIM_INTERFACE_NAME(eeprom_interface);
115SIM_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);
127intptr_t referenceVar;
132static struct cooja_mt_thread rtimer_thread;
133static struct cooja_mt_thread process_run_thread;
136void leds_arch_init(
void);
139rtimer_thread_loop(
void *data)
155 memset(&
addr, 0,
sizeof(linkaddr_t));
156#if NETSTACK_CONF_WITH_IPV6
157 for(
size_t i = 0; i <
sizeof(
uip_lladdr.addr); i += 2) {
158 addr.u8[i + 1] = simMoteID & 0xff;
159 addr.u8[i + 0] = simMoteID >> 8;
162 addr.u8[0] = simMoteID & 0xff;
163 addr.u8[1] = simMoteID >> 8;
198 while(simProcessRunValue-- > 0) {
204 if(simDontFallAsleep) {
205 simDontFallAsleep = 0;
206 simProcessRunValue = 1;
215process_run_thread_loop(
void *data)
218 simProcessRunValue = 1;
236JNIEXPORT jint JNICALL
239 return JNI_VERSION_10;
254JNIEXPORT
void JNICALL
258 cooja_mt_start(&rtimer_thread, &rtimer_thread_loop, NULL);
259 cooja_mt_start(&process_run_thread, &process_run_thread_loop, NULL);
279JNIEXPORT
void JNICALL
282 (*env)->SetByteArrayRegion(
287 (jbyte *) (((intptr_t)rel_addr) + referenceVar)
306JNIEXPORT
void JNICALL
309 (*env)->GetByteArrayRegion(env, mem_arr, 0, length,
310 (jbyte *)((intptr_t)rel_addr + referenceVar));
332JNIEXPORT
void JNICALL
335 simProcessRunValue = 0;
338 doActionsBeforeTick();
347 cooja_mt_exec(&rtimer_thread);
349 if(simProcessRunValue == 0) {
352 cooja_mt_exec(&process_run_thread);
356 doActionsAfterTick();
375JNIEXPORT
void JNICALL
378 referenceVar = (((intptr_t)&referenceVar) - ((intptr_t)
addr));
Default definitions of C compiler quirk work-arounds.
Header file for the GPIO HAL.
void platform_init_stage_three()
Final stage of platform driver initialisation.
void platform_init_stage_one(void)
Basic (Stage 1) platform driver initialisation.
void platform_init_stage_two()
Stage 2 of platform driver initialisation.
bool eeprom_init(void)
Initialize the EEPROM module.
int etimer_pending(void)
Check if there are any non-expired event timers.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
void gpio_hal_init()
Initialise the GPIO HAL.
void linkaddr_set_node_addr(linkaddr_t *t)
Set the address of the current node.
void platform_main_loop()
The platform's main loop, if provided.
int process_run(void)
Run the system once - call poll handlers and process one event.
int process_nevents(void)
Number of events waiting to be processed.
uip_lladdr_t uip_lladdr
Host L2 address.
Header file for the logging system.
Include file for the Contiki low-layer network stack (NETSTACK)
Node-id (simple 16-bit identifiers) handling.
Header file for the Packet queue buffer management.
Generic serial I/O process header filer.
A shell back-end for the serial port.
Header file for IPv6-related data structures.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Header file for the uIP TCP/IP stack.
SENSORS & button_sensor
Exports global symbols for the sensor API.