@@ -193,3 +193,54 @@ This codebase now includes a small DoIP transport abstraction, a split TCP/UDP i
193193- Build Integration
194194 - CMake: when ` BUILD_UDS_TP_DOIP=ON ` , the DoIP target includes the new TCP/UDP transport sources.
195195 - Bazel: ` src/BUILD ` updated to include the new transport sources and headers.
196+
197+ ### Quick Start: Discovery + Selection
198+
199+ Minimal example of discovering DoIP responders and selecting one by VIN prefix:
200+
201+ ``` c
202+ #include < stdio.h>
203+ #include < string.h>
204+ #include < stdbool.h>
205+ #include < stdint.h>
206+ #include " tp/doip/doip_client.h"
207+
208+ static bool select_by_vin (const DoIPDiscoveryInfo * info, void * user) {
209+ const char * needle = (const char * )user; // VIN prefix or full VIN
210+ if (!needle || !* needle) return false;
211+ if (info->vin[ 0] == '\0') return false;
212+ return strncmp(info->vin, needle, strlen(needle)) == 0;
213+ }
214+
215+ int main(int argc, char ** argv) {
216+ const char * vin_prefix = argc > 1 ? argv[ 1] : NULL;
217+ bool loopback = argc > 2 ? (strcmp(argv[ 2] , "loopback") == 0) : false;
218+
219+ DoIPClient_t tp;
220+ memset(&tp, 0, sizeof(tp));
221+
222+ UDSDoIPSetSelectionCallback(&tp, select_by_vin, (void*)vin_prefix);
223+
224+ int count = UDSDoIPDiscoverVehicles(&tp, 2000, loopback);
225+ printf("Discovered %d responders\n", count);
226+ printf("Selected server: %s\n", tp.server_ip);
227+ return 0;
228+ }
229+ ```
230+
231+ Build and run (ad hoc):
232+
233+ ```bash
234+ gcc -DUDS_TP_DOIP -Isrc -I. -o build/doip_discovery_example \
235+ src/tp/doip/doip_client.c src/tp/doip/doip_tp_udp.c src/tp/doip/doip_tp_tcp.c \
236+ examples/doip_discovery_example/main.c
237+
238+ # Default multicast discovery (~2s), chooses first responder
239+ ./build/doip_discovery_example
240+
241+ # Filter by VIN prefix
242+ ./build/doip_discovery_example WBA
243+
244+ # Loopback discovery for local testing
245+ ./build/doip_discovery_example "" loopback
246+ ```
0 commit comments