Added a new function to select a device by it's secondary address
This commit is contained in:
parent
d12d7dd052
commit
ef630f2e5d
@ -1695,16 +1695,15 @@ mbus_send_ping_frame(mbus_handle *handle, int address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Prove for the presence of a device(s) using the supplied secondary address
|
// Select a device using the supplied secondary address (mask).
|
||||||
// (mask).
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
int
|
int
|
||||||
mbus_probe_secondary_address(mbus_handle * handle, const char *mask, char *matching_addr)
|
mbus_select_secondary_address(mbus_handle * handle, const char *mask)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
mbus_frame reply;
|
mbus_frame reply;
|
||||||
|
|
||||||
if (mask == NULL || matching_addr == NULL || strlen(mask) != 16)
|
if (mask == NULL || strlen(mask) != 16)
|
||||||
{
|
{
|
||||||
MBUS_ERROR("%s: Invalid address masks.\n", __PRETTY_FUNCTION__);
|
MBUS_ERROR("%s: Invalid address masks.\n", __PRETTY_FUNCTION__);
|
||||||
return MBUS_PROBE_ERROR;
|
return MBUS_PROBE_ERROR;
|
||||||
@ -1747,6 +1746,34 @@ mbus_probe_secondary_address(mbus_handle * handle, const char *mask, char *match
|
|||||||
return MBUS_PROBE_COLLISION;
|
return MBUS_PROBE_COLLISION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return MBUS_PROBE_SINGLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MBUS_ERROR("%s: Unexpected reply for address [%s].\n", __PRETTY_FUNCTION__, mask);
|
||||||
|
|
||||||
|
return MBUS_PROBE_NOTHING;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Prove for the presence of a device(s) using the supplied secondary address
|
||||||
|
// (mask).
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
int
|
||||||
|
mbus_probe_secondary_address(mbus_handle * handle, const char *mask, char *matching_addr)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
mbus_frame reply;
|
||||||
|
|
||||||
|
if (mask == NULL || matching_addr == NULL || strlen(mask) != 16)
|
||||||
|
{
|
||||||
|
MBUS_ERROR("%s: Invalid address masks.\n", __PRETTY_FUNCTION__);
|
||||||
|
return MBUS_PROBE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mbus_select_secondary_address(handle, mask);
|
||||||
|
|
||||||
|
if (ret == MBUS_PROBE_SINGLE)
|
||||||
|
{
|
||||||
/* send a data request command to find out the full address */
|
/* send a data request command to find out the full address */
|
||||||
if (mbus_send_request_frame(handle, 253) == -1)
|
if (mbus_send_request_frame(handle, 253) == -1)
|
||||||
{
|
{
|
||||||
@ -1788,9 +1815,7 @@ mbus_probe_secondary_address(mbus_handle * handle, const char *mask, char *match
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MBUS_ERROR("%s: Unexpected reply for address [%s].\n", __PRETTY_FUNCTION__, mask);
|
return ret;
|
||||||
|
|
||||||
return MBUS_PROBE_NOTHING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user