#include <bluesense.h>
#include <stdio.h>
int main(void) {
bsDeviceInterface_registeredDeviceInterfaces_t registered = bsDeviceInterface_allocInterfaceTable();
bsDeviceTable_table_t devices = bsDeviceTable_allocDeviceTable();
bsMaster_device_t master = bsMaster_allocMaster(registered,devices,0);
#if 1
bsMaster_addIPAddress(master, "1623", "admin", "admin");
#endif
printf("Detecting devices for the next 2+ seconds...\n");
fflush(stdout);
uint16_t newFound = 1;
while(newFound) {
newFound = bsMaster_detectDevices(master,10,2*1000*1000);
}
uint8_t msgCount = bsMaster_getMessageCount();
if (msgCount!=0) {
printf("Connection messages: \n");
uint8_t index;
for (index=0; index<msgCount; index++) {
printf("%s \n",bsMaster_getMessage(index));
}
bsMaster_clearMessages();
}
printf("Found %d device(s) \n",bsDeviceTable_getListedDeviceCount(devices));
bsDeviceTable_deviceInfo_t dev = bsDeviceTable_getFirstDevice(devices);
for(; dev; dev = bsDeviceTable_getNextDevice(dev)) {
dex_devtype_t tp = bsDeviceTable_getDeviceType(dev);
identifier_t id = bsDeviceTable_getDeviceId(dev);
printf("Device id = %d, type = %d, typename = %s firmwareVersion = %d\n",
id,
tp,
bsDeviceInterface_getDeviceTypeName(registered,tp),
bsDeviceTable_getDeviceFirmwareVersion(dev));
}
bsMaster_freeMaster(master);
bsDeviceTable_freeDeviceTable(devices);
bsDeviceInterface_freeInterfaceTable(registered);
printf("Press Enter to finish\n");
fflush(stdout);
getchar();
return(0);
}