-
Notifications
You must be signed in to change notification settings - Fork 36
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this example! Integration looks OK. I'll test this and post the results. Travis complains about some whitespace errors.
wakaama-temp/Makefile.ci
Outdated
@@ -0,0 +1,60 @@ | |||
BOARD_BLACKLIST := \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After RIOT-OS/RIOT#12872 the blacklist should not be necessary
wakaama-temp/temp_reader.c
Outdated
_temp_instance = instance; | ||
|
||
_uri.flag = LWM2M_URI_FLAG_OBJECT_ID | LWM2M_URI_FLAG_INSTANCE_ID | | ||
LWM2M_URI_FLAG_RESOURCE_ID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alignment is off
wakaama-temp/temp_reader.c
Outdated
DEBUG("temperature: %d.%02d C\n", phy.val[0] / 100, phy.val[0] % 100); | ||
} | ||
else { | ||
DEBUG("Sensor read failure: %d\n", res); | ||
} | ||
|
||
_temp_instance->sensor_value = (double)phy.val[0] / 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As SAUL_DRIVER
is configurable, maybe use the phy.scale
value here to format the temperature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, formatting is needed. Thanks for the pointer to this attribute; I was unaware.
/* Priority is main-6 because LwM2M is main-1, and network stack is below | ||
* that. */ | ||
_pid = thread_create(_msg_stack, sizeof(_msg_stack), | ||
THREAD_PRIORITY_MAIN - 6, THREAD_CREATE_STACKTEST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leandrolanzieri, I would appreciate any ideas you have on management of thread priorities. Subtraction by 6 is hacky, and I also had to change the default priority level on native (see Makefile) to accommodate this.
It seems like there should be something like identified min/max priorities for application threads.
Comments addressed. |
Contribution description
This application extends the RIOT LwM2M Wakaama example to periodically sample a SAUL temperature sensor and make the value available as a LwM2M measured temperature (/3303) object. The app also can be run with a "native" board without a SAUL sensor. In this case the temperature value simply increases with each measurement.
This implementation provides partial support for the LwM2M definition for measured temperature, including only the sensor value and units.
The app works fine, but should be considered a WIP for a couple of reasons:
measured_temp.(c|h)
module belongs with the Wakaama pkg in RIOT. I plan to create a separate PR to add that. Once that is merged, I can update this PR to reference it instead.Testing procedure
See README.md to set up and run the app.
For temperature readings, I use a Microchip MCP9808 sensor with the RIOT JC42 driver. Adafruit makes it easy for those of us who live in the higher levels of the stack. :-)