Unexpected DeviceSessionPB Protobuf Response

Our application is reading the DeviceSessionPB protobuf data stored in Redis and using it to make decisions. Occassionally when decoding a device’s session, the result is missing information. We are only decoding it for the devAddr, nwkSEncKey, and nFCntDown fields. In the result below, the nFCntDown field is missing. If it is missing, can we assume that it is a default value? If so, what is the default value? 0? 1?

{
  "deviceProfileId": "74be0d81-325f-4aad-9c83-02da42998d9a",
  "serviceProfileId": "84e60453-ecc0-49b2-85e8-7b76b6943300",
  "routingProfileId": "6d5db27e-4ce2-4b2b-b5d7-91f069397978",
  "devAddr": "AG/fPA==",
  "devEui": "AASjCwD5oac=",
  "joinEui": "AAAAAAAAAAA=",
  "fNwkSIntKey": "OvuqJZj8So7OXSz+i1iuYw==",
  "sNwkSIntKey": "OvuqJZj8So7OXSz+i1iuYw==",
  "nwkSEncKey": "OvuqJZj8So7OXSz+i1iuYw==",
  "fCntUp": 1,
  "skipFCntCheck": true,
  "rxDelay": 1,
  "rx2Dr": 10,
  "rx2Frequency": 923300000,
  "nbTrans": 1,
  "enabledUplinkChannels": [
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10,
    11,
    12,
    13,
    14,
    15,
    16,
    17,
    18,
    19,
    20,
    21,
    22,
    23,
    24,
    25,
    26,
    27,
    28,
    29,
    30,
    31,
    32,
    33,
    34,
    35,
    36,
    37,
    38,
    39,
    40,
    41,
    42,
    43,
    44,
    45,
    46,
    47,
    48,
    49,
    50,
    51,
    52,
    53,
    54,
    55,
    56,
    57,
    58,
    59,
    60,
    61,
    62,
    63,
    64,
    65,
    66,
    67,
    68,
    69,
    70,
    71
  ],
  "uplinkAdrHistory": [
    {
      "maxSnr": 8.5,
      "gatewayCount": 1
    }
  ],
  "lastDeviceStatusRequestTimeUnixNs": "-6795364578871345152",
  "lastDownlinkTxTimestampUnixNs": "-6795364578871345152",
  "macVersion": "1.0.2"
}

DeviceSessionPB

message DeviceSessionPB {
    // ID of the device-profile.
    string device_profile_id = 1;

    // ID of the service-profile.
    string service_profile_id = 2;

    // ID of the routing-profile.
    string routing_profile_id = 3;

    // Device address.
    bytes dev_addr = 4;

    // Device EUI.
    bytes dev_eui = 5;

    // Join EUI.
    bytes join_eui = 6;

    // FNwkSIntKey.
    bytes f_nwk_s_int_key = 7;

    // SNwkSIntKey.
    bytes s_nwk_s_int_key = 8;

    // NwkSEncKey.
    bytes nwk_s_enc_key = 9;

    // AppSKeyEnvelope contains the (encrypted) AppSKey key-envelope.
    common.KeyEnvelope app_s_key_envelope = 45;

    // Uplink frame-counter.
    uint32 f_cnt_up = 10;

    // Downlink frame-counter (network-server).
    uint32 n_f_cnt_down = 11;

    // Uplink frame-counter (application-server).
    // Note: this frame-counter is managed by the application-server.
    uint32 a_f_cnt_down = 12;

    // Frame-counter holding the last confirmed downlink frame (n_f_cnt_down or a_f_cnt_down).
    uint32 conf_f_cnt = 39;

    // Skip uplink frame-counter validation.
    bool skip_f_cnt_check = 13;

    // RX Delay.
    uint32 rx_delay = 14;

    // RX1 data-rate offset.
    uint32 rx1_dr_offset = 15;

    // RX2 data-rate.
    uint32 rx2_dr = 16;

    // RX2 frequency.
    uint32 rx2_frequency = 17;

	// TXPowerIndex which the node is using. The possible values are defined
	// by the lorawan/band package and are region specific. By default it is
	// assumed that the node is using TXPower 0. This value is controlled by
    // the ADR engine.
    uint32 tx_power_index = 18;

	// DR defines the (last known) data-rate at which the node is operating.
    // This value is controlled by the ADR engine.
    uint32 dr = 19;

    // ADR defines if the device has ADR enabled.
    bool adr = 20;

	// MaxSupportedTXPowerIndex defines the maximum supported tx-power index
    // by the node, or 0 when not set.
    uint32 max_supported_tx_power_index = 21;

	// NbTrans defines the number of transmissions for each unconfirmed uplink
	// frame. In case of 0, the default value is used.
    // This value is controlled by the ADR engine.
    uint32 nb_trans = 23;

    // Channels that are activated on the device.
    repeated uint32 enabled_uplink_channels = 24;

    // Extra uplink channels, configured by the user.
    map<uint32, DeviceSessionPBChannel> extra_uplink_channels = 25;

    // Frequency of each channel.
    repeated uint32 channel_frequencies = 26;

    // Uplink history for ADR (last 20 uplink transmissions).
    repeated DeviceSessionPBUplinkADRHistory uplink_adr_history = 27;

    // Last device-status requested timestamp (Unix ns)
    int64 last_device_status_request_time_unix_ns = 29;

    // Last downlink timestamp (Unix ns).
    int64 last_downlink_tx_timestamp_unix_ns = 32;

    // Class-B beacon is locked.
    bool beacon_locked = 33;

    // Class-B ping-slot nb.
    uint32 ping_slot_nb = 34;

    // Class-B ping-slot data-rate.
    uint32 ping_slot_dr = 35;

    // Class-B ping-slot tx frequency.
    uint32 ping_slot_frequency = 36;

    // LoRaWAN mac-version.
    string mac_version = 37;

	// MinSupportedTXPowerIndex defines the minimum supported tx-power index
    // by the node (default 0).
    uint32 min_supported_tx_power_index = 38;

    // RejoinRequestEnabled defines if the rejoin-request is enabled on the
    // device.
    bool rejoin_request_enabled = 44;

	// RejoinRequestMaxCountN defines the 2^(C+4) uplink message interval for
    // the rejoin-request.
    uint32 rejoin_request_max_count_n = 40;

	// RejoinRequestMaxTimeN defines the 2^(T+10) time interval (seconds)
    // for the rejoin-request.
    uint32 rejoin_request_max_time_n = 41;

    // Rejoin counter (RJCount0).
    // This counter is reset to 0 after each successful join-accept.
    uint32 rejoin_count_0 = 42;

    // Pending rejoin device-session contains a device-session which has not
    // yet been activated by the device (by sending a first uplink).
    bytes pending_rejoin_device_session = 43;

    // Device reference altitude for geolocation.
    double reference_altitude = 46;

    // UplinkDwellTime.
    bool uplink_dwell_time_400ms = 47;

    // DownlinkDwellTime.
    bool downlink_dwell_time_400ms = 48;

    // Uplink max. EIRP index.
    uint32 uplink_max_eirp_index = 49;

    // Mac-command error counter.
    map<uint32, uint32> mac_command_error_count = 50;
}

We are only decoding it for the devAddr, nwkSEncKey, and nFCntDown fields.

Please use the API for this :slight_smile: This data (reading directly from Redis) could change any time and break your application.