Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

LwM2M/SAUL temperature app #66

Closed
wants to merge 7 commits into from
Closed

Conversation

kb2ma
Copy link
Member

@kb2ma kb2ma commented Dec 8, 2019

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:

  • The Wakaamaa pkg was merged after 2019.10, and we don't expect to update this project's dependency on RIOT until the 2020.01 release. At that time I can remove the commit in this PR for that dependency.
  • The 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. :-)

@kb2ma kb2ma added the new app This contributes a new application label Dec 8, 2019
Copy link
Contributor

@leandrolanzieri leandrolanzieri left a 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.

@@ -0,0 +1,60 @@
BOARD_BLACKLIST := \
Copy link
Contributor

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

_temp_instance = instance;

_uri.flag = LWM2M_URI_FLAG_OBJECT_ID | LWM2M_URI_FLAG_INSTANCE_ID |
LWM2M_URI_FLAG_RESOURCE_ID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alignment is off

Comment on lines 62 to 68
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;
Copy link
Contributor

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?

Copy link
Member Author

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,
Copy link
Member Author

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.

@kb2ma
Copy link
Member Author

kb2ma commented Jan 15, 2020

Comments addressed.

miri64
miri64 previously requested changes Jan 20, 2020
wakaama-temp/Makefile Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new app This contributes a new application
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants