USER MANUAL RC188x-GPR
2019 Radiocrafts AS
RIIM User Manual (rev.1.2)
Page
8
of
23
RIIM_SETUP
()
{
Util
.
printf
(
"# Starting RIIM Sensor Board Node\n"
);
// Initialize variables.
// This MUST be done explicitly in RIIM_SETUP(), except if they are
// declared const
milliVolts
=
0
;
// Set up interface towards the SHT35-sensor
ADC
.
init
(
ADC0
,
ADC_FIXED_REFERENCE
,
ADC_SAMPLING_DURATION_10_6_US
);
// Create CoAP resource
CoAP
.
init
(
ResponseHandler
);
// Create timer that sends the CoAP PUT message
Sensor_timer_handler
=
Timer
.
create
(
PERIODIC
,
TimerPeriod
,
ReadSensor
);
CoAP_timer_handler
=
Timer
.
create
(
PERIODIC
,
TimerPeriod
,
SendCoAP
);
Timer
.
start
(
Sensor_timer_handler
);
Timer
.
start
(
CoAP_timer_handler
);
// Start the node
Network
.
startLeafNode
();
// Return UAPI_OK to indicate setup went well
return
UAPI_OK
;
}
Example 1 - ADC sensor example
Hopefully you get an idea of how easy it is to define and register a handler for an event. In a little more than 30
lines of actual code you have created a full CoAP and Mesh-enabled ADC sensor.