WPILibC++ 2023.4.3
ntcore_c.h File Reference
#include <stdint.h>
#include <stddef.h>
#include "ntcore_c_types.h"

Go to the source code of this file.

Classes

struct  NT_String
 A NetworkTables string. More...
 
struct  NT_Value
 NetworkTables Entry Value. More...
 
struct  NT_TopicInfo
 NetworkTables Topic Information. More...
 
struct  NT_ConnectionInfo
 NetworkTables Connection Information. More...
 
struct  NT_ValueEventData
 NetworkTables value event data. More...
 
struct  NT_LogMessage
 NetworkTables log message. More...
 
struct  NT_TimeSyncEventData
 NetworkTables time sync event data. More...
 
struct  NT_Event
 NetworkTables event. More...
 
struct  NT_PubSubOptions
 NetworkTables publish/subscribe options. More...
 
struct  NT_Meta_SubscriberOptions
 Subscriber options. More...
 
struct  NT_Meta_TopicPublisher
 Topic publisher (as published via $pub$<topic>). More...
 
struct  NT_Meta_TopicSubscriber
 Topic subscriber (as published via $sub$<topic>). More...
 
struct  NT_Meta_ClientPublisher
 Client publisher (as published via $clientpub$<client> or $serverpub). More...
 
struct  NT_Meta_ClientSubscriber
 Client subscriber (as published via $clientsub$<client> or $serversub). More...
 
struct  NT_Meta_Client
 Client (as published via $clients). More...
 

Macros

#define NT_DEFAULT_PORT3   1735
 Default network tables port number (NT3) More...
 
#define NT_DEFAULT_PORT4   5810
 Default network tables port number (NT4) More...
 

Typedefs

typedef int NT_Bool
 Typedefs. More...
 
typedef unsigned int NT_Handle
 
typedef NT_Handle NT_ConnectionDataLogger
 
typedef NT_Handle NT_DataLogger
 
typedef NT_Handle NT_Entry
 
typedef NT_Handle NT_Inst
 
typedef NT_Handle NT_Listener
 
typedef NT_Handle NT_ListenerPoller
 
typedef NT_Handle NT_MultiSubscriber
 
typedef NT_Handle NT_Topic
 
typedef NT_Handle NT_Subscriber
 
typedef NT_Handle NT_Publisher
 
typedef void(* NT_ListenerCallback) (void *data, const struct NT_Event *event)
 Event listener callback function. More...
 

Enumerations

enum  NT_Type {
  NT_UNASSIGNED = 0 , NT_BOOLEAN = 0x01 , NT_DOUBLE = 0x02 , NT_STRING = 0x04 ,
  NT_RAW = 0x08 , NT_BOOLEAN_ARRAY = 0x10 , NT_DOUBLE_ARRAY = 0x20 , NT_STRING_ARRAY = 0x40 ,
  NT_RPC = 0x80 , NT_INTEGER = 0x100 , NT_FLOAT = 0x200 , NT_INTEGER_ARRAY = 0x400 ,
  NT_FLOAT_ARRAY = 0x800
}
 NetworkTables data types. More...
 
enum  NT_EntryFlags { NT_PERSISTENT = 0x01 , NT_RETAINED = 0x02 }
 NetworkTables entry flags. More...
 
enum  NT_LogLevel {
  NT_LOG_CRITICAL = 50 , NT_LOG_ERROR = 40 , NT_LOG_WARNING = 30 , NT_LOG_INFO = 20 ,
  NT_LOG_DEBUG = 10 , NT_LOG_DEBUG1 = 9 , NT_LOG_DEBUG2 = 8 , NT_LOG_DEBUG3 = 7 ,
  NT_LOG_DEBUG4 = 6
}
 NetworkTables logging levels. More...
 
enum  NT_NetworkMode {
  NT_NET_MODE_NONE = 0x00 , NT_NET_MODE_SERVER = 0x01 , NT_NET_MODE_CLIENT3 = 0x02 , NT_NET_MODE_CLIENT4 = 0x04 ,
  NT_NET_MODE_STARTING = 0x08 , NT_NET_MODE_LOCAL = 0x10
}
 Client/server modes. More...
 
