BS120x Ethernet Library 1.1.0
BS120x Ethernet Library
Loading...
Searching...
No Matches
Discovery

Device discovery functionality. More...

+ Collaboration diagram for Discovery:

Functions

int Bs120xEnet_DiscoverDevices (const char *interface, Bs120xUnitConfig devices_buf[], size_t *devices_len)
 Discovery devices over Ethernet.
 

Detailed Description

Device discovery functionality.

Function Documentation

◆ Bs120xEnet_DiscoverDevices()

int Bs120xEnet_DiscoverDevices ( const char *  interface,
Bs120xUnitConfig  devices_buf[],
size_t *  devices_len 
)

Discovery devices over Ethernet.

This function listens on port 58431 for 2 seconds, recording all devices which broadcast during that time.

Example usage (error handling omitted):

size_t n = 10;
Bs120xUnitConfig* buf = calloc(n, sizeof(*buf));
Bs120xEnet_DiscoverDevices("192.168.1.150", buf, &n);
printf("found %zu devices\n", n);
for (size_t i = 0; i < n; ++i) {
printf("%zu: %s\n", i + 1, buf[i].serial_number);
}
free(buf);
int Bs120xEnet_DiscoverDevices(const char *interface, Bs120xUnitConfig devices_buf[], size_t *devices_len)
Discovery devices over Ethernet.
BS1201 unit configuration structure. Strings are null-terminated.
Definition CInterface.h:127
Parameters
[in]interfaceThe network interface to use.
[out]devices_bufBuffer to hold the returned devices.
[in,out]devices_lenAddress of an integer containing the length of devices_buf. It will be updated to contain the number of devices discovered.
Returns
0 on success or a negative error code.