Skip to content

Commit

Permalink
0.5.4 with try to send with FCB when secondary device was selected (e…
Browse files Browse the repository at this point in the history
…xperiment)
  • Loading branch information
Apollon77 committed Apr 23, 2018
1 parent 57d1be8 commit 4ff23ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-mbus",
"version": "0.5.3",
"version": "0.5.4",
"description": "libmbus binding",
"keywords": [
"mbus"
Expand Down
18 changes: 16 additions & 2 deletions src/mbus-master.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ class RecieveWorker : public Nan::AsyncWorker {
mbus_frame_data reply_data;
char error[100];
int address;
int secondary_selected = 0;
int request_frame_res;

memset((void *)&reply, 0, sizeof(mbus_frame));
memset((void *)&reply_data, 0, sizeof(mbus_frame_data));
Expand Down Expand Up @@ -288,7 +290,10 @@ class RecieveWorker : public Nan::AsyncWorker {
uv_rwlock_wrunlock(lock);
return;
}
// else MBUS_PROBE_SINGLE
else if (ret == MBUS_PROBE_SINGLE)
{
secondary_selected = 1;
}

address = MBUS_ADDRESS_NETWORK_LAYER;
}
Expand All @@ -298,7 +303,16 @@ class RecieveWorker : public Nan::AsyncWorker {
address = atoi(addr_str);
}

if (mbus_send_request_frame(handle, address) == -1)
if (secondary_selected == 1)
{
request_frame_res = mbus_send_request_frame_fcb(handle, address);
}
else
{
request_frame_res = mbus_send_request_frame(handle, address);
}

if (request_frame_res == -1)
{
sprintf(error, "Failed to send M-Bus request frame[%s].", addr_str);
SetErrorMessage(error);
Expand Down

0 comments on commit 4ff23ce

Please sign in to comment.