enum  NT_EventFlags {
  NT_EVENT_NONE = 0 , NT_EVENT_IMMEDIATE = 0x01 , NT_EVENT_CONNECTED = 0x02 , NT_EVENT_DISCONNECTED = 0x04 ,
  NT_EVENT_CONNECTION = NT_EVENT_CONNECTED | NT_EVENT_DISCONNECTED , NT_EVENT_PUBLISH = 0x08 , NT_EVENT_UNPUBLISH = 0x10 , NT_EVENT_PROPERTIES = 0x20 ,
  NT_EVENT_TOPIC = NT_EVENT_PUBLISH | NT_EVENT_UNPUBLISH | NT_EVENT_PROPERTIES , NT_EVENT_VALUE_REMOTE = 0x40 , NT_EVENT_VALUE_LOCAL = 0x80 , NT_EVENT_VALUE_ALL = NT_EVENT_VALUE_REMOTE | NT_EVENT_VALUE_LOCAL ,
  NT_EVENT_LOGMESSAGE = 0x100 , NT_EVENT_TIMESYNC = 0x200
}
 Event notification flags. More...
 

Functions

NT_Inst NT_GetDefaultInstance (void)
 Get default instance. More...
 
NT_Inst NT_CreateInstance (void)
 Create an instance. More...
 
void NT_DestroyInstance (NT_Inst inst)
 Destroy an instance. More...
 
NT_Inst NT_GetInstanceFromHandle (NT_Handle handle)
 Get instance handle from another handle. More...
 
NT_Entry NT_GetEntry (NT_Inst inst, const char *name, size_t name_len)
 Get Entry Handle. More...
 
char * NT_GetEntryName (NT_Entry entry, size_t *name_len)
 Gets the name of the specified entry. More...
 
enum NT_Type NT_GetEntryType (NT_Entry entry)
 Gets the type for the specified key, or unassigned if non existent. More...
 
uint64_t NT_GetEntryLastChange (NT_Entry entry)
 Gets the last time the entry was changed. More...
 
void NT_GetEntryValue (NT_Entry entry, struct NT_Value *value)
 Get Entry Value. More...
 
NT_Bool NT_SetDefaultEntryValue (NT_Entry entry, const struct NT_Value *default_value)
 Set Default Entry Value. More...
 
NT_Bool NT_SetEntryValue (NT_Entry entry, const struct NT_Value *value)
 Set Entry Value. More...
 
void NT_SetEntryFlags (NT_Entry entry, unsigned int flags)
 Set Entry Flags. More...
 
unsigned int NT_GetEntryFlags (NT_Entry entry)
 Get Entry Flags. More...
 
struct NT_ValueNT_ReadQueueValue (NT_Handle subentry, size_t *count)
 Read Entry Queue. More...
 
NT_TopicNT_GetTopics (NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int types, size_t *count)
 Get Published Topic Handles. More...
 
NT_TopicNT_GetTopicsStr (NT_Inst inst, const char *prefix, size_t prefix_len, const char *const *types, size_t types_len, size_t *count)
 Get Published Topic Handles. More...
 
struct NT_TopicInfoNT_GetTopicInfos (NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int types, size_t *count)
 Get Topics. More...
 
struct NT_TopicInfoNT_GetTopicInfosStr (NT_Inst inst, const char *prefix, size_t prefix_len, const char *const *types, size_t types_len, size_t *count)
 Get Topics. More...
 
NT_Bool NT_GetTopicInfo (NT_Topic topic, struct NT_TopicInfo *info)
 Gets Topic Information. More...
 
NT_Topic NT_GetTopic (NT_Inst inst, const char *name, size_t name_len)
 Gets Topic Handle. More...
 
char * NT_GetTopicName (NT_Topic topic, size_t *name_len)
 Gets the name of the specified topic. More...
 
enum NT_Type NT_GetTopicType (NT_Topic topic)
 Gets the type for the specified topic, or unassigned if non existent. More...
 
char * NT_GetTopicTypeString (NT_Topic topic, size_t *type_len)
 Gets the type string for the specified topic. More...
 
void NT_SetTopicPersistent (NT_Topic topic, NT_Bool value)
 Sets the persistent property of a topic. More...
 
