WPILibC++ 2027.0.0-alpha-2
Loading...
Searching...
No Matches
ntcore_c.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <stdint.h>
8
9#include <wpi/string.h>
10
11#ifdef __cplusplus
12#include <cstddef>
13#else
14#include <stddef.h>
15#endif
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21struct WPI_DataLog;
22
23/**
24 * @defgroup ntcore_c_api ntcore C API
25 *
26 * Handle-based interface for C.
27 *
28 * @{
29 */
30
31/** Typedefs */
32typedef int NT_Bool;
33
34typedef unsigned int NT_Handle;
45
46/** Default network tables port number */
47#define NT_DEFAULT_PORT 5810
48
49/** NetworkTables data types. */
65
66/** NetworkTables entry flags. */
72
73/** NetworkTables logging levels. */
85
86/** Client/server modes */
88 NT_NET_MODE_NONE = 0x00, /* not running */
89 NT_NET_MODE_SERVER = 0x01, /* running in server mode */
90 NT_NET_MODE_CLIENT = 0x04, /* running in client mode */
91 NT_NET_MODE_STARTING = 0x08, /* flag for starting (either client or server) */
92 NT_NET_MODE_LOCAL = 0x10, /* running in local-only mode */
93};
94
95/** Event notification flags. */
98 /** Initial listener addition. */
100 /** Client connected (on server, any client connected). */
102 /** Client disconnected (on server, any client disconnected). */
104 /** Any connection event (connect or disconnect). */
106 /** New topic published. */
108 /** Topic unpublished. */
110 /** Topic properties changed. */
112 /** Any topic event (publish, unpublish, or properties changed). */
114 /** Topic value updated (via network). */
116 /** Topic value updated (local). */
118 /** Topic value updated (network or local). */
120 /** Log message. */
122 /** Time synchronized with server. */
124};
125
126/*
127 * Structures
128 */
129
130/** NetworkTables Entry Value. Note this is a typed union. */
131struct NT_Value {
133 int64_t last_change;
134 int64_t server_time;
135 union {
137 int64_t v_int;
138 float v_float;
139 double v_double;
141 struct {
142 uint8_t* data;
143 size_t size;
145 struct {
147 size_t size;
149 struct {
150 double* arr;
151 size_t size;
153 struct {
154 float* arr;
155 size_t size;
157 struct {
158 int64_t* arr;
159 size_t size;
161 struct {
163 size_t size;
166};
167
168/** NetworkTables Topic Information */
170 /** Topic handle */
172
173 /** Topic name */
174 struct WPI_String name;
175
176 /** Topic type */
178
179 /** Topic type string */
181
182 /** Topic properties JSON string */
184};
185
186/** NetworkTables Connection Information */
188 /**
189 * The remote identifier (as set on the remote node by NT_StartClient().
190 */
192
193 /** The IP address of the remote node. */
195
196 /** The port number of the remote node. */
197 unsigned int remote_port;
198
199 /**
200 * The last time any update was received from the remote node (same scale as
201 * returned by nt::Now()).
202 */
203 uint64_t last_update;
204
205 /**
206 * The protocol version being used for this connection. This in protocol
207 * layer format, so 0x0200 = 2.0, 0x0300 = 3.0).
208 */
209 unsigned int protocol_version;
210};
211
212/** NetworkTables value event data. */
214 /** Topic handle. */
216
217 /** Subscriber/entry handle. */
219
220 /** The new value. */
222};
223
224/** NetworkTables log message. */
226 /** Log level of the message. See NT_LogLevel. */
227 unsigned int level;
228
229 /** The filename of the source file that generated the message. */
231
232 /** The line number in the source file that generated the message. */
233 unsigned int line;
234
235 /** The message. */
237};
238
239/** NetworkTables time sync event data. */
241 /**
242 * Offset between local time and server time, in microseconds. Add this value
243 * to local time to get the estimated equivalent server time.
244 */
246
247 /** Measured round trip time divided by 2, in microseconds. */
248 int64_t rtt2;
249
250 /**
251 * If serverTimeOffset and RTT are valid. An event with this set to false is
252 * sent when the client disconnects.
253 */
255};
256
257/** NetworkTables event */
258struct NT_Event {
259 /** Listener that triggered this event. */
261
262 /**
263 * Event flags (NT_EventFlags). Also indicates the data included with the
264 * event:
265 * - NT_EVENT_CONNECTED or NT_EVENT_DISCONNECTED: connInfo
266 * - NT_EVENT_PUBLISH, NT_EVENT_UNPUBLISH, or NT_EVENT_PROPERTIES: topicInfo
267 * - NT_EVENT_VALUE_REMOTE, NT_NOTIFY_VALUE_LOCAL: valueData
268 * - NT_EVENT_LOGMESSAGE: logMessage
269 * - NT_EVENT_TIMESYNC: timeSyncData
270 */
271 unsigned int flags;
272
273 /** Event data; content depends on flags. */
274 union {
281};
282
283/** NetworkTables publish/subscribe options. */
285 /**
286 * Structure size. Must be set to sizeof(NT_PubSubOptions).
287 */
288 unsigned int structSize;
289
290 /**
291 * Polling storage size for a subscription. Specifies the maximum number of
292 * updates NetworkTables should store between calls to the subscriber's
293 * ReadQueue() function. If zero, defaults to 1 if sendAll is false, 20 if
294 * sendAll is true.
295 */
296 unsigned int pollStorage;
297
298 /**
299 * How frequently changes will be sent over the network, in seconds.
300 * NetworkTables may send more frequently than this (e.g. use a combined
301 * minimum period for all values) or apply a restricted range to this value.
302 * The default is 100 ms.
303 */
304 double periodic;
305
306 /**
307 * For subscriptions, if non-zero, value updates for ReadQueue() are not
308 * queued for this publisher.
309 */
311
312 /**
313 * Send all value changes over the network.
314 */
316
317 /**
318 * For subscriptions, don't ask for value changes (only topic announcements).
319 */
321
322 /**
323 * Perform prefix match on subscriber topic names. Is ignored/overridden by
324 * Subscribe() functions; only present in struct for the purposes of getting
325 * information about subscriptions.
326 */
328
329 /**
330 * Preserve duplicate value changes (rather than ignoring them).
331 */
333
334 /**
335 * For subscriptions, if remote value updates should not be queued for
336 * ReadQueue(). See also disableLocal.
337 */
339
340 /**
341 * For subscriptions, if local value updates should not be queued for
342 * ReadQueue(). See also disableRemote.
343 */
345
346 /**
347 * For entries, don't queue (for ReadQueue) value updates for the entry's
348 * internal publisher.
349 */
351
352 /**
353 * For subscriptions, don't share the existence of the subscription with the
354 * network. Note this means updates will not be received from the network
355 * unless another subscription overlaps with this one, and the subscription
356 * will not appear in metatopics.
357 */
359};
360
361/**
362 * @defgroup ntcore_instance_cfunc Instance Functions
363 * @{
364 */
365
366/**
367 * Get default instance.
368 * This is the instance used by non-handle-taking functions.
369 *
370 * @return Instance handle
371 */
373
374/**
375 * Create an instance.
376 *
377 * @return Instance handle
378 */
380
381/**
382 * Destroy an instance.
383 * The default instance cannot be destroyed.
384 *
385 * @param inst Instance handle
386 */
388
389/**
390 * Get instance handle from another handle.
391 *
392 * @param handle handle
393 * @return Instance handle
394 */
396
397/** @} */
398
399/**
400 * @defgroup ntcore_table_cfunc Table Functions
401 * @{
402 */
403
404/**
405 * Get Entry Handle.
406 *
407 * @param inst instance handle
408 * @param name entry name (UTF-8 string)
409 * @return entry handle
410 */
411NT_Entry NT_GetEntry(NT_Inst inst, const struct WPI_String* name);
412
413/**
414 * Gets the name of the specified entry.
415 * Returns an empty string if the handle is invalid.
416 *
417 * @param entry entry handle
418 * @param name entry name (output parameter)
419 */
420void NT_GetEntryName(NT_Entry entry, struct WPI_String* name);
421
422/**
423 * Gets the type for the specified key, or unassigned if non existent.
424 *
425 * @param entry entry handle
426 * @return Entry type
427 */
429
430/**
431 * Gets the last time the entry was changed.
432 * Returns 0 if the handle is invalid.
433 *
434 * @param entry entry handle
435 * @return Entry last change time
436 */
438
439/**
440 * Get Entry Value.
441 *
442 * Returns copy of current entry value.
443 * Note that one of the type options is "unassigned".
444 *
445 * @param entry entry handle
446 * @param value storage for returned entry value
447 *
448 * It is the caller's responsibility to free value once it's no longer
449 * needed (the utility function NT_DisposeValue() is useful for this
450 * purpose).
451 */
452void NT_GetEntryValue(NT_Entry entry, struct NT_Value* value);
453
454/**
455 * Get Entry Value.
456 *
457 * Returns copy of current entry value.
458 * Note that one of the type options is "unassigned".
459 *
460 * @param entry entry handle
461 * @param types bitmask of NT_Type values; 0 is treated specially
462 * as a "don't care"
463 * @param value storage for returned entry value
464 *
465 * It is the caller's responsibility to free value once it's no longer
466 * needed (the utility function NT_DisposeValue() is useful for this
467 * purpose).
468 */
469void NT_GetEntryValueType(NT_Entry entry, unsigned int types,
470 struct NT_Value* value);
471
472/**
473 * Set Default Entry Value.
474 *
475 * Returns 0 if name exists.
476 * Otherwise, sets passed in value, and returns 1.
477 * Note that one of the type options is "unassigned".
478 *
479 * @param entry entry handle
480 * @param default_value value to be set if name does not exist
481 * @return 0 on error (value not set), 1 on success
482 */
484 const struct NT_Value* default_value);
485
486/**
487 * Set Entry Value.
488 *
489 * Sets new entry value. If type of new value differs from the type of the
490 * currently stored entry, returns error and does not update value.
491 *
492 * @param entry entry handle
493 * @param value new entry value
494 * @return 0 on error (type mismatch), 1 on success
495 */
496NT_Bool NT_SetEntryValue(NT_Entry entry, const struct NT_Value* value);
497
498/**
499 * Set Entry Flags.
500 *
501 * @param entry entry handle
502 * @param flags flags value (bitmask of NT_EntryFlags)
503 */
504void NT_SetEntryFlags(NT_Entry entry, unsigned int flags);
505
506/**
507 * Get Entry Flags.
508 *
509 * @param entry entry handle
510 * @return Flags value (bitmask of NT_EntryFlags)
511 */
512unsigned int NT_GetEntryFlags(NT_Entry entry);
513
514/**
515 * Read Entry Queue.
516 *
517 * Returns new entry values since last call. The returned array must be freed
518 * using NT_DisposeValueArray().
519 *
520 * @param subentry subscriber or entry handle
521 * @param count count of items in returned array (output)
522 * @return entry value array; returns NULL and count=0 if no new values
523 */
524struct NT_Value* NT_ReadQueueValue(NT_Handle subentry, size_t* count);
525
526/**
527 * Read Entry Queue.
528 *
529 * Returns new entry values since last call. The returned array must be freed
530 * using NT_DisposeValueArray().
531 *
532 * @param subentry subscriber or entry handle
533 * @param types bitmask of NT_Type values; 0 is treated specially
534 * as a "don't care"
535 * @param count count of items in returned array (output)
536 * @return entry value array; returns NULL and count=0 if no new values
537 */
538struct NT_Value* NT_ReadQueueValueType(NT_Handle subentry, unsigned int types,
539 size_t* count);
540
541/** @} */
542
543/**
544 * @defgroup ntcore_topic_cfunc Topic Functions
545 * @{
546 */
547
548/**
549 * Get Published Topic Handles.
550 *
551 * Returns an array of topic handles. The results are optionally
552 * filtered by string prefix and type to only return a subset of all
553 * topics.
554 *
555 * @param inst instance handle
556 * @param prefix name required prefix; only topics whose name
557 * starts with this string are returned
558 * @param types bitmask of NT_Type values; 0 is treated specially
559 * as a "don't care"
560 * @param count output parameter; set to length of returned array
561 * @return Array of topic handles.
562 */
563NT_Topic* NT_GetTopics(NT_Inst inst, const struct WPI_String* prefix,
564 unsigned int types, size_t* count);
565
566/**
567 * Get Published Topic Handles.
568 *
569 * Returns an array of topic handles. The results are optionally
570 * filtered by string prefix and type to only return a subset of all
571 * topics.
572 *
573 * @param inst instance handle
574 * @param prefix name required prefix; only topics whose name
575 * starts with this string are returned
576 * @param types array of type strings
577 * @param types_len number of elements in types array
578 * @param count output parameter; set to length of returned array
579 * @return Array of topic handles.
580 */
581NT_Topic* NT_GetTopicsStr(NT_Inst inst, const struct WPI_String* prefix,
582 const struct WPI_String* types, size_t types_len,
583 size_t* count);
584
585/**
586 * Get Topics.
587 *
588 * Returns an array of topic information (handle, name, type). The results are
589 * optionally filtered by string prefix and type to only return a subset
590 * of all topics.
591 *
592 * @param inst instance handle
593 * @param prefix name required prefix; only topics whose name
594 * starts with this string are returned
595 * @param types bitmask of NT_Type values; 0 is treated specially
596 * as a "don't care"
597 * @param count output parameter; set to length of returned array
598 * @return Array of topic information.
599 */
601 const struct WPI_String* prefix,
602 unsigned int types, size_t* count);
603
604/**
605 * Get Topics.
606 *
607 * Returns an array of topic information (handle, name, type). The results are
608 * optionally filtered by string prefix and type to only return a subset
609 * of all topics.
610 *
611 * @param inst instance handle
612 * @param prefix name required prefix; only topics whose name
613 * starts with this string are returned
614 * @param types array of type strings
615 * @param types_len number of elements in types array
616 * @param count output parameter; set to length of returned array
617 * @return Array of topic information.
618 */
620 const struct WPI_String* prefix,
621 const struct WPI_String* types,
622 size_t types_len, size_t* count);
623
624/**
625 * Gets Topic Information.
626 *
627 * Returns information about a topic (name and type).
628 *
629 * @param topic handle
630 * @param info information (output)
631 * @return True if successful, false on error.
632 */
634
635/**
636 * Gets Topic Handle.
637 *
638 * Returns topic handle.
639 *
640 * @param inst instance handle
641 * @param name topic name
642 * @return Topic handle.
643 */
644NT_Topic NT_GetTopic(NT_Inst inst, const struct WPI_String* name);
645
646/**
647 * Gets the name of the specified topic.
648 *
649 * @param topic topic handle
650 * @param name topic name (output); return length of 0 and nullptr if
651 * handle is invalid.
652 */
654
655/**
656 * Gets the type for the specified topic, or unassigned if non existent.
657 *
658 * @param topic topic handle
659 * @return Topic type
660 */
662
663/**
664 * Gets the type string for the specified topic. This may have more information
665 * than the numeric type (especially for raw values).
666 *
667 * @param topic topic handle
668 * @param type topic type string (output)
669 */
671
672/**
673 * Sets the persistent property of a topic. If true, the stored value is
674 * persistent through server restarts.
675 *
676 * @param topic topic handle
677 * @param value True for persistent, false for not persistent.
678 */
680
681/**
682 * Gets the persistent property of a topic.
683 *
684 * @param topic topic handle
685 * @return persistent property value
686 */
688
689/**
690 * Sets the retained property of a topic. If true, the server retains the
691 * topic even when there are no publishers.
692 *
693 * @param topic topic handle
694 * @param value new retained property value
695 */
697
698/**
699 * Gets the retained property of a topic.
700 *
701 * @param topic topic handle
702 * @return retained property value
703 */
705
706/**
707 * Sets the cached property of a topic. If true, the server and clients will
708 * store the latest value, allowing the value to be read (and not just accessed
709 * through event queues and listeners).
710 *
711 * @param topic topic handle
712 * @param value True for cached, false for not cached
713 */
715
716/**
717 * Gets the cached property of a topic.
718 *
719 * @param topic topic handle
720 * @return cached property value
721 */
723
724/**
725 * Determine if topic exists (e.g. has at least one publisher).
726 *
727 * @param handle Topic, entry, or subscriber handle.
728 * @return True if topic exists.
729 */
731
732/**
733 * Gets the current value of a property (as a JSON string).
734 *
735 * @param topic topic handle
736 * @param name property name
737 * @param property JSON string (output)
738 */
740 struct WPI_String* property);
741
742/**
743 * Sets a property value.
744 *
745 * @param topic topic handle
746 * @param name property name
747 * @param value property value (JSON string)
748 */
750 const struct WPI_String* value);
751
752/**
753 * Deletes a property. Has no effect if the property does not exist.
754 *
755 * @param topic topic handle
756 * @param name property name
757 */
759
760/**
761 * Gets all topic properties as a JSON string. Each key in the object
762 * is the property name, and the corresponding value is the property value.
763 *
764 * @param topic topic handle
765 * @param properties JSON string (output)
766 */
768
769/**
770 * Updates multiple topic properties. Each key in the passed-in JSON object is
771 * the name of the property to add/update, and the corresponding value is the
772 * property value to set for that property. Null values result in deletion
773 * of the corresponding property.
774 *
775 * @param topic topic handle
776 * @param properties JSON object string with keys to add/update/delete
777 * @return False if properties are not a valid JSON object
778 */
780 const struct WPI_String* properties);
781
782/**
783 * Creates a new subscriber to value changes on a topic.
784 *
785 * @param topic topic handle
786 * @param type expected type
787 * @param typeStr expected type string
788 * @param options subscription options
789 * @return Subscriber handle
790 */
792 const struct WPI_String* typeStr,
793 const struct NT_PubSubOptions* options);
794
795/**
796 * Stops subscriber.
797 *
798 * @param sub subscriber handle
799 */
801
802/**
803 * Creates a new publisher to a topic.
804 *
805 * @param topic topic handle
806 * @param type type
807 * @param typeStr type string
808 * @param options publish options
809 * @return Publisher handle
810 */
812 const struct WPI_String* typeStr,
813 const struct NT_PubSubOptions* options);
814
815/**
816 * Creates a new publisher to a topic.
817 *
818 * @param topic topic handle
819 * @param type type
820 * @param typeStr type string
821 * @param properties initial properties (JSON object)
822 * @param options publish options
823 * @return Publisher handle
824 */
826 const struct WPI_String* typeStr,
827 const struct WPI_String* properties,
828 const struct NT_PubSubOptions* options);
829
830/**
831 * Stops publisher.
832 *
833 * @param pubentry publisher/entry handle
834 */
835void NT_Unpublish(NT_Handle pubentry);
836
837/**
838 * @brief Creates a new entry (subscriber and weak publisher) to a topic.
839 *
840 * @param topic topic handle
841 * @param type type
842 * @param typeStr type string
843 * @param options publish options
844 * @return Entry handle
845 */
847 const struct WPI_String* typeStr,
848 const struct NT_PubSubOptions* options);
849
850/**
851 * Stops entry subscriber/publisher.
852 *
853 * @param entry entry handle
854 */
856
857/**
858 * Stops entry/subscriber/publisher.
859 *
860 * @param pubsubentry entry/subscriber/publisher handle
861 */
862void NT_Release(NT_Handle pubsubentry);
863
864/**
865 * Gets the topic handle from an entry/subscriber/publisher handle.
866 *
867 * @param pubsubentry entry/subscriber/publisher handle
868 * @return Topic handle
869 */
871
872/** @} */
873
874/**
875 * @defgroup ntcore_advancedsub_cfunc Advanced Subscriber Functions
876 * @{
877 */
878
879/**
880 * Subscribes to multiple topics based on one or more topic name prefixes. Can
881 * be used in combination with a Value Listener or ReadQueueValue() to get value
882 * changes across all matching topics.
883 *
884 * @param inst instance handle
885 * @param prefixes topic name prefixes
886 * @param prefixes_len number of elements in prefixes array
887 * @param options subscriber options
888 * @return subscriber handle
889 */
891 const struct WPI_String* prefixes,
892 size_t prefixes_len,
893 const struct NT_PubSubOptions* options);
894
895/**
896 * Unsubscribes a multi-subscriber.
897 *
898 * @param sub multi-subscriber handle
899 */
901
902/** @} */
903
904/**
905 * @defgroup ntcore_listener_cfunc Listener Functions
906 * @{
907 */
908
909/**
910 * Event listener callback function.
911 *
912 * @param data data pointer provided to callback creation function
913 * @param event event info
914 */
915typedef void (*NT_ListenerCallback)(void* data, const struct NT_Event* event);
916
917/**
918 * Creates a listener poller.
919 *
920 * A poller provides a single queue of poll events. Events linked to this
921 * poller (using NT_AddPolledXListener()) will be stored in the queue and
922 * must be collected by calling NT_ReadListenerQueue().
923 * The returned handle must be destroyed with NT_DestroyListenerPoller().
924 *
925 * @param inst instance handle
926 * @return poller handle
927 */
929
930/**
931 * Destroys a listener poller. This will abort any blocked polling
932 * call and prevent additional events from being generated for this poller.
933 *
934 * @param poller poller handle
935 */
937
938/**
939 * Read notifications.
940 *
941 * @param poller poller handle
942 * @param len length of returned array (output)
943 * @return Array of events. Returns NULL and len=0 if no events since last
944 * call.
945 */
947
948/**
949 * Removes a listener.
950 *
951 * @param listener Listener handle to remove
952 */
954
955/**
956 * Wait for the listener queue to be empty. This is primarily useful
957 * for deterministic testing. This blocks until either the listener
958 * queue is empty (e.g. there are no more events that need to be passed along to
959 * callbacks or poll queues) or the timeout expires.
960 *
961 * @param handle handle
962 * @param timeout timeout, in seconds. Set to 0 for non-blocking behavior, or a
963 * negative value to block indefinitely
964 * @return False if timed out, otherwise true.
965 */
967
968/**
969 * Create a listener for changes to topics with names that start with
970 * the given prefix. This creates a corresponding internal subscriber with the
971 * lifetime of the listener.
972 *
973 * @param inst Instance handle
974 * @param prefix Topic name string prefix
975 * @param mask Bitmask of NT_EventFlags values (only topic and value events will
976 * be generated)
977 * @param data Data passed to callback function
978 * @param callback Listener function
979 * @return Listener handle
980 */
982 unsigned int mask, void* data,
983 NT_ListenerCallback callback);
984
985/**
986 * Create a listener for changes to topics with names that start with any of
987 * the given prefixes. This creates a corresponding internal subscriber with the
988 * lifetime of the listener.
989 *
990 * @param inst Instance handle
991 * @param prefixes Topic name string prefixes
992 * @param prefixes_len Number of elements in prefixes array
993 * @param mask Bitmask of NT_EventFlags values (only topic and value events will
994 * be generated)
995 * @param data Data passed to callback function
996 * @param callback Listener function
997 * @return Listener handle
998 */
1000 const struct WPI_String* prefixes,
1001 size_t prefixes_len, unsigned int mask,
1002 void* data, NT_ListenerCallback callback);
1003
1004/**
1005 * Create a listener.
1006 *
1007 * Some combinations of handle and mask have no effect:
1008 * - connection and log message events are only generated on instances
1009 * - topic and value events are only generated on non-instances
1010 *
1011 * Adding value and topic events on a topic will create a corresponding internal
1012 * subscriber with the lifetime of the listener.
1013 *
1014 * Adding a log message listener through this function will only result in
1015 * events at NT_LOG_INFO or higher; for more customized settings, use
1016 * NT_AddLogger().
1017 *
1018 * @param handle Handle
1019 * @param mask Bitmask of NT_EventFlags values
1020 * @param data Data passed to callback function
1021 * @param callback Listener function
1022 * @return Listener handle
1023 */
1024NT_Listener NT_AddListener(NT_Handle handle, unsigned int mask, void* data,
1025 NT_ListenerCallback callback);
1026
1027/**
1028 * Creates a polled topic listener. This creates a corresponding internal
1029 * subscriber with the lifetime of the listener.
1030 * The caller is responsible for calling NT_ReadListenerQueue() to poll.
1031 *
1032 * @param poller poller handle
1033 * @param prefix UTF-8 string prefix
1034 * @param mask NT_EventFlags bitmask (only topic and value events
1035 * will be generated)
1036 * @return Listener handle
1037 */
1039 const struct WPI_String* prefix,
1040 unsigned int mask);
1041
1042/**
1043 * Creates a polled topic listener. This creates a corresponding internal
1044 * subscriber with the lifetime of the listener.
1045 * The caller is responsible for calling NT_ReadListenerQueue() to poll.
1046 *
1047 * @param poller poller handle
1048 * @param prefixes array of UTF-8 string prefixes
1049 * @param prefixes_len Length of prefixes array
1050 * @param mask NT_EventFlags bitmask (only topic and value events
1051 * will be generated)
1052 * @return Listener handle
1053 */
1055 const struct WPI_String* prefixes,
1056 size_t prefixes_len,
1057 unsigned int mask);
1058
1059/**
1060 * Creates a polled listener.
1061 * The caller is responsible for calling NT_ReadListenerQueue() to poll.
1062 *
1063 * Some combinations of handle and mask have no effect:
1064 * - connection and log message events are only generated on instances
1065 * - topic and value events are only generated on non-instances
1066 *
1067 * Adding value and topic events on a topic will create a corresponding internal
1068 * subscriber with the lifetime of the listener.
1069 *
1070 * Adding a log message listener through this function will only result in
1071 * events at NT_LOG_INFO or higher; for more customized settings, use
1072 * NT_AddPolledLogger().
1073 *
1074 * @param poller poller handle
1075 * @param handle handle
1076 * @param mask NT_NotifyKind bitmask
1077 * @return Listener handle
1078 */
1080 unsigned int mask);
1081
1082/** @} */
1083
1084/**
1085 * @defgroup ntcore_network_cfunc Client/Server Functions
1086 * @{
1087 */
1088
1089/**
1090 * Get the current network mode.
1091 *
1092 * @param inst instance handle
1093 * @return Bitmask of NT_NetworkMode.
1094 */
1095unsigned int NT_GetNetworkMode(NT_Inst inst);
1096
1097/**
1098 * Starts local-only operation. Prevents calls to NT_StartServer or
1099 * NT_StartClient from taking effect. Has no effect if NT_StartServer or
1100 * NT_StartClient has already been called.
1101 */
1103
1104/**
1105 * Stops local-only operation. NT_StartServer or NT_StartClient can be called
1106 * after this call to start a server or client.
1107 */
1109
1110/**
1111 * Starts a server using the specified filename, listening address, and port.
1112 *
1113 * @param inst instance handle
1114 * @param persist_filename the name of the persist file to use (UTF-8 string,
1115 * null terminated)
1116 * @param listen_address the address to listen on, or an empty string to
1117 * listen on any address. (UTF-8 string, null
1118 * terminated)
1119 * @param port port to communicate over
1120 */
1121void NT_StartServer(NT_Inst inst, const struct WPI_String* persist_filename,
1122 const struct WPI_String* listen_address, unsigned int port);
1123
1124/**
1125 * Stops the server if it is running.
1126 *
1127 * @param inst instance handle
1128 */
1130
1131/**
1132 * Starts a client. Use NT_SetServer or NT_SetServerTeam to set the server
1133 * name and port.
1134 *
1135 * @param inst instance handle
1136 * @param identity network identity to advertise (cannot be empty string)
1137 */
1138void NT_StartClient(NT_Inst inst, const struct WPI_String* identity);
1139
1140/**
1141 * Stops the client if it is running.
1142 *
1143 * @param inst instance handle
1144 */
1146
1147/**
1148 * Sets server address and port for client (without restarting client).
1149 *
1150 * @param inst instance handle
1151 * @param server_name server name (UTF-8 string, null terminated)
1152 * @param port port to communicate over
1153 */
1154void NT_SetServer(NT_Inst inst, const struct WPI_String* server_name,
1155 unsigned int port);
1156
1157/**
1158 * Sets server addresses for client (without restarting client).
1159 * The client will attempt to connect to each server in round robin fashion.
1160 *
1161 * @param inst instance handle
1162 * @param count length of the server_names and ports arrays
1163 * @param server_names array of server names (each a UTF-8 string, null
1164 * terminated)
1165 * @param ports array of ports to communicate over (one for each server)
1166 */
1167void NT_SetServerMulti(NT_Inst inst, size_t count,
1168 const struct WPI_String* server_names,
1169 const unsigned int* ports);
1170
1171/**
1172 * Sets server addresses and port for client (without restarting client).
1173 * Connects using commonly known robot addresses for the specified team.
1174 *
1175 * @param inst instance handle
1176 * @param team team number
1177 * @param port port to communicate over
1178 */
1179void NT_SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port);
1180
1181/**
1182 * Disconnects the client if it's running and connected. This will automatically
1183 * start reconnection attempts to the current server list.
1184 *
1185 * @param inst instance handle
1186 */
1188
1189/**
1190 * Starts requesting server address from Driver Station.
1191 * This connects to the Driver Station running on localhost to obtain the
1192 * server IP address.
1193 *
1194 * @param inst instance handle
1195 * @param port server port to use in combination with IP from DS
1196 */
1197void NT_StartDSClient(NT_Inst inst, unsigned int port);
1198
1199/**
1200 * Stops requesting server address from Driver Station.
1201 *
1202 * @param inst instance handle
1203 */
1205
1206/**
1207 * Flush local updates.
1208 *
1209 * Forces an immediate flush of all local changes to the client/server.
1210 * This does not flush to the network.
1211 *
1212 * Normally this is done on a regularly scheduled interval.
1213 *
1214 * @param inst instance handle
1215 */
1217
1218/**
1219 * Flush to network.
1220 *
1221 * Forces an immediate flush of all local entry changes to network.
1222 * Normally this is done on a regularly scheduled interval (set
1223 * by update rates on individual publishers).
1224 *
1225 * Note: flushes are rate limited to avoid excessive network traffic. If
1226 * the time between calls is too short, the flush will occur after the minimum
1227 * time elapses (rather than immediately).
1228 *
1229 * @param inst instance handle
1230 */
1232
1233/**
1234 * Get information on the currently established network connections.
1235 * If operating as a client, this will return either zero or one values.
1236 *
1237 * @param inst instance handle
1238 * @param count returns the number of elements in the array
1239 * @return array of connection information
1240 *
1241 * It is the caller's responsibility to free the array. The
1242 * NT_DisposeConnectionInfoArray function is useful for this purpose.
1243 */
1244struct NT_ConnectionInfo* NT_GetConnections(NT_Inst inst, size_t* count);
1245
1246/**
1247 * Return whether or not the instance is connected to another node.
1248 *
1249 * @param inst instance handle
1250 * @return True if connected.
1251 */
1253
1254/**
1255 * Get the time offset between server time and local time. Add this value to
1256 * local time to get the estimated equivalent server time. In server mode, this
1257 * always returns a valid value of 0. In client mode, this returns the time
1258 * offset only if the client and server are connected and have exchanged
1259 * synchronization messages. Note the time offset may change over time as it is
1260 * periodically updated; to receive updates as events, add a listener to the
1261 * "time sync" event.
1262 *
1263 * @param inst instance handle
1264 * @param valid set to true if the return value is valid, false otherwise
1265 * (output)
1266 * @return Time offset in microseconds (if valid is set to true)
1267 */
1269
1270/** @} */
1271
1272/**
1273 * @defgroup ntcore_utility_cfunc Utility Functions
1274 * @{
1275 */
1276
1277/**
1278 * Frees value memory.
1279 *
1280 * @param value value to free
1281 */
1282void NT_DisposeValue(struct NT_Value* value);
1283
1284/**
1285 * Initializes a NT_Value.
1286 * Sets type to NT_UNASSIGNED and clears rest of struct.
1287 *
1288 * @param value value to initialize
1289 */
1290void NT_InitValue(struct NT_Value* value);
1291
1292/**
1293 * Frees an array of NT_Values.
1294 *
1295 * @param arr pointer to the value array to free
1296 * @param count number of elements in the array
1297 *
1298 * Note that the individual NT_Values in the array should NOT be
1299 * freed before calling this. This function will free all the values
1300 * individually.
1301 */
1302void NT_DisposeValueArray(struct NT_Value* arr, size_t count);
1303
1304/**
1305 * Disposes a connection info array.
1306 *
1307 * @param arr pointer to the array to dispose
1308 * @param count number of elements in the array
1309 */
1310void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo* arr, size_t count);
1311
1312/**
1313 * Disposes a topic info array.
1314 *
1315 * @param arr pointer to the array to dispose
1316 * @param count number of elements in the array
1317 */
1318void NT_DisposeTopicInfoArray(struct NT_TopicInfo* arr, size_t count);
1319
1320/**
1321 * Disposes a single topic info (as returned by NT_GetTopicInfo).
1322 *
1323 * @param info pointer to the info to dispose
1324 */
1326
1327/**
1328 * Disposes an event array.
1329 *
1330 * @param arr pointer to the array to dispose
1331 * @param count number of elements in the array
1332 */
1333void NT_DisposeEventArray(struct NT_Event* arr, size_t count);
1334
1335/**
1336 * Disposes a single event.
1337 *
1338 * @param event pointer to the event to dispose
1339 */
1340void NT_DisposeEvent(struct NT_Event* event);
1341
1342/**
1343 * Returns monotonic current time in 1 us increments.
1344 * This is the same time base used for entry and connection timestamps.
1345 * This function by default simply wraps WPI_Now(), but if NT_SetNow() is
1346 * called, this function instead returns the value passed to NT_SetNow();
1347 * this can be used to reduce overhead.
1348 *
1349 * @return Timestamp
1350 */
1351int64_t NT_Now(void);
1352
1353/**
1354 * Sets the current timestamp used for timestamping values that do not
1355 * provide a timestamp (e.g. a value of 0 is passed). For consistency,
1356 * it also results in NT_Now() returning the set value. This should generally
1357 * be used only if the overhead of calling WPI_Now() is a concern.
1358 * If used, it should be called periodically with the value of WPI_Now().
1359 *
1360 * @param timestamp timestamp (1 us increments)
1361 */
1362void NT_SetNow(int64_t timestamp);
1363
1364/** @} */
1365
1366/**
1367 * @defgroup ntcore_data_logger_cfunc Data Logger Functions
1368 * @{
1369 */
1370
1371/**
1372 * Starts logging entry changes to a DataLog.
1373 *
1374 * @param inst instance handle
1375 * @param log data log object; lifetime must extend until StopEntryDataLog is
1376 * called or the instance is destroyed
1377 * @param prefix only store entries with names that start with this prefix;
1378 * the prefix is not included in the data log entry name
1379 * @param logPrefix prefix to add to data log entry names
1380 * @return Data logger handle
1381 */
1382NT_DataLogger NT_StartEntryDataLog(NT_Inst inst, struct WPI_DataLog* log,
1383 const struct WPI_String* prefix,
1384 const struct WPI_String* logPrefix);
1385
1386/**
1387 * Stops logging entry changes to a DataLog.
1388 *
1389 * @param logger data logger handle
1390 */
1392
1393/**
1394 * Starts logging connection changes to a DataLog.
1395 *
1396 * @param inst instance handle
1397 * @param log data log object; lifetime must extend until StopConnectionDataLog
1398 * is called or the instance is destroyed
1399 * @param name data log entry name
1400 * @return Data logger handle
1401 */
1403 NT_Inst inst, struct WPI_DataLog* log, const struct WPI_String* name);
1404
1405/**
1406 * Stops logging connection changes to a DataLog.
1407 *
1408 * @param logger data logger handle
1409 */
1411
1412/** @} */
1413
1414/**
1415 * @defgroup ntcore_logger_cfunc Logger Functions
1416 * @{
1417 */
1418
1419/**
1420 * Add logger callback function. By default, log messages are sent to stderr;
1421 * this function sends log messages to the provided callback function instead.
1422 * The callback function will only be called for log messages with level
1423 * greater than or equal to min_level and less than or equal to max_level;
1424 * messages outside this range will be silently ignored.
1425 *
1426 * @param inst instance handle
1427 * @param min_level minimum log level
1428 * @param max_level maximum log level
1429 * @param data data pointer to pass to func
1430 * @param func listener callback function
1431 * @return Listener handle
1432 */
1433NT_Listener NT_AddLogger(NT_Inst inst, unsigned int min_level,
1434 unsigned int max_level, void* data,
1435 NT_ListenerCallback func);
1436
1437/**
1438 * Set the log level for a listener poller. Events will only be generated for
1439 * log messages with level greater than or equal to min_level and less than or
1440 * equal to max_level; messages outside this range will be silently ignored.
1441 *
1442 * @param poller poller handle
1443 * @param min_level minimum log level
1444 * @param max_level maximum log level
1445 * @return Listener handle
1446 */
1447NT_Listener NT_AddPolledLogger(NT_ListenerPoller poller, unsigned int min_level,
1448 unsigned int max_level);
1449
1450/** @} */
1451
1452/**
1453 * @defgroup ntcore_schema_cfunc Schema Functions
1454 * @{
1455 */
1456
1457/**
1458 * Returns whether there is a data schema already registered with the given
1459 * name. This does NOT perform a check as to whether the schema has already
1460 * been published by another node on the network.
1461 *
1462 * @param inst instance
1463 * @param name Name (the string passed as the data type for topics using this
1464 * schema)
1465 * @return True if schema already registered
1466 */
1467NT_Bool NT_HasSchema(NT_Inst inst, const struct WPI_String* name);
1468
1469/**
1470 * Registers a data schema. Data schemas provide information for how a
1471 * certain data type string can be decoded. The type string of a data schema
1472 * indicates the type of the schema itself (e.g. "protobuf" for protobuf
1473 * schemas, "struct" for struct schemas, etc). In NetworkTables, schemas are
1474 * published just like normal topics, with the name being generated from the
1475 * provided name: "/.schema/<name>". Duplicate calls to this function with
1476 * the same name are silently ignored.
1477 *
1478 * @param inst instance
1479 * @param name Name (the string passed as the data type for topics using this
1480 * schema)
1481 * @param type Type of schema (e.g. "protobuf", "struct", etc)
1482 * @param schema Schema data
1483 * @param schemaSize Size of schema data
1484 */
1485void NT_AddSchema(NT_Inst inst, const struct WPI_String* name,
1486 const struct WPI_String* type, const uint8_t* schema,
1487 size_t schemaSize);
1488
1489/** @} */
1490
1491/**
1492 * @defgroup ntcore_interop_cfunc Interop Utility Functions
1493 * @{
1494 */
1495
1496/**
1497 * @defgroup ntcore_memoryallocators_cfunc Memory Allocators
1498 * @{
1499 */
1500
1501/**
1502 * Allocates an array of chars.
1503 * Note that the size is the number of elements, and not the
1504 * specific number of bytes to allocate. That is calculated internally.
1505 *
1506 * @param size the number of elements the array will contain
1507 * @return the allocated char array
1508 *
1509 * After use, the array should be freed using the NT_FreeCharArray()
1510 * function.
1511 */
1512char* NT_AllocateCharArray(size_t size);
1513
1514/**
1515 * Allocates an array of booleans.
1516 * Note that the size is the number of elements, and not the
1517 * specific number of bytes to allocate. That is calculated internally.
1518 *
1519 * @param size the number of elements the array will contain
1520 * @return the allocated boolean array
1521 *
1522 * After use, the array should be freed using the NT_FreeBooleanArray()
1523 * function.
1524 */
1526
1527/**
1528 * Allocates an array of ints.
1529 * Note that the size is the number of elements, and not the
1530 * specific number of bytes to allocate. That is calculated internally.
1531 *
1532 * @param size the number of elements the array will contain
1533 * @return the allocated double array
1534 *
1535 * After use, the array should be freed using the NT_FreeIntArray()
1536 * function.
1537 */
1538int64_t* NT_AllocateIntegerArray(size_t size);
1539
1540/**
1541 * Allocates an array of floats.
1542 * Note that the size is the number of elements, and not the
1543 * specific number of bytes to allocate. That is calculated internally.
1544 *
1545 * @param size the number of elements the array will contain
1546 * @return the allocated double array
1547 *
1548 * After use, the array should be freed using the NT_FreeFloatArray()
1549 * function.
1550 */
1551float* NT_AllocateFloatArray(size_t size);
1552
1553/**
1554 * Allocates an array of doubles.
1555 * Note that the size is the number of elements, and not the
1556 * specific number of bytes to allocate. That is calculated internally.
1557 *
1558 * @param size the number of elements the array will contain
1559 * @return the allocated double array
1560 *
1561 * After use, the array should be freed using the NT_FreeDoubleArray()
1562 * function.
1563 */
1564double* NT_AllocateDoubleArray(size_t size);
1565
1566/**
1567 * Frees an array of chars.
1568 *
1569 * @param v_char pointer to the char array to free
1570 */
1571void NT_FreeCharArray(char* v_char);
1572
1573/**
1574 * Frees an array of booleans.
1575 *
1576 * @param v_boolean pointer to the boolean array to free
1577 */
1579
1580/**
1581 * Frees an array of ints.
1582 *
1583 * @param v_int pointer to the int array to free
1584 */
1585void NT_FreeIntegerArray(int64_t* v_int);
1586
1587/**
1588 * Frees an array of floats.
1589 *
1590 * @param v_float pointer to the float array to free
1591 */
1592void NT_FreeFloatArray(float* v_float);
1593
1594/**
1595 * Frees an array of doubles.
1596 *
1597 * @param v_double pointer to the double array to free
1598 */
1599void NT_FreeDoubleArray(double* v_double);
1600
1601/** @} */
1602
1603/**
1604 * @defgroup ntcore_typedgetters_cfunc Typed Getters
1605 * @{
1606 */
1607
1608/**
1609 * Returns the type of an NT_Value struct.
1610 * Note that one of the type options is "unassigned".
1611 *
1612 * @param value The NT_Value struct to get the type from.
1613 * @return The type of the value, or unassigned if null.
1614 */
1615enum NT_Type NT_GetValueType(const struct NT_Value* value);
1616
1617/**
1618 * Returns the boolean from the NT_Value.
1619 * If the NT_Value is null, or is assigned to a different type, returns 0.
1620 *
1621 * @param value NT_Value struct to get the boolean from
1622 * @param last_change returns time in ms since the last change in the value
1623 * @param v_boolean returns the boolean assigned to the name
1624 * @return 1 if successful, or 0 if value is null or not a boolean
1625 */
1626NT_Bool NT_GetValueBoolean(const struct NT_Value* value, uint64_t* last_change,
1627 NT_Bool* v_boolean);
1628
1629/**
1630 * Returns the int from the NT_Value.
1631 * If the NT_Value is null, or is assigned to a different type, returns 0.
1632 *
1633 * @param value NT_Value struct to get the int from
1634 * @param last_change returns time in ms since the last change in the value
1635 * @param v_int returns the int assigned to the name
1636 * @return 1 if successful, or 0 if value is null or not an int
1637 */
1638NT_Bool NT_GetValueInteger(const struct NT_Value* value, uint64_t* last_change,
1639 int64_t* v_int);
1640
1641/**
1642 * Returns the float from the NT_Value.
1643 * If the NT_Value is null, or is assigned to a different type, returns 0.
1644 *
1645 * @param value NT_Value struct to get the float from
1646 * @param last_change returns time in ms since the last change in the value
1647 * @param v_float returns the float assigned to the name
1648 * @return 1 if successful, or 0 if value is null or not a float
1649 */
1650NT_Bool NT_GetValueFloat(const struct NT_Value* value, uint64_t* last_change,
1651 float* v_float);
1652
1653/**
1654 * Returns the double from the NT_Value.
1655 * If the NT_Value is null, or is assigned to a different type, returns 0.
1656 *
1657 * @param value NT_Value struct to get the double from
1658 * @param last_change returns time in ms since the last change in the value
1659 * @param v_double returns the double assigned to the name
1660 * @return 1 if successful, or 0 if value is null or not a double
1661 */
1662NT_Bool NT_GetValueDouble(const struct NT_Value* value, uint64_t* last_change,
1663 double* v_double);
1664
1665/**
1666 * Returns a copy of the string from the NT_Value.
1667 * If the NT_Value is null, or is assigned to a different type, returns 0.
1668 *
1669 * @param value NT_Value struct to get the string from
1670 * @param last_change returns time in ms since the last change in the value
1671 * @param str_len returns the length of the string
1672 * @return pointer to the string (UTF-8), or null if error
1673 *
1674 * It is the caller's responsibility to free the string once its no longer
1675 * needed. The NT_FreeCharArray() function is useful for this purpose. The
1676 * returned string is a copy of the string in the value, and must be freed
1677 * separately.
1678 */
1679char* NT_GetValueString(const struct NT_Value* value, uint64_t* last_change,
1680 size_t* str_len);
1681
1682/**
1683 * Returns a copy of the raw value from the NT_Value.
1684 * If the NT_Value is null, or is assigned to a different type, returns null.
1685 *
1686 * @param value NT_Value struct to get the string from
1687 * @param last_change returns time in ms since the last change in the value
1688 * @param raw_len returns the length of the string
1689 * @return pointer to the raw value (UTF-8), or null if error
1690 *
1691 * It is the caller's responsibility to free the raw value once its no longer
1692 * needed. The NT_FreeCharArray() function is useful for this purpose. The
1693 * returned string is a copy of the string in the value, and must be freed
1694 * separately.
1695 */
1696uint8_t* NT_GetValueRaw(const struct NT_Value* value, uint64_t* last_change,
1697 size_t* raw_len);
1698
1699/**
1700 * Returns a copy of the boolean array from the NT_Value.
1701 * If the NT_Value is null, or is assigned to a different type, returns null.
1702 *
1703 * @param value NT_Value struct to get the boolean array from
1704 * @param last_change returns time in ms since the last change in the value
1705 * @param arr_size returns the number of elements in the array
1706 * @return pointer to the boolean array, or null if error
1707 *
1708 * It is the caller's responsibility to free the array once its no longer
1709 * needed. The NT_FreeBooleanArray() function is useful for this purpose.
1710 * The returned array is a copy of the array in the value, and must be
1711 * freed separately.
1712 */
1714 uint64_t* last_change, size_t* arr_size);
1715
1716/**
1717 * Returns a copy of the int array from the NT_Value.
1718 * If the NT_Value is null, or is assigned to a different type, returns null.
1719 *
1720 * @param value NT_Value struct to get the int array from
1721 * @param last_change returns time in ms since the last change in the value
1722 * @param arr_size returns the number of elements in the array
1723 * @return pointer to the int array, or null if error
1724 *
1725 * It is the caller's responsibility to free the array once its no longer
1726 * needed. The NT_FreeIntArray() function is useful for this purpose.
1727 * The returned array is a copy of the array in the value, and must be
1728 * freed separately.
1729 */
1730int64_t* NT_GetValueIntegerArray(const struct NT_Value* value,
1731 uint64_t* last_change, size_t* arr_size);
1732
1733/**
1734 * Returns a copy of the float array from the NT_Value.
1735 * If the NT_Value is null, or is assigned to a different type, returns null.
1736 *
1737 * @param value NT_Value struct to get the float array from
1738 * @param last_change returns time in ms since the last change in the value
1739 * @param arr_size returns the number of elements in the array
1740 * @return pointer to the float array, or null if error
1741 *
1742 * It is the caller's responsibility to free the array once its no longer
1743 * needed. The NT_FreeFloatArray() function is useful for this purpose.
1744 * The returned array is a copy of the array in the value, and must be
1745 * freed separately.
1746 */
1747float* NT_GetValueFloatArray(const struct NT_Value* value,
1748 uint64_t* last_change, size_t* arr_size);
1749
1750/**
1751 * Returns a copy of the double array from the NT_Value.
1752 * If the NT_Value is null, or is assigned to a different type, returns null.
1753 *
1754 * @param value NT_Value struct to get the double array from
1755 * @param last_change returns time in ms since the last change in the value
1756 * @param arr_size returns the number of elements in the array
1757 * @return pointer to the double array, or null if error
1758 *
1759 * It is the caller's responsibility to free the array once its no longer
1760 * needed. The NT_FreeDoubleArray() function is useful for this purpose.
1761 * The returned array is a copy of the array in the value, and must be
1762 * freed separately.
1763 */
1764double* NT_GetValueDoubleArray(const struct NT_Value* value,
1765 uint64_t* last_change, size_t* arr_size);
1766
1767/**
1768 * Returns a copy of the struct WPI_String array from the NT_Value.
1769 * If the NT_Value is null, or is assigned to a different type, returns null.
1770 *
1771 * @param value NT_Value struct to get the struct WPI_String array from
1772 * @param last_change returns time in ms since the last change in the value
1773 * @param arr_size returns the number of elements in the array
1774 * @return pointer to the struct WPI_String array, or null if error
1775 *
1776 * It is the caller's responsibility to free the array once its no longer
1777 * needed. The WPI_FreeStringArray() function is useful for this purpose.
1778 * The returned array is a copy of the array in the value, and must be
1779 * freed separately. Note that the individual struct WPI_Strings should not be
1780 * freed, but the entire array should be freed at once. The
1781 * WPI_FreeStringArray() function will free all the struct WPI_Strings.
1782 */
1783struct WPI_String* NT_GetValueStringArray(const struct NT_Value* value,
1784 uint64_t* last_change,
1785 size_t* arr_size);
1786
1787/** @} */
1788/** @} */
1789/** @} */
1790
1791/**
1792 * @defgroup ntcore_c_meta_api ntcore C meta-topic API
1793 *
1794 * Meta-topic decoders for C.
1795 *
1796 * @{
1797 */
1798
1799/**
1800 * Subscriber options. Different from PubSubOptions in this reflects only
1801 * options that are sent over the network.
1802 */
1809
1810/**
1811 * Topic publisher (as published via `$pub$<topic>`).
1812 */
1817
1818/**
1819 * Topic subscriber (as published via `$sub$<topic>`).
1820 */
1826
1827/**
1828 * Client publisher (as published via `$clientpub$<client>` or `$serverpub`).
1829 */
1834
1835/**
1836 * Client subscriber (as published via `$clientsub$<client>` or `$serversub`).
1837 */
1844
1845/**
1846 * Client (as published via `$clients`).
1847 */
1851 uint16_t version;
1852};
1853
1854/**
1855 * Decodes `$pub$<topic>` meta-topic data.
1856 *
1857 * @param data data contents
1858 * @param size size of data contents
1859 * @param count number of elements in returned array (output)
1860 * @return Array of TopicPublishers, or NULL on decoding error.
1861 */
1863 const uint8_t* data, size_t size, size_t* count);
1864
1865/**
1866 * Decodes `$sub$<topic>` meta-topic data.
1867 *
1868 * @param data data contents
1869 * @param size size of data contents
1870 * @param count number of elements in returned array (output)
1871 * @return Array of TopicSubscribers, or NULL on decoding error.
1872 */
1874 const uint8_t* data, size_t size, size_t* count);
1875
1876/**
1877 * Decodes `$clientpub$<topic>` meta-topic data.
1878 *
1879 * @param data data contents
1880 * @param size size of data contents
1881 * @param count number of elements in returned array (output)
1882 * @return Array of ClientPublishers, or NULL on decoding error.
1883 */
1885 const uint8_t* data, size_t size, size_t* count);
1886
1887/**
1888 * Decodes `$clientsub$<topic>` meta-topic data.
1889 *
1890 * @param data data contents
1891 * @param size size of data contents
1892 * @param count number of elements in returned array (output)
1893 * @return Array of ClientSubscribers, or NULL on decoding error.
1894 */
1896 const uint8_t* data, size_t size, size_t* count);
1897
1898/**
1899 * Decodes `$clients` meta-topic data.
1900 *
1901 * @param data data contents
1902 * @param size size of data contents
1903 * @param count number of elements in returned array (output)
1904 * @return Array of Clients, or NULL on decoding error.
1905 */
1906struct NT_Meta_Client* NT_Meta_DecodeClients(const uint8_t* data, size_t size,
1907 size_t* count);
1908
1909/**
1910 * Frees an array of NT_Meta_TopicPublisher.
1911 *
1912 * @param arr pointer to the array to free
1913 * @param count size of the array to free
1914 */
1916 size_t count);
1917
1918/**
1919 * Frees an array of NT_Meta_TopicSubscriber.
1920 *
1921 * @param arr pointer to the array to free
1922 * @param count size of the array to free
1923 */
1925 size_t count);
1926
1927/**
1928 * Frees an array of NT_Meta_ClientPublisher.
1929 *
1930 * @param arr pointer to the array to free
1931 * @param count size of the array to free
1932 */
1934 size_t count);
1935
1936/**
1937 * Frees an array of NT_Meta_ClientSubscriber.
1938 *
1939 * @param arr pointer to the array to free
1940 * @param count size of the array to free
1941 */
1943 size_t count);
1944
1945/**
1946 * Frees an array of NT_Meta_Client.
1947 *
1948 * @param arr pointer to the array to free
1949 * @param count size of the array to free
1950 */
1951void NT_Meta_FreeClients(struct NT_Meta_Client* arr, size_t count);
1952
1953/** @} */
1954
1955#ifdef __cplusplus
1956} // extern "C"
1957#endif
1958
1959#include "ntcore_c_types.h"
void NT_UnsubscribeMultiple(NT_MultiSubscriber sub)
Unsubscribes a multi-subscriber.
NT_MultiSubscriber NT_SubscribeMultiple(NT_Inst inst, const struct WPI_String *prefixes, size_t prefixes_len, const struct NT_PubSubOptions *options)
Subscribes to multiple topics based on one or more topic name prefixes.
NT_Handle NT_Topic
Definition ntcore_c.h:42
NT_Handle NT_ConnectionDataLogger
Definition ntcore_c.h:35
NT_Handle NT_Listener
Definition ntcore_c.h:39
NT_EntryFlags
NetworkTables entry flags.
Definition ntcore_c.h:67
int NT_Bool
Typedefs.
Definition ntcore_c.h:32
NT_LogLevel
NetworkTables logging levels.
Definition ntcore_c.h:74
NT_NetworkMode
Client/server modes.
Definition ntcore_c.h:87
NT_Handle NT_Subscriber
Definition ntcore_c.h:43
unsigned int NT_Handle
Definition ntcore_c.h:34
NT_Type
NetworkTables data types.
Definition ntcore_c.h:50
NT_Handle NT_Inst
Definition ntcore_c.h:38
NT_Handle NT_Publisher
Definition ntcore_c.h:44
NT_EventFlags
Event notification flags.
Definition ntcore_c.h:96
NT_Handle NT_ListenerPoller
Definition ntcore_c.h:40
NT_Handle NT_MultiSubscriber
Definition ntcore_c.h:41
NT_Handle NT_Entry
Definition ntcore_c.h:37
NT_Handle NT_DataLogger
Definition ntcore_c.h:36
@ NT_RETAINED
Definition ntcore_c.h:69
@ NT_PERSISTENT
Definition ntcore_c.h:68
@ NT_UNCACHED
Definition ntcore_c.h:70
@ NT_LOG_DEBUG4
Definition ntcore_c.h:83
@ NT_LOG_WARNING
Definition ntcore_c.h:77
@ NT_LOG_INFO
Definition ntcore_c.h:78
@ NT_LOG_DEBUG2
Definition ntcore_c.h:81
@ NT_LOG_DEBUG
Definition ntcore_c.h:79
@ NT_LOG_CRITICAL
Definition ntcore_c.h:75
@ NT_LOG_ERROR
Definition ntcore_c.h:76
@ NT_LOG_DEBUG3
Definition ntcore_c.h:82
@ NT_LOG_DEBUG1
Definition ntcore_c.h:80
@ NT_NET_MODE_STARTING
Definition ntcore_c.h:91
@ NT_NET_MODE_LOCAL
Definition ntcore_c.h:92
@ NT_NET_MODE_CLIENT
Definition ntcore_c.h:90
@ NT_NET_MODE_SERVER
Definition ntcore_c.h:89
@ NT_NET_MODE_NONE
Definition ntcore_c.h:88
@ NT_DOUBLE
Definition ntcore_c.h:53
@ NT_BOOLEAN
Definition ntcore_c.h:52
@ NT_DOUBLE_ARRAY
Definition ntcore_c.h:57
@ NT_STRING
Definition ntcore_c.h:54
@ NT_FLOAT_ARRAY
Definition ntcore_c.h:63
@ NT_RPC
Definition ntcore_c.h:59
@ NT_INTEGER
Definition ntcore_c.h:60
@ NT_BOOLEAN_ARRAY
Definition ntcore_c.h:56
@ NT_FLOAT
Definition ntcore_c.h:61
@ NT_STRING_ARRAY
Definition ntcore_c.h:58
@ NT_INTEGER_ARRAY
Definition ntcore_c.h:62
@ NT_UNASSIGNED
Definition ntcore_c.h:51
@ NT_RAW
Definition ntcore_c.h:55
@ NT_EVENT_VALUE_ALL
Topic value updated (network or local).
Definition ntcore_c.h:119
@ NT_EVENT_LOGMESSAGE
Log message.
Definition ntcore_c.h:121
@ NT_EVENT_NONE
Definition ntcore_c.h:97
@ NT_EVENT_UNPUBLISH
Topic unpublished.
Definition ntcore_c.h:109
@ NT_EVENT_PROPERTIES
Topic properties changed.
Definition ntcore_c.h:111
@ NT_EVENT_CONNECTED
Client connected (on server, any client connected).
Definition ntcore_c.h:101
@ NT_EVENT_TIMESYNC
Time synchronized with server.
Definition ntcore_c.h:123
@ NT_EVENT_VALUE_REMOTE
Topic value updated (via network).
Definition ntcore_c.h:115
@ NT_EVENT_PUBLISH
New topic published.
Definition ntcore_c.h:107
@ NT_EVENT_TOPIC
Any topic event (publish, unpublish, or properties changed).
Definition ntcore_c.h:113
@ NT_EVENT_CONNECTION
Any connection event (connect or disconnect).
Definition ntcore_c.h:105
@ NT_EVENT_DISCONNECTED
Client disconnected (on server, any client disconnected).
Definition ntcore_c.h:103
@ NT_EVENT_IMMEDIATE
Initial listener addition.
Definition ntcore_c.h:99
@ NT_EVENT_VALUE_LOCAL
Topic value updated (local).
Definition ntcore_c.h:117
struct NT_Meta_ClientSubscriber * NT_Meta_DecodeClientSubscribers(const uint8_t *data, size_t size, size_t *count)
Decodes $clientsub$<topic> meta-topic data.
struct NT_Meta_ClientPublisher * NT_Meta_DecodeClientPublishers(const uint8_t *data, size_t size, size_t *count)
Decodes $clientpub$<topic> meta-topic data.
struct NT_Meta_TopicPublisher * NT_Meta_DecodeTopicPublishers(const uint8_t *data, size_t size, size_t *count)
Decodes $pub$<topic> meta-topic data.
void NT_Meta_FreeClientSubscribers(struct NT_Meta_ClientSubscriber *arr, size_t count)
Frees an array of NT_Meta_ClientSubscriber.
void NT_Meta_FreeTopicSubscribers(struct NT_Meta_TopicSubscriber *arr, size_t count)
Frees an array of NT_Meta_TopicSubscriber.
struct NT_Meta_TopicSubscriber * NT_Meta_DecodeTopicSubscribers(const uint8_t *data, size_t size, size_t *count)
Decodes $sub$<topic> meta-topic data.
void NT_Meta_FreeClientPublishers(struct NT_Meta_ClientPublisher *arr, size_t count)
Frees an array of NT_Meta_ClientPublisher.
void NT_Meta_FreeClients(struct NT_Meta_Client *arr, size_t count)
Frees an array of NT_Meta_Client.
void NT_Meta_FreeTopicPublishers(struct NT_Meta_TopicPublisher *arr, size_t count)
Frees an array of NT_Meta_TopicPublisher.
struct NT_Meta_Client * NT_Meta_DecodeClients(const uint8_t *data, size_t size, size_t *count)
Decodes $clients meta-topic data.
void NT_StopConnectionDataLog(NT_ConnectionDataLogger logger)
Stops logging connection changes to a DataLog.
NT_ConnectionDataLogger NT_StartConnectionDataLog(NT_Inst inst, struct WPI_DataLog *log, const struct WPI_String *name)
Starts logging connection changes to a DataLog.
NT_DataLogger NT_StartEntryDataLog(NT_Inst inst, struct WPI_DataLog *log, const struct WPI_String *prefix, const struct WPI_String *logPrefix)
Starts logging entry changes to a DataLog.
void NT_StopEntryDataLog(NT_DataLogger logger)
Stops logging entry changes to a DataLog.
void NT_DestroyInstance(NT_Inst inst)
Destroy an instance.
NT_Inst NT_CreateInstance(void)
Create an instance.
NT_Inst NT_GetDefaultInstance(void)
Get default instance.
NT_Inst NT_GetInstanceFromHandle(NT_Handle handle)
Get instance handle from another handle.
void NT_RemoveListener(NT_Listener listener)
Removes a listener.
NT_Listener NT_AddListenerSingle(NT_Inst inst, const struct WPI_String *prefix, unsigned int mask, void *data, NT_ListenerCallback callback)
Create a listener for changes to topics with names that start with the given prefix.
void(* NT_ListenerCallback)(void *data, const struct NT_Event *event)
Event listener callback function.
Definition ntcore_c.h:915
NT_ListenerPoller NT_CreateListenerPoller(NT_Inst inst)
Creates a listener poller.
NT_Listener NT_AddPolledListenerMultiple(NT_ListenerPoller poller, const struct WPI_String *prefixes, size_t prefixes_len, unsigned int mask)
Creates a polled topic listener.
struct NT_Event * NT_ReadListenerQueue(NT_ListenerPoller poller, size_t *len)
Read notifications.
NT_Listener NT_AddPolledListenerSingle(NT_ListenerPoller poller, const struct WPI_String *prefix, unsigned int mask)
Creates a polled topic listener.
NT_Listener NT_AddPolledListener(NT_ListenerPoller poller, NT_Handle handle, unsigned int mask)
Creates a polled listener.
void NT_DestroyListenerPoller(NT_ListenerPoller poller)
Destroys a listener poller.
NT_Listener NT_AddListener(NT_Handle handle, unsigned int mask, void *data, NT_ListenerCallback callback)
Create a listener.
NT_Listener NT_AddListenerMultiple(NT_Inst inst, const struct WPI_String *prefixes, size_t prefixes_len, unsigned int mask, void *data, NT_ListenerCallback callback)
Create a listener for changes to topics with names that start with any of the given prefixes.
NT_Bool NT_WaitForListenerQueue(NT_Handle handle, double timeout)
Wait for the listener queue to be empty.
NT_Listener NT_AddPolledLogger(NT_ListenerPoller poller, unsigned int min_level, unsigned int max_level)
Set the log level for a listener poller.
NT_Listener NT_AddLogger(NT_Inst inst, unsigned int min_level, unsigned int max_level, void *data, NT_ListenerCallback func)
Add logger callback function.
float * NT_AllocateFloatArray(size_t size)
Allocates an array of floats.
void NT_FreeIntegerArray(int64_t *v_int)
Frees an array of ints.
void NT_FreeFloatArray(float *v_float)
Frees an array of floats.
void NT_FreeBooleanArray(NT_Bool *v_boolean)
Frees an array of booleans.
NT_Bool * NT_AllocateBooleanArray(size_t size)
Allocates an array of booleans.
void NT_FreeDoubleArray(double *v_double)
Frees an array of doubles.
double * NT_AllocateDoubleArray(size_t size)
Allocates an array of doubles.
void NT_FreeCharArray(char *v_char)
Frees an array of chars.
int64_t * NT_AllocateIntegerArray(size_t size)
Allocates an array of ints.
char * NT_AllocateCharArray(size_t size)
Allocates an array of chars.
void NT_Disconnect(NT_Inst inst)
Disconnects the client if it's running and connected.
void NT_SetServerMulti(NT_Inst inst, size_t count, const struct WPI_String *server_names, const unsigned int *ports)
Sets server addresses for client (without restarting client).
void NT_StartClient(NT_Inst inst, const struct WPI_String *identity)
Starts a client.
void NT_StartLocal(NT_Inst inst)
Starts local-only operation.
void NT_StopClient(NT_Inst inst)
Stops the client if it is running.
void NT_StopServer(NT_Inst inst)
Stops the server if it is running.
unsigned int NT_GetNetworkMode(NT_Inst inst)
Get the current network mode.
void NT_StopLocal(NT_Inst inst)
Stops local-only operation.
void NT_SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port)
Sets server addresses and port for client (without restarting client).
void NT_Flush(NT_Inst inst)
Flush to network.
int64_t NT_GetServerTimeOffset(NT_Inst inst, NT_Bool *valid)
Get the time offset between server time and local time.
void NT_FlushLocal(NT_Inst inst)
Flush local updates.
NT_Bool NT_IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
void NT_StartServer(NT_Inst inst, const struct WPI_String *persist_filename, const struct WPI_String *listen_address, unsigned int port)
Starts a server using the specified filename, listening address, and port.
void NT_StartDSClient(NT_Inst inst, unsigned int port)
Starts requesting server address from Driver Station.
void NT_SetServer(NT_Inst inst, const struct WPI_String *server_name, unsigned int port)
Sets server address and port for client (without restarting client).
void NT_StopDSClient(NT_Inst inst)
Stops requesting server address from Driver Station.
struct NT_ConnectionInfo * NT_GetConnections(NT_Inst inst, size_t *count)
Get information on the currently established network connections.
void NT_AddSchema(NT_Inst inst, const struct WPI_String *name, const struct WPI_String *type, const uint8_t *schema, size_t schemaSize)
Registers a data schema.
NT_Bool NT_HasSchema(NT_Inst inst, const struct WPI_String *name)
Returns whether there is a data schema already registered with the given name.
NT_Bool NT_SetEntryValue(NT_Entry entry, const struct NT_Value *value)
Set Entry Value.
void NT_GetEntryValue(NT_Entry entry, struct NT_Value *value)
Get Entry Value.
void NT_GetEntryValueType(NT_Entry entry, unsigned int types, struct NT_Value *value)
Get Entry Value.
enum NT_Type NT_GetEntryType(NT_Entry entry)
Gets the type for the specified key, or unassigned if non existent.
struct NT_Value * NT_ReadQueueValue(NT_Handle subentry, size_t *count)
Read Entry Queue.
NT_Bool NT_SetDefaultEntryValue(NT_Entry entry, const struct NT_Value *default_value)
Set Default Entry Value.
NT_Entry NT_GetEntry(NT_Inst inst, const struct WPI_String *name)
Get Entry Handle.
void NT_GetEntryName(NT_Entry entry, struct WPI_String *name)
Gets the name of the specified entry.
unsigned int NT_GetEntryFlags(NT_Entry entry)
Get Entry Flags.
uint64_t NT_GetEntryLastChange(NT_Entry entry)
Gets the last time the entry was changed.
struct NT_Value * NT_ReadQueueValueType(NT_Handle subentry, unsigned int types, size_t *count)
Read Entry Queue.
void NT_SetEntryFlags(NT_Entry entry, unsigned int flags)
Set Entry Flags.
NT_Topic * NT_GetTopics(NT_Inst inst, const struct WPI_String *prefix, unsigned int types, size_t *count)
Get Published Topic Handles.
void NT_GetTopicProperties(NT_Topic topic, struct WPI_String *properties)
Gets all topic properties as a JSON string.
void NT_SetTopicRetained(NT_Topic topic, NT_Bool value)
Sets the retained property of a topic.
void NT_DeleteTopicProperty(NT_Topic topic, const struct WPI_String *name)
Deletes a property.
NT_Bool NT_GetTopicExists(NT_Handle handle)
Determine if topic exists (e.g.
NT_Bool NT_SetTopicProperties(NT_Topic topic, const struct WPI_String *properties)
Updates multiple topic properties.
NT_Topic NT_GetTopicFromHandle(NT_Handle pubsubentry)
Gets the topic handle from an entry/subscriber/publisher handle.
void NT_Release(NT_Handle pubsubentry)
Stops entry/subscriber/publisher.
void NT_SetTopicPersistent(NT_Topic topic, NT_Bool value)
Sets the persistent property of a topic.
void NT_ReleaseEntry(NT_Entry entry)
Stops entry subscriber/publisher.
struct NT_TopicInfo * NT_GetTopicInfosStr(NT_Inst inst, const struct WPI_String *prefix, const struct WPI_String *types, size_t types_len, size_t *count)
Get Topics.
void NT_GetTopicName(NT_Topic topic, struct WPI_String *name)
Gets the name of the specified topic.
NT_Bool NT_GetTopicInfo(NT_Topic topic, struct NT_TopicInfo *info)
Gets Topic Information.
NT_Publisher NT_Publish(NT_Topic topic, enum NT_Type type, const struct WPI_String *typeStr, const struct NT_PubSubOptions *options)
Creates a new publisher to a topic.
NT_Subscriber NT_Subscribe(NT_Topic topic, enum NT_Type type, const struct WPI_String *typeStr, const struct NT_PubSubOptions *options)
Creates a new subscriber to value changes on a topic.
void NT_GetTopicProperty(NT_Topic topic, const struct WPI_String *name, struct WPI_String *property)
Gets the current value of a property (as a JSON string).
NT_Entry NT_GetEntryEx(NT_Topic topic, enum NT_Type type, const struct WPI_String *typeStr, const struct NT_PubSubOptions *options)
Creates a new entry (subscriber and weak publisher) to a topic.
NT_Bool NT_SetTopicProperty(NT_Topic topic, const struct WPI_String *name, const struct WPI_String *value)
Sets a property value.
NT_Bool NT_GetTopicCached(NT_Topic topic)
Gets the cached property of a topic.
void NT_SetTopicCached(NT_Topic topic, NT_Bool value)
Sets the cached property of a topic.
NT_Bool NT_GetTopicPersistent(NT_Topic topic)
Gets the persistent property of a topic.
struct NT_TopicInfo * NT_GetTopicInfos(NT_Inst inst, const struct WPI_String *prefix, unsigned int types, size_t *count)
Get Topics.
NT_Publisher NT_PublishEx(NT_Topic topic, enum NT_Type type, const struct WPI_String *typeStr, const struct WPI_String *properties, const struct NT_PubSubOptions *options)
Creates a new publisher to a topic.
void NT_GetTopicTypeString(NT_Topic topic, struct WPI_String *type)
Gets the type string for the specified topic.
NT_Bool NT_GetTopicRetained(NT_Topic topic)
Gets the retained property of a topic.
void NT_Unpublish(NT_Handle pubentry)
Stops publisher.
enum NT_Type NT_GetTopicType(NT_Topic topic)
Gets the type for the specified topic, or unassigned if non existent.
void NT_Unsubscribe(NT_Subscriber sub)
Stops subscriber.
NT_Topic * NT_GetTopicsStr(NT_Inst inst, const struct WPI_String *prefix, const struct WPI_String *types, size_t types_len, size_t *count)
Get Published Topic Handles.
NT_Topic NT_GetTopic(NT_Inst inst, const struct WPI_String *name)
Gets Topic Handle.
int64_t * NT_GetValueIntegerArray(const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
Returns a copy of the int array from the NT_Value.
enum NT_Type NT_GetValueType(const struct NT_Value *value)
Returns the type of an NT_Value struct.
double * NT_GetValueDoubleArray(const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
Returns a copy of the double array from the NT_Value.
float * NT_GetValueFloatArray(const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
Returns a copy of the float array from the NT_Value.
struct WPI_String * NT_GetValueStringArray(const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
Returns a copy of the struct WPI_String array from the NT_Value.
NT_Bool * NT_GetValueBooleanArray(const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
Returns a copy of the boolean array from the NT_Value.
NT_Bool NT_GetValueFloat(const struct NT_Value *value, uint64_t *last_change, float *v_float)
Returns the float from the NT_Value.
NT_Bool NT_GetValueDouble(const struct NT_Value *value, uint64_t *last_change, double *v_double)
Returns the double from the NT_Value.
char * NT_GetValueString(const struct NT_Value *value, uint64_t *last_change, size_t *str_len)
Returns a copy of the string from the NT_Value.
NT_Bool NT_GetValueBoolean(const struct NT_Value *value, uint64_t *last_change, NT_Bool *v_boolean)
Returns the boolean from the NT_Value.
uint8_t * NT_GetValueRaw(const struct NT_Value *value, uint64_t *last_change, size_t *raw_len)
Returns a copy of the raw value from the NT_Value.
NT_Bool NT_GetValueInteger(const struct NT_Value *value, uint64_t *last_change, int64_t *v_int)
Returns the int from the NT_Value.
void NT_SetNow(int64_t timestamp)
Sets the current timestamp used for timestamping values that do not provide a timestamp (e....
void NT_InitValue(struct NT_Value *value)
Initializes a NT_Value.
void NT_DisposeTopicInfoArray(struct NT_TopicInfo *arr, size_t count)
Disposes a topic info array.
void NT_DisposeTopicInfo(struct NT_TopicInfo *info)
Disposes a single topic info (as returned by NT_GetTopicInfo).
void NT_DisposeConnectionInfoArray(struct NT_ConnectionInfo *arr, size_t count)
Disposes a connection info array.
int64_t NT_Now(void)
Returns monotonic current time in 1 us increments.
void NT_DisposeValue(struct NT_Value *value)
Frees value memory.
void NT_DisposeEventArray(struct NT_Event *arr, size_t count)
Disposes an event array.
void NT_DisposeValueArray(struct NT_Value *arr, size_t count)
Frees an array of NT_Values.
void NT_DisposeEvent(struct NT_Event *event)
Disposes a single event.
NetworkTables Connection Information.
Definition ntcore_c.h:187
struct WPI_String remote_ip
The IP address of the remote node.
Definition ntcore_c.h:194
unsigned int remote_port
The port number of the remote node.
Definition ntcore_c.h:197
uint64_t last_update
The last time any update was received from the remote node (same scale as returned by nt::Now()).
Definition ntcore_c.h:203
unsigned int protocol_version
The protocol version being used for this connection.
Definition ntcore_c.h:209
struct WPI_String remote_id
The remote identifier (as set on the remote node by NT_StartClient().
Definition ntcore_c.h:191
NetworkTables event.
Definition ntcore_c.h:258
struct NT_LogMessage logMessage
Definition ntcore_c.h:278
NT_Handle listener
Listener that triggered this event.
Definition ntcore_c.h:260
unsigned int flags
Event flags (NT_EventFlags).
Definition ntcore_c.h:271
struct NT_TopicInfo topicInfo
Definition ntcore_c.h:276
struct NT_ConnectionInfo connInfo
Definition ntcore_c.h:275
union NT_Event::@69 data
Event data; content depends on flags.
struct NT_TimeSyncEventData timeSyncData
Definition ntcore_c.h:279
struct NT_ValueEventData valueData
Definition ntcore_c.h:277
NetworkTables log message.
Definition ntcore_c.h:225
unsigned int level
Log level of the message.
Definition ntcore_c.h:227
struct WPI_String message
The message.
Definition ntcore_c.h:236
struct WPI_String filename
The filename of the source file that generated the message.
Definition ntcore_c.h:230
unsigned int line
The line number in the source file that generated the message.
Definition ntcore_c.h:233
Client (as published via $clients).
Definition ntcore_c.h:1848
struct WPI_String conn
Definition ntcore_c.h:1850
struct WPI_String id
Definition ntcore_c.h:1849
uint16_t version
Definition ntcore_c.h:1851
Client publisher (as published via $clientpub$<client> or $serverpub).
Definition ntcore_c.h:1830
int64_t uid
Definition ntcore_c.h:1831
struct WPI_String topic
Definition ntcore_c.h:1832
Client subscriber (as published via $clientsub$<client> or $serversub).
Definition ntcore_c.h:1838
struct NT_Meta_SubscriberOptions options
Definition ntcore_c.h:1842
int64_t uid
Definition ntcore_c.h:1839
size_t topicsCount
Definition ntcore_c.h:1840
struct WPI_String * topics
Definition ntcore_c.h:1841
Subscriber options.
Definition ntcore_c.h:1803
NT_Bool prefixMatch
Definition ntcore_c.h:1807
double periodic
Definition ntcore_c.h:1804
NT_Bool sendAll
Definition ntcore_c.h:1806
NT_Bool topicsOnly
Definition ntcore_c.h:1805
Topic publisher (as published via $pub$<topic>).
Definition ntcore_c.h:1813
struct WPI_String client
Definition ntcore_c.h:1814
uint64_t pubuid
Definition ntcore_c.h:1815
Topic subscriber (as published via $sub$<topic>).
Definition ntcore_c.h:1821
uint64_t subuid
Definition ntcore_c.h:1823
struct WPI_String client
Definition ntcore_c.h:1822
struct NT_Meta_SubscriberOptions options
Definition ntcore_c.h:1824
NetworkTables publish/subscribe options.
Definition ntcore_c.h:284
unsigned int structSize
Structure size.
Definition ntcore_c.h:288
NT_Bool prefixMatch
Perform prefix match on subscriber topic names.
Definition ntcore_c.h:327
NT_Bool disableRemote
For subscriptions, if remote value updates should not be queued for ReadQueue().
Definition ntcore_c.h:338
NT_Bool keepDuplicates
Preserve duplicate value changes (rather than ignoring them).
Definition ntcore_c.h:332
NT_Bool disableLocal
For subscriptions, if local value updates should not be queued for ReadQueue().
Definition ntcore_c.h:344
NT_Publisher excludePublisher
For subscriptions, if non-zero, value updates for ReadQueue() are not queued for this publisher.
Definition ntcore_c.h:310
unsigned int pollStorage
Polling storage size for a subscription.
Definition ntcore_c.h:296
NT_Bool topicsOnly
For subscriptions, don't ask for value changes (only topic announcements).
Definition ntcore_c.h:320
NT_Bool sendAll
Send all value changes over the network.
Definition ntcore_c.h:315
double periodic
How frequently changes will be sent over the network, in seconds.
Definition ntcore_c.h:304
NT_Bool excludeSelf
For entries, don't queue (for ReadQueue) value updates for the entry's internal publisher.
Definition ntcore_c.h:350
NT_Bool hidden
For subscriptions, don't share the existence of the subscription with the network.
Definition ntcore_c.h:358
NetworkTables time sync event data.
Definition ntcore_c.h:240
int64_t rtt2
Measured round trip time divided by 2, in microseconds.
Definition ntcore_c.h:248
NT_Bool valid
If serverTimeOffset and RTT are valid.
Definition ntcore_c.h:254
int64_t serverTimeOffset
Offset between local time and server time, in microseconds.
Definition ntcore_c.h:245
NetworkTables Topic Information.
Definition ntcore_c.h:169
struct WPI_String properties
Topic properties JSON string.
Definition ntcore_c.h:183
NT_Topic topic
Topic handle.
Definition ntcore_c.h:171
enum NT_Type type
Topic type.
Definition ntcore_c.h:177
struct WPI_String type_str
Topic type string.
Definition ntcore_c.h:180
NetworkTables value event data.
Definition ntcore_c.h:213
NT_Handle subentry
Subscriber/entry handle.
Definition ntcore_c.h:218
NT_Topic topic
Topic handle.
Definition ntcore_c.h:215
struct NT_Value value
The new value.
Definition ntcore_c.h:221
NetworkTables Entry Value.
Definition ntcore_c.h:131
enum NT_Type type
Definition ntcore_c.h:132
float * arr
Definition ntcore_c.h:154
struct NT_Value::@62::@66 arr_float
struct NT_Value::@62::@64 arr_boolean
float v_float
Definition ntcore_c.h:138
double * arr
Definition ntcore_c.h:150
struct NT_Value::@62::@68 arr_string
struct NT_Value::@62::@65 arr_double
int64_t last_change
Definition ntcore_c.h:133
int64_t server_time
Definition ntcore_c.h:134
double v_double
Definition ntcore_c.h:139
uint8_t * data
Definition ntcore_c.h:142
NT_Bool v_boolean
Definition ntcore_c.h:136
struct WPI_String v_string
Definition ntcore_c.h:140
struct NT_Value::@62::@63 v_raw
struct NT_Value::@62::@67 arr_int
size_t size
Definition ntcore_c.h:143
NT_Bool * arr
Definition ntcore_c.h:146
struct WPI_String * arr
Definition ntcore_c.h:162
int64_t v_int
Definition ntcore_c.h:137
int64_t * arr
Definition ntcore_c.h:158
A const UTF8 string.
Definition string.h:14