@@ -56,37 +56,36 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
56
56
}
57
57
}
58
58
59
- void ffPrintBluetooth (FFBluetoothOptions * options )
59
+ bool ffPrintBluetooth (FFBluetoothOptions * options )
60
60
{
61
61
FF_LIST_AUTO_DESTROY devices = ffListCreate (sizeof (FFBluetoothResult ));
62
62
const char * error = ffDetectBluetooth (options , & devices );
63
63
64
64
if (error )
65
65
{
66
66
ffPrintError (FF_BLUETOOTH_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT , "%s" , error );
67
+ return false;
67
68
}
68
- else
69
- {
70
- FF_LIST_AUTO_DESTROY filtered = ffListCreate (sizeof (FFBluetoothResult * ));
71
69
72
- FF_LIST_FOR_EACH (FFBluetoothResult , device , devices )
73
- {
74
- if (!device -> connected && !options -> showDisconnected )
75
- continue ;
70
+ FF_LIST_AUTO_DESTROY filtered = ffListCreate (sizeof (FFBluetoothResult * ));
76
71
77
- * (FFBluetoothResult * * )ffListAdd (& filtered ) = device ;
78
- }
72
+ FF_LIST_FOR_EACH (FFBluetoothResult , device , devices )
73
+ {
74
+ if (!device -> connected && !options -> showDisconnected )
75
+ continue ;
79
76
80
- if (filtered .length == 0 )
81
- {
82
- ffPrintError (FF_BLUETOOTH_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT , "No bluetooth devices found" );
83
- }
77
+ * (FFBluetoothResult * * )ffListAdd (& filtered ) = device ;
78
+ }
84
79
85
- for (uint32_t i = 0 ; i < filtered .length ; i ++ )
86
- {
87
- uint8_t index = (uint8_t ) (filtered .length == 1 ? 0 : i + 1 );
88
- printDevice (options , * FF_LIST_GET (FFBluetoothResult * , filtered , i ), index );
89
- }
80
+ if (filtered .length == 0 )
81
+ {
82
+ ffPrintError (FF_BLUETOOTH_MODULE_NAME , 0 , & options -> moduleArgs , FF_PRINT_TYPE_DEFAULT , "No bluetooth devices found" );
83
+ }
84
+
85
+ for (uint32_t i = 0 ; i < filtered .length ; i ++ )
86
+ {
87
+ uint8_t index = (uint8_t ) (filtered .length == 1 ? 0 : i + 1 );
88
+ printDevice (options , * FF_LIST_GET (FFBluetoothResult * , filtered , i ), index );
90
89
}
91
90
92
91
FF_LIST_FOR_EACH (FFBluetoothResult , device , devices )
@@ -95,6 +94,7 @@ void ffPrintBluetooth(FFBluetoothOptions* options)
95
94
ffStrbufDestroy (& device -> type );
96
95
ffStrbufDestroy (& device -> address );
97
96
}
97
+ return true;
98
98
}
99
99
100
100
void ffParseBluetoothJsonObject (FFBluetoothOptions * options , yyjson_val * module )
@@ -128,15 +128,15 @@ void ffGenerateBluetoothJsonConfig(FFBluetoothOptions* options, yyjson_mut_doc*
128
128
ffPercentGenerateJsonConfig (doc , module , options -> percent );
129
129
}
130
130
131
- void ffGenerateBluetoothJsonResult (FFBluetoothOptions * options , yyjson_mut_doc * doc , yyjson_mut_val * module )
131
+ bool ffGenerateBluetoothJsonResult (FFBluetoothOptions * options , yyjson_mut_doc * doc , yyjson_mut_val * module )
132
132
{
133
133
FF_LIST_AUTO_DESTROY results = ffListCreate (sizeof (FFBluetoothResult ));
134
134
135
135
const char * error = ffDetectBluetooth (options , & results );
136
136
if (error )
137
137
{
138
138
yyjson_mut_obj_add_str (doc , module , "error" , error );
139
- return ;
139
+ return false ;
140
140
}
141
141
142
142
yyjson_mut_val * arr = yyjson_mut_obj_add_arr (doc , module , "result" );
@@ -157,6 +157,7 @@ void ffGenerateBluetoothJsonResult(FFBluetoothOptions* options, yyjson_mut_doc*
157
157
ffStrbufDestroy (& device -> type );
158
158
ffStrbufDestroy (& device -> address );
159
159
}
160
+ return true;
160
161
}
161
162
162
163
void ffInitBluetoothOptions (FFBluetoothOptions * options )
0 commit comments