NT_Bool NT_GetTopicPersistent (NT_Topic topic)
 Gets the persistent property of a topic. More...
 
void NT_SetTopicRetained (NT_Topic topic, NT_Bool value)
 Sets the retained property of a topic. More...
 
NT_Bool NT_GetTopicRetained (NT_Topic topic)
 Gets the retained property of a topic. More...
 
NT_Bool NT_GetTopicExists (NT_Handle handle)
 Determine if topic exists (e.g. More...
 
char * NT_GetTopicProperty (NT_Topic topic, const char *name, size_t *len)
 Gets the current value of a property (as a JSON string). More...
 
NT_Bool NT_SetTopicProperty (NT_Topic topic, const char *name, const char *value)
 Sets a property value. More...
 
void NT_DeleteTopicProperty (NT_Topic topic, const char *name)
 Deletes a property. More...
 
char * NT_GetTopicProperties (NT_Topic topic, size_t *len)
 Gets all topic properties as a JSON string. More...
 
NT_Bool NT_SetTopicProperties (NT_Topic topic, const char *properties)
 Updates multiple topic properties. More...
 
NT_Subscriber NT_Subscribe (NT_Topic topic, enum NT_Type type, const char *typeStr, const struct NT_PubSubOptions *options)
 Creates a new subscriber to value changes on a topic. More...
 
void NT_Unsubscribe (NT_Subscriber sub)
 Stops subscriber. More...
 
NT_Publisher NT_Publish (NT_Topic topic, enum NT_Type type, const char *typeStr, const struct NT_PubSubOptions *options)
 Creates a new publisher to a topic. More...
 
NT_Publisher NT_PublishEx (NT_Topic topic, enum NT_Type type, const char *typeStr, const char *properties, const struct NT_PubSubOptions *options)
 Creates a new publisher to a topic. More...
 
void NT_Unpublish (NT_Handle pubentry)
 Stops publisher. More...
 
NT_Entry NT_GetEntryEx (NT_Topic topic, enum NT_Type type, const char *typeStr, const struct NT_PubSubOptions *options)
 Creates a new entry (subscriber and weak publisher) to a topic. More...
 
void NT_ReleaseEntry (NT_Entry entry)
 Stops entry subscriber/publisher. More...
 
void NT_Release (NT_Handle pubsubentry)
 Stops entry/subscriber/publisher. More...
 
NT_Topic NT_GetTopicFromHandle (NT_Handle pubsubentry)
 Gets the topic handle from an entry/subscriber/publisher handle. More...
 
NT_MultiSubscriber NT_SubscribeMultiple (NT_Inst inst, const struct NT_String *prefixes, size_t prefixes_len, const struct NT_PubSubOptions *options)
 Subscribes to multiple topics based on one or more topic name prefixes. More...
 
void NT_UnsubscribeMultiple (NT_MultiSubscriber sub)
 Unsubscribes a multi-subscriber. More...
 
NT_ListenerPoller NT_CreateListenerPoller (NT_Inst inst)
 Creates a listener poller. More...
 
void NT_DestroyListenerPoller (NT_ListenerPoller poller)
 Destroys a listener poller. More...
 
struct NT_EventNT_ReadListenerQueue (NT_ListenerPoller poller, size_t *len)
 Read notifications. More...
 
void NT_RemoveListener (NT_Listener listener)
 Removes a listener. More...
 
NT_Bool NT_WaitForListenerQueue (NT_Handle handle, double timeout)
 Wait for the listener queue to be empty. More...
 
NT_Listener NT_AddListenerSingle (NT_Inst inst, const char *prefix, size_t prefix_len, unsigned int mask, void *data, NT_ListenerCallback callback)
 Create a listener for changes to topics with names that start with the given prefix. More...
 
NT_Listener NT_AddListenerMultiple (NT_Inst inst, const struct NT_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. More...
 
NT_Listener NT_AddListener (NT_Handle handle, unsigned int mask, void *data, NT_ListenerCallback callback)
 Create a listener. More...
 
NT_Listener NT_AddPolledListenerSingle (NT_ListenerPoller poller, const char *prefix, size_t prefix_len, unsigned int mask)
 Creates a polled topic listener. More...
 
NT_Listener NT_AddPolledListenerMultiple (NT_ListenerPoller poller, const struct NT_String *prefixes, size_t prefixes_len, unsigned int mask)
 Creates a polled topic listener. More...
 
NT_Listener NT_AddPolledListener (NT_ListenerPoller poller, NT_Handle handle, unsigned int mask)
 Creates a polled listener. More...
 
unsigned int NT_GetNetworkMode (NT_Inst inst)
 Get the current network mode. More...
 
void NT_StartLocal (NT_Inst inst)
 Starts local-only operation. More...
 
void NT_StopLocal (NT_Inst inst)
 Stops local-only operation. More...
 
void NT_StartServer (NT_Inst inst, const char *persist_filename, const char *listen_address, unsigned int port3, unsigned int port4)
 Starts a server using the specified filename, listening address, and port. More...
 
void NT_StopServer (NT_Inst inst)
 Stops the server if it is running. More...
 
void NT_StartClient3 (NT_Inst inst, const char *identity)
 Starts a NT3 client. More...
 
void NT_StartClient4 (NT_Inst inst, const char *identity)
 Starts a NT4 client. More...
 
void NT_StopClient (NT_Inst inst)
 Stops the client if it is running. More...
 
void NT_SetServer (NT_Inst inst, const char *server_name, unsigned int port)
 Sets server address and port for client (without restarting client). More...
 
void NT_SetServerMulti (NT_Inst inst, size_t count, const char **server_names, const unsigned int *ports)
 Sets server addresses for client (without restarting client). More...
 
void NT_SetServerTeam (NT_Inst inst, unsigned int team, unsigned int port)
 Sets server addresses and port for client (without restarting client). More...
 
void NT_Disconnect (NT_Inst inst)
 Disconnects the client if it's running and connected. More...
 
void NT_StartDSClient (NT_Inst inst, unsigned int port)
 Starts requesting server address from Driver Station. More...
 
void NT_StopDSClient (NT_Inst inst)
 Stops requesting server address from Driver Station. More...
 
void NT_FlushLocal (NT_Inst inst)
 Flush local updates. More...
 
void NT_Flush (NT_Inst inst)
 Flush to network. More...
 
struct NT_ConnectionInfoNT_GetConnections (NT_Inst inst, size_t *count)
 Get information on the currently established network connections. More...
 
NT_Bool NT_IsConnected (NT_Inst inst)
 Return whether or not the instance is connected to another node. More...
 
int64_t NT_GetServerTimeOffset (NT_Inst inst, NT_Bool *valid)
 Get the time offset between server time and local time. More...
 
void NT_DisposeValue (struct NT_Value *value)
 Frees value memory. More...
 
void NT_InitValue (struct NT_Value *value)
 Initializes a NT_Value. More...
 
void NT_DisposeString (struct NT_String *str)
 Frees string memory. More...
 
void NT_InitString (struct NT_String *str)
 Initializes a NT_String. More...
 
void NT_DisposeValueArray (struct NT_Value *arr, size_t count)
 Frees an array of NT_Values. More...
 
void NT_DisposeConnectionInfoArray (struct NT_ConnectionInfo *arr, size_t count)
 Disposes a connection info array. More...
 
void NT_DisposeTopicInfoArray (struct NT_TopicInfo *arr, size_t count)
 Disposes a topic info array. More...
 
void NT_DisposeTopicInfo (struct NT_TopicInfo *info)
 Disposes a single topic info (as returned by NT_GetTopicInfo). More...
 
void NT_DisposeEventArray (struct NT_Event *arr, size_t count)
 Disposes an event array. More...
 
void NT_DisposeEvent (struct NT_Event *event)
 Disposes a single event. More...
 
int64_t NT_Now (void)
 Returns monotonic current time in 1 us increments. More...
 
void NT_SetNow (int64_t timestamp)
 Sets the current timestamp used for timestamping values that do not provide a timestamp (e.g. More...
 
NT_Listener NT_AddLogger (NT_Inst inst, unsigned int min_level, unsigned int max_level, void *data, NT_ListenerCallback func)
 Add logger callback function. More...
 
NT_Listener NT_AddPolledLogger (NT_ListenerPoller poller, unsigned int min_level, unsigned int max_level)
 Set the log level for a listener poller. More...
 
char * NT_AllocateCharArray (size_t size)
 Allocates an array of chars. More...
 
NT_BoolNT_AllocateBooleanArray (size_t size)
 Allocates an array of booleans. More...
 
int64_t * NT_AllocateIntegerArray (size_t size)
 Allocates an array of ints. More...
 
float * NT_AllocateFloatArray (size_t size)
 Allocates an array of floats. More...
 
double * NT_AllocateDoubleArray (size_t size)
 Allocates an array of doubles. More...
 
struct NT_StringNT_AllocateStringArray (size_t size)
 Allocates an array of NT_Strings. More...
 
void NT_FreeCharArray (char *v_char)
 Frees an array of chars. More...
 
void NT_FreeBooleanArray (NT_Bool *v_boolean)
 Frees an array of booleans. More...
 
void NT_FreeIntegerArray (int64_t *v_int)
 Frees an array of ints. More...
 
void NT_FreeFloatArray (float *v_float)
 Frees an array of floats. More...
 
void NT_FreeDoubleArray (double *v_double)
 Frees an array of doubles. More...
 
void NT_FreeStringArray (struct NT_String *v_string, size_t arr_size)
 Frees an array of NT_Strings. More...
 
enum NT_Type NT_GetValueType (const struct NT_Value *value)
 Returns the type of an NT_Value struct. More...
 
NT_Bool NT_GetValueBoolean (const struct NT_Value *value, uint64_t *last_change, NT_Bool *v_boolean)
 Returns the boolean from the NT_Value. More...
 
NT_Bool NT_GetValueInteger (const struct NT_Value *value, uint64_t *last_change, int64_t *v_int)
 Returns the int from the NT_Value. More...
 
NT_Bool NT_GetValueFloat (const struct NT_Value *value, uint64_t *last_change, float *v_float)
 Returns the float from the NT_Value. More...
 
NT_Bool NT_GetValueDouble (const struct NT_Value *value, uint64_t *last_change, double *v_double)
 Returns the double from the NT_Value. More...
 
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. More...
 
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. More...
 
NT_BoolNT_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. More...
 
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. More...
 
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. More...
 
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. More...
 
struct NT_StringNT_GetValueStringArray (const struct NT_Value *value, uint64_t *last_change, size_t *arr_size)
 Returns a copy of the NT_String array from the NT_Value. More...
 
struct NT_Meta_TopicPublisherNT_Meta_DecodeTopicPublishers (const uint8_t *data, size_t size, size_t *count)
 Decodes $pub$<topic> meta-topic data. More...
 
struct NT_Meta_TopicSubscriberNT_Meta_DecodeTopicSubscribers (const uint8_t *data, size_t size, size_t *count)
 Decodes $sub$<topic> meta-topic data. More...
 
struct NT_Meta_ClientPublisherNT_Meta_DecodeClientPublishers (const uint8_t *data, size_t size, size_t *count)
 Decodes $clientpub$<topic> meta-topic data. More...
 
struct NT_Meta_ClientSubscriberNT_Meta_DecodeClientSubscribers (const uint8_t *data, size_t size, size_t *count)
 Decodes $clientsub$<topic> meta-topic data. More...
 
struct NT_Meta_ClientNT_Meta_DecodeClients (const uint8_t *data, size_t size, size_t *count)
 Decodes $clients meta-topic data. More...
 
void NT_Meta_FreeTopicPublishers (struct NT_Meta_TopicPublisher *arr, size_t count)
 Frees an array of NT_Meta_TopicPublisher. More...
 
void NT_Meta_FreeTopicSubscribers (struct NT_Meta_TopicSubscriber *arr, size_t count)
 Frees an array of NT_Meta_TopicSubscriber. More...
 
void NT_Meta_FreeClientPublishers (struct NT_Meta_ClientPublisher *arr, size_t count)
 Frees an array of NT_Meta_ClientPublisher. More...
 
void NT_Meta_FreeClientSubscribers (struct NT_Meta_ClientSubscriber *arr, size_t count)
 Frees an array of NT_Meta_ClientSubscriber. More...
 
void NT_Meta_FreeClients (struct NT_Meta_Client *arr, size_t count)
 Frees an array of NT_Meta_Client. More...