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