46 #include "sys/clock.h" 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 103 SIM_INTERFACE_NAME(moteid_interface);
104 SIM_INTERFACE_NAME(vib_interface);
105 SIM_INTERFACE_NAME(rs232_interface);
106 SIM_INTERFACE_NAME(simlog_interface);
107 SIM_INTERFACE_NAME(beep_interface);
108 SIM_INTERFACE_NAME(radio_interface);
109 SIM_INTERFACE_NAME(button_interface);
110 SIM_INTERFACE_NAME(pir_interface);
111 SIM_INTERFACE_NAME(clock_interface);
112 SIM_INTERFACE_NAME(leds_interface);
113 SIM_INTERFACE_NAME(cfs_interface);
114 SIM_INTERFACE_NAME(eeprom_interface);
115 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);
127 intptr_t referenceVar;
132 static struct cooja_mt_thread rtimer_thread;
133 static struct cooja_mt_thread process_run_thread;
136 void leds_arch_init(
void);
139 rtimer_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;
215 process_run_thread_loop(
void *data)
218 simProcessRunValue = 1;
236 JNIEXPORT jint JNICALL
239 return JNI_VERSION_10;
254 JNIEXPORT
void JNICALL
258 cooja_mt_start(&rtimer_thread, &rtimer_thread_loop, NULL);
259 cooja_mt_start(&process_run_thread, &process_run_thread_loop, NULL);
279 JNIEXPORT
void JNICALL
282 (*env)->SetByteArrayRegion(
287 (jbyte *) (((intptr_t)rel_addr) + referenceVar)
306 JNIEXPORT
void JNICALL
309 (*env)->GetByteArrayRegion(env, mem_arr, 0, length,
310 (jbyte *)((intptr_t)rel_addr + referenceVar));
332 JNIEXPORT
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();
375 JNIEXPORT
void JNICALL
378 referenceVar = (((intptr_t)&referenceVar) - ((intptr_t)addr));
SENSORS & button_sensor
Exports global symbols for the sensor API.
uip_lladdr_t uip_lladdr
Host L2 address.
bool eeprom_init(void)
Initialize the EEPROM module.
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.
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.