Skip to content

samples: add panther board sensor MQTT application #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

MaxAgneni
Copy link

Signed-off-by: Massimiliano Agneni [email protected]

@jukkar jukkar added the net label Jun 6, 2017
@jukkar jukkar requested review from lpereira, jukkar and tbursztyka June 6, 2017 07:30
{
int len = 0;

len += sprintf(json+len, "{");
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer that we use snprintf() or snprintk() (the latter uses less memory) which would check that you do not overwrite the buffer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Better yet: use the JSON library that comes with Zephyr.


k_sem_init(&sync_sem, 0, 1);

k_thread_spawn(ipm_stack, STACKSIZE, ipm_thread,
Copy link
Member

Choose a reason for hiding this comment

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

The k_thread_spawn() is deprecated, you should use k_thread_create() instead.

Note also that PR #392 (not yet merged) will bring some changes how the stack is defined.

sensors.BME280[2].val1 = (val->val1 * 10) + (val->val2 / 100000);
sensors.BME280[2].val2 = (val->val2 % 100000) * 10;
break;

Copy link
Member

Choose a reason for hiding this comment

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

Minor nit pick, the breaks in this switch do not look unified (some have empty line after and/or before). Could you make this look better in this respect?

static char ipm_stack[STACKSIZE];
static char json[2048];
static struct shield_sens sensors;
static struct k_sem sync_sem;
Copy link
Member

Choose a reason for hiding this comment

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

too many spaces


#define ZEPHYR_ADDR "0.0.0.0"

#define APP_SLEEP_MSECS 5000
Copy link
Member

Choose a reason for hiding this comment

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

The values look weirdly aligned, perhaps use spaces here instead of tabs?

}

while (1) {

Copy link
Member

Choose a reason for hiding this comment

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

This empty line is useless here.

@jukkar jukkar removed the net label Jun 6, 2017
Copy link
Collaborator

@lpereira lpereira left a comment

Choose a reason for hiding this comment

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

It's a nice example, but there are multiple issues with this patch; I didn't finish reviewing it.

{
int len = 0;

len += sprintf(json+len, "{");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better yet: use the JSON library that comes with Zephyr.


client_ctx = CONTAINER_OF(mqtt_ctx, struct mqtt_client_ctx, mqtt_ctx);

printk("[%s:%d]", __func__, __LINE__);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather use the logging stuff for debugging messages. (There are other places in the code where printk() is used and the logging subsystem could be used instead.)

*/
int mqtt_send(char *topic, char *payload)
{
struct mqtt_publish_msg *pub_msg = &client_ctx.pub_msg;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indentation is wrong here. Please use tabs. (Add a git commit hook to always pass your changes through checkpatch. The documentation explains how to do it.)


ret = net_mgmt(NET_REQUEST_WIFI_CMD_AP_CONNECT, iface,
&req, sizeof(req));
if(ret){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing spaces here: if (ret) {. Please use checkpatch.

/* fetch sensor samples */
old = NULL;
for (i = 0; i < ARRAY_SIZE(info); i++) {
if (info[i].dev) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to do if (!info[i].dev]) { continue; } here. Avoids one indentation level.

QUARK_SE_IPM_DEFINE(ess_ipm, 0, QUARK_SE_IPM_INBOUND);

static char ipm_stack[STACKSIZE];
static char json[2048];
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for json to be global. Define it where it's used, or better yet: use the JSON library that comes with Zephyr... it's safer.

Signed-off-by: Massimiliano Agneni <[email protected]>
Signed-off-by: Anas Nashif <[email protected]>
@nashif nashif force-pushed the samples-panther branch from 8348bd3 to f69f8e7 Compare July 4, 2017 00:53
nagineni pushed a commit to nagineni/zephyr that referenced this pull request Nov 20, 2017
@pfalcon pfalcon changed the title samples: add panther sensor MQTT application samples: add panther board sensor MQTT application Jan 11, 2018
@nashif
Copy link
Member

nashif commented Jan 30, 2018

panther board was removed

@nashif nashif closed this Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants