Do not break hackrf_open() API, provide a hackrf_open_by_serial() instead for the new functionality.
This commit is contained in:

committed by
Heikki Hannikainen

parent
893fef3fcf
commit
c0b3638cce
@ -164,7 +164,7 @@ int main(int argc, char** argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(serial_number, &device);
|
||||
result = hackrf_open_by_serial(serial_number, &device);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_open() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
|
@ -130,7 +130,7 @@ int main(int argc, char** argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = hackrf_open(NULL, &device);
|
||||
result = hackrf_open(&device);
|
||||
if( result ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
|
@ -131,7 +131,7 @@ int main(int argc, char** argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = hackrf_open(NULL, &device);
|
||||
result = hackrf_open(&device);
|
||||
if( result ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
|
@ -195,7 +195,7 @@ int main(int argc, char** argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = hackrf_open(NULL, &device);
|
||||
result = hackrf_open(&device);
|
||||
if( result ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
return -1;
|
||||
|
@ -219,7 +219,7 @@ int main(int argc, char** argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(serial_number, &device);
|
||||
result = hackrf_open_by_serial(serial_number, &device);
|
||||
if (result != HACKRF_SUCCESS) {
|
||||
fprintf(stderr, "hackrf_open() failed: %s (%d)\n",
|
||||
hackrf_error_name(result), result);
|
||||
|
@ -782,7 +782,7 @@ int main(int argc, char** argv) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
result = hackrf_open(serial_number, &device);
|
||||
result = hackrf_open_by_serial(serial_number, &device);
|
||||
if( result != HACKRF_SUCCESS ) {
|
||||
printf("hackrf_open() failed: %s (%d)\n", hackrf_error_name(result), result);
|
||||
usage();
|
||||
|
@ -447,7 +447,7 @@ static int hackrf_open_setup(libusb_device_handle* usb_device, hackrf_device** d
|
||||
return HACKRF_SUCCESS;
|
||||
}
|
||||
|
||||
int ADDCALL hackrf_open(const char* const desired_serial_number, hackrf_device** device)
|
||||
int ADDCALL hackrf_open(hackrf_device** device)
|
||||
{
|
||||
libusb_device_handle* usb_device;
|
||||
|
||||
@ -456,16 +456,11 @@ int ADDCALL hackrf_open(const char* const desired_serial_number, hackrf_device**
|
||||
return HACKRF_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if( desired_serial_number )
|
||||
usb_device = libusb_open_device_with_vid_pid(g_libusb_context, hackrf_usb_vid, hackrf_one_usb_pid);
|
||||
|
||||
if( usb_device == NULL )
|
||||
{
|
||||
usb_device = hackrf_open_usb(desired_serial_number);
|
||||
} else {
|
||||
usb_device = libusb_open_device_with_vid_pid(g_libusb_context, hackrf_usb_vid, hackrf_one_usb_pid);
|
||||
|
||||
if( usb_device == NULL )
|
||||
{
|
||||
usb_device = libusb_open_device_with_vid_pid(g_libusb_context, hackrf_usb_vid, hackrf_jawbreaker_usb_pid);
|
||||
}
|
||||
usb_device = libusb_open_device_with_vid_pid(g_libusb_context, hackrf_usb_vid, hackrf_jawbreaker_usb_pid);
|
||||
}
|
||||
|
||||
if( usb_device == NULL )
|
||||
@ -476,6 +471,30 @@ int ADDCALL hackrf_open(const char* const desired_serial_number, hackrf_device**
|
||||
return hackrf_open_setup(usb_device, device);
|
||||
}
|
||||
|
||||
int ADDCALL hackrf_open_by_serial(const char* const desired_serial_number, hackrf_device** device)
|
||||
{
|
||||
libusb_device_handle* usb_device;
|
||||
|
||||
if( desired_serial_number == NULL )
|
||||
{
|
||||
return hackrf_open(device);
|
||||
}
|
||||
|
||||
if( device == NULL )
|
||||
{
|
||||
return HACKRF_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
usb_device = hackrf_open_usb(desired_serial_number);
|
||||
|
||||
if( usb_device == NULL )
|
||||
{
|
||||
return HACKRF_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
return hackrf_open_setup(usb_device, device);
|
||||
}
|
||||
|
||||
int ADDCALL hackrf_device_list_open(hackrf_device_list_t *list, int idx, hackrf_device** device)
|
||||
{
|
||||
libusb_device_handle* usb_device;
|
||||
|
@ -117,7 +117,8 @@ extern ADDAPI hackrf_device_list_t* ADDCALL hackrf_device_list();
|
||||
extern ADDAPI int ADDCALL hackrf_device_list_open(hackrf_device_list_t *list, int idx, hackrf_device** device);
|
||||
extern ADDAPI void ADDCALL hackrf_device_list_free(hackrf_device_list_t *list);
|
||||
|
||||
extern ADDAPI int ADDCALL hackrf_open(const char* const desired_serial_number, hackrf_device** device);
|
||||
extern ADDAPI int ADDCALL hackrf_open(hackrf_device** device);
|
||||
extern ADDAPI int ADDCALL hackrf_open_by_serial(const char* const desired_serial_number, hackrf_device** device);
|
||||
extern ADDAPI int ADDCALL hackrf_close(hackrf_device* device);
|
||||
|
||||
extern ADDAPI int ADDCALL hackrf_start_rx(hackrf_device* device, hackrf_sample_block_cb_fn callback, void* rx_ctx);
|
||||
|
Reference in New Issue
Block a user