Skip to content

Montior Packet⚓︎

The monitor packet holds the information about the unit and the digital IO;

  • The serial number, os version, and a timestamp are reported.
  • The digital inputs have a state and a counter value.
  • The outputs have a state.

The monitor packet is an unsolictied message that gets sent whenever the I/O on the JNIOR gets updated. It can also be requsted manually when needed.

Here is an example monitor packet:

The order of the elements in the JSON string are not guaranteed. Line breaks shown below are for display purposes only. They are not present in the JSON string that is returned.

{
  "Message":"Monitor",
  "Serial Number":622120001,
  "Model":"410",
  "Version":"v2.5.2",
  "Inputs":[
    {"Count":1,"State":1},{"Count":1,"State":1},
    {"Count":1,"State":1},{"Count":1,"State":1},
    {"Count":1,"State":1},{"Count":1,"State":1},
    {"Count":1,"State":1},{"Count":1,"State":1}
  ],
  "Outputs":[
    {"State":0},{"State":1},{"State":0},{"State":0},
    {"State":0},{"State":0},{"State":0},{"State":0},
    {"State":0},{"State":0},{"State":0},{"State":0}
  ]
  "Timestamp":1771132520471,
}

Once the monitor packet is obtained from a connection, an IO change, a Request Monitor Packet function call, or through the callback mechanism, you can get several bits of information about the unit. Information like the Serial Number, Model, Firmware Version, and current timestamp are all available via the monitor packet.

To get access to this information you should parse the monitor packet string as a JSON object in your language of choice. You will then be able to do something like the following examples...

Request Monitor Packet⚓︎

Version 26.0.0 - May ##, 2026

There may be a situation where you want to refresh the Monitor Packet and request that a new one gets sent. To do this you will use the Request Monitor Packet call.

1

1
2
// Requests a monitor packet from the JNIOR
_jmpConnection.RequestMonitorPacket();
1
2
// Requests a monitor packet from the JNIOR
jmpConnection.requestMonitorPacket();
1
2
# requests a monitor packet from the JNIOR
jmp_connection.request_monitor_packet()

Monitor Packet Callback⚓︎

Version 26.0.0 - May ##, 2026

You can add a callback that will be executed when ever a monitor packet is received. To do that you will need to implement the following

1
2
3
4
5
6
7
8
// the function that will be the callback and that will get executed 
// when a  monitor packet is received
void on_monitor_packet(const char* monitor_packet_json_string) {
  std::cout << "monitor packet has been received: " << monitor_packet_json_string << std::endl;
}

// registry the callback function with the library
jmplib.add_monitor_callback(&on_monitor_packet);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
// Defines the callback method that runs when the JMP monitor packet
// is received.
private static void OnMonitorCallback(string uuid, IntPtr monitorPacketJson)
{
    var monitorPacketJsonString = Marshal.PtrToStringAnsi(monitorPacketJson);
    Console.WriteLine($"{uuid}: Monitor packet is {monitorPacketJsonString}");
}

...

// Once the OnMonitorPacket function is defined, you can
// now add the monitor packet listener to enable the callback.
// This will check for when the monitor packet is received, and 
// then run the OnMonitorPacket function.
JmpLib.AddMonitorCallback(OnMonitorCallback);

...

// After you no long need the monitor packet callback you should 
// remove it
JmpLib.RemoveMonitorCallback(OnMonitorCallback);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// Defines the callback method that runs when the JMP monitor packet
// is received.
public void onMonitorPacket(jmpConnection, int inputChangeMask, int outputStateMask) {
  System.out.println("Input Change Mask = " + inputChangeMask + ". Output Change Mask = " + outputStateMask);
}

// Once the onMonitorPacket function is defined, you can
// now add the monitor packet listener to enable the callback.
// This will check for when the monitor packet is received, and 
// then run the onMonitorPacket function.
JmpLib.addMonitorPacketListener(this);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Defines the callback method that runs when the JMP monitor packet
# is received.
def on_monitor(jmp_connection, input_state_mask: int, output_state_mask: int):
  print(f"Input Change Mask: {input_state_mask}. Output Change Mask {output_state_mask}.")

# Once the on_monitor function is defined, you can
# now add the monitor packet listener to enable the callback.
# This will check for when the monitor packet is received, and 
# then run the on_monitor function.
jmplib_py.add_monitor_packet_callback(on_monitor)

Unit Infomation⚓︎

