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