Version 26.0.0 - May ##, 2026

Once the connection is made, and authenticated, a Monitor Packet will be sent. The Monitor Packet contains information, not only abobut the I/O, but about the unit as well. Information like the serial number, the model, the version, and the units current time and all included.

The following calls are available to get you this infomation:

1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// this import is useful for interacting with the time values on the JNIOR
using TimeZoneConverter;
// the information pulled here is whats returned in the monitor packet

// GetModel returns the JNIOR's model number
Console.WriteLine($"Model: {_jmpConnection.GetModel()}");
// GetSerialNumber returns the JNIOR's serial number
Console.WriteLine($"Serial Number: {_jmpConnection.GetSerialNumber()}");
// GetVersion returns the JNIOR's OS version
Console.WriteLine($"Firmware Version: {_jmpConnection.GetVersion()}");
// GetHostname returns the JNIOR's OS version
Console.WriteLine($"Hostname: {_jmpConnection.GetHostname()}");
// GetInputCount() returns the JNIOR's number of inputs
System.out.println("Input Count: " + jmpConnection.GetInputCount())
// GetOutputCount() returns the JNIOR's number of outputs
System.out.println("Output Count: " + jmpConnection.GetOutputCount())
// GetTimestamp returns the JNIOR's current time as a timestamp
Console.WriteLine($"Timestamp: {_jmpConnection.GetTimestamp()}");
// GetTime() returns the JNIOR's time as a date object
// when getting time, its not timezone aware so by default it's timezone is UTC
Console.WriteLine($"Time: {_jmpConnection.GetTime()}");
// GetTimezone() returns the timezone the JNIOR has set
Console.WriteLine($"Timezone: {_jmpConnection.GetTimezone()}");
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// this import is useful for interacting with the time values on the JNIOR
import java.util.Date;
// the information pulled here is whats returned in the monitor packet

// getModel returns the JNIOR's model number
System.out.println("Model: " + jmpConnection.getModel());
// getSerialNumber returns the JNIOR's serial number
System.out.println("Serial Number: " + jmpConnection.getSerialNumber());
// getVersion returns the JNIOR's OS version
System.out.println("Version: " + jmpConnection.getVersion());
// getHostname returns the JNIOR's name it's been assigned
System.out.println("Hostname: " + jmpConnection.getHostname());
// getTimestamp returns the JNIOR's current time as a timestamp
System.out.println("Timestamp: " + jmpConnection.getTimestamp());   
// getInputCount() returns the JNIOR's number of inputs
System.out.println("Input Count: " + jmpConnection.getInputCount())
// getOutputCount() returns the JNIOR's number of outputs
System.out.println("Output Count: " + jmpConnection.getOutputCount())
// getTime() returns the JNIOR's time as a date object
// when getting time, its not timezone aware so by default it's timezone is UTC
Date d = jmpConnection.getTime();
System.out.println("UTC Time: " + d);
// getTimezone() returns the timezone the JNIOR has set
System.out.println("Timezone: " + jmpConnection.getTimezone());
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# these imports are useful for interacting with time values on the JNIOR
from datetime import timezone
from zoneinfo import ZoneInfo
# the information pulled here is whats returned in the monitor packet

# get_model returns the JNIOR's model number
print(f"Model is: {jmp_connection.get_model()}")
# get_serial_number the JNIOR's serial number
print(f"Serial Number is: {jmp_connection.get_serial_number()}")
# get_version returns the JNIOR's OS version
print(f"Version is: {jmp_connection.get_version()}")
# get_hostname returns the JNIOR's name it's been assigned
print(f"Hostname is: {jmp_connection.get_hostname()}")
# get_timestamp returns the JNIOR's timestamp
print(f"Timestamp is: {jmp_connection.get_timestamp()}")
# get_input_count returns the JNIOR's number of inputs
print(f"Input Count is: {jmp_connection.get_input_count()}")
# get_output_count returns the JNIOR's number of outputs
print(f"Output Count is: {jmp_connection.get_output_count()}")
# get_time returns the JNIOR's time as a date object
# when getting time, its not timezone aware so by default it's timezone is UTC
print("Time is:" {jmp_connection.get_time()})
# get_timezone() returns the timezone the JNIOR has set
print("Timezone is:" {jmp_connection.timezone()})

Possible Status Returns:

  • INVALID_UUID: If a JMP Connection is not found for the given UUID
dsgf