The device is in an invalid device-class for this action

Hello.
I need help.

Device 000000001103001b, join OTAA. Class C. Lorawan mac version 1.0.2B

Nov 16 06:51:05 iot loraserver[27513]: time="2018-11-16T06:51:05Z" level=error msg="schedule next device-queue item error" dev_eui=000000001103001b error="the device is in an invalid device-class for this action"
Nov 16 06:51:06 iot loraserver[27513]: time="2018-11-16T06:51:06Z" level=error msg="schedule next device-queue item error" dev_eui=000000001103001b error="the device is in an invalid device-class for this action"
Nov 16 06:51:07 iot loraserver[27513]: time="2018-11-16T06:51:07Z" level=error msg="schedule next device-queue item error" dev_eui=000000001103001b error="the device is in an invalid device-class for this action"
Nov 16 06:51:08 iot loraserver[27513]: time="2018-11-16T06:51:08Z" level=error msg="schedule next device-queue item error" dev_eui=000000001103001b error="the device is in an invalid device-class for this action"

Thank you

{
  "deviceQueueItems": [
    {
      "devEUI": "000000001103001b",
      "confirmed": true,
      "fCnt": 51,
      "fPort": 3,
      "data": "AQ==",
      "jsonObject": ""
    },
    {
      "devEUI": "000000001103001b",
      "confirmed": true,
      "fCnt": 52,
      "fPort": 3,
      "data": "AQ==",
      "jsonObject": ""
    }
  ]
}
{
  "device": {
    "devEUI": "000000001103001b",
    "name": "000000001103001b",
    "applicationID": "2",
    "description": "000000001103001b",
    "deviceProfileID": "0c8c58f3-449e-4b95-8fcf-e18274539f82",
    "skipFCntCheck": false,
    "referenceAltitude": 0
  },
  "lastSeenAt": "2018-11-16T01:57:08.367214Z",
  "deviceStatusBattery": 255,
  "deviceStatusMargin": 17,
  "location": null
}
{
  "deviceProfile": {
    "id": "0c8c58f3-449e-4b95-8fcf-e18274539f82",
    "name": "Default_C_1.0.2B",
    "organizationID": "1",
    "networkServerID": "1",
    "supportsClassB": false,
    "classBTimeout": 0,
    "pingSlotPeriod": 0,
    "pingSlotDR": 0,
    "pingSlotFreq": 0,
    "supportsClassC": true,
    "classCTimeout": 0,
    "macVersion": "1.0.2",
    "regParamsRevision": "B",
    "rxDelay1": 0,
    "rxDROffset1": 0,
    "rxDataRate2": 0,
    "rxFreq2": 0,
    "factoryPresetFreqs": [],
    "maxEIRP": 14,
    "maxDutyCycle": 0,
    "supportsJoin": true,
    "rfRegion": "RU_864_870",
    "supports32BitFCnt": false
  },
  "createdAt": "2018-09-20T08:59:34.070374Z",
  "updatedAt": "2018-11-09T11:26:14.579561Z"
}

View queries that are running to the database

select
    d.*
from
    loraserver_ns.public.device d
inner join loraserver_ns.public.device_profile dp
    on dp.device_profile_id = d.device_profile_id
where (
      dp.supports_class_c = true
      or dp.supports_class_b = true
    )
    -- we want devices with queue items
    and exists (
        select
            1
        from
            loraserver_ns.public.device_queue dq
        where
            dq.dev_eui = d.dev_eui
            and (
              dp.supports_class_c = true
              or (
                dp.supports_class_b = true
                and dq.emit_at_time_since_gps_epoch <= 1226806495
			-- 340779h34m55.164089417s
              )
            )
    )
    -- we don't want device with pending queue items that did not yet
    -- timeout
    and not exists (
        select
            1
        from
            loraserver_ns.public.device_queue dq
        where
            dq.dev_eui = d.dev_eui
            and is_pending = true
            and dq.timeout_after > now()
    )
order by
    d.dev_eui
limit 100
dev_eui created_at updated_at device_profile_id service_profile_id routing_profile_id skip_fcnt_check reference_altitude
E’\x000000001103001B’ 2018-09-25 04:52:00.898111 2018-11-20 03:45:25.815553 2fe7e03f-0889-433f-ab0f-34c0dfe8e33d 0f2c855b-4488-4ad5-82e2-1058727f0c63 6d5db27e-4ce2-4b2b-b5d7-91f069397978 true 0

Sometimes this problem occurs. No one had this problem? Developers do not know why there is and how to solve this problem?

Nov 22 03:47:33 iot loraserver[14307]: time="2018-11-22T03:47:33Z" level=error msg="schedule next device-queue item error" dev_eui=3134363470377014 error="the device is in an invalid device-class for this action"
Nov 22 03:47:34 iot loraserver[14307]: time="2018-11-22T03:47:34Z" level=error msg="schedule next device-queue item error" dev_eui=3134363470377014 error="the device is in an invalid device-class for this action"
Nov 22 03:47:35 iot loraserver[14307]: time="2018-11-22T03:47:35Z" level=error msg="schedule next device-queue item error" dev_eui=3134363470377014 error="the device is in an invalid device-class for this action"
Nov 22 03:47:36 iot loraserver[14307]: time="2018-11-22T03:47:36Z" level=error msg="schedule next device-queue item error" dev_eui=3134363470377014 error="the device is in an invalid device-class for this action"
Nov 22 03:47:37 iot loraserver[14307]: time="2018-11-22T03:47:37Z" level=error msg="schedule next device-queue item error" dev_eui=3134363470377014 error="the device is in an invalid device-class for this action"
Nov 22 03:47:38 iot loraserver[14307]: time="2018-11-22T03:47:38Z" level=error msg="schedule next device-queue item error" dev_eui=3134363470377014 error="the device is in an invalid device-class for this action"

Table “device_queue”

3096	2018-11-22 04:01:17.823866	2018-11-22 04:01:17.823866	1464p7p	E'\\x8C71'	4	2	true	false		

Table “device”

|E'\\x00000000110F0007'|2018-11-20 03:37:22.842727|2018-11-21 05:25:51.340440|2fe7e03f-0889-433f-ab0f-34c0dfe8e33d|0f2c855b-4488-4ad5-82e2-1058727f0c63|6d5db27e-4ce2-4b2b-b5d7-91f069397978|false|0|
|1464p7p|2018-09-21 02:05:10.951647|2018-11-22 03:47:21.162369|0c8c58f3-449e-4b95-8fcf-e18274539f82|0f2c855b-4488-4ad5-82e2-1058727f0c63|6d5db27e-4ce2-4b2b-b5d7-91f069397978|false|0|
|E'\\x00000000110F0054'|2018-11-20 03:37:22.841253|2018-11-21 07:02:34.760221|2fe7e03f-0889-433f-ab0f-34c0dfe8e33d|0f2c855b-4488-4ad5-82e2-1058727f0c63|6d5db27e-4ce2-4b2b-b5d7-91f069397978|false|0|
|E'\\x70B3D58FF00383C1'|2018-09-21 02:21:48.461299|2018-10-02 11:39:21.711613|0c8c58f3-449e-4b95-8fcf-e18274539f82|0f2c855b-4488-4ad5-82e2-1058727f0c63|6d5db27e-4ce2-4b2b-b5d7-91f069397978|false|0|

Table “device_profile”

|2018-09-20 08:55:21.613247|2018-11-09 11:26:09.143938|cef1adf0-974e-400d-9db6-68f6b390b64c|false|0|0|0|0|false|0|1.0.2|B|0|0|0|0||14|0|true|RU_864_870|false|
|2018-09-20 08:59:34.072179|2018-11-09 11:26:14.574367|0c8c58f3-449e-4b95-8fcf-e18274539f82|false|0|0|0|0|true|0|1.0.2|B|0|0|0|0||14|0|true|RU_864_870|false|
|2018-11-08 02:41:16.504209|2018-11-16 05:41:11.355399|2fe7e03f-0889-433f-ab0f-34c0dfe8e33d|false|0|0|0|0|true|0|1.0.0|B|0|0|0|0||14|0|true|RU_864_870|false|
|2018-11-20 03:23:31.249342|2018-11-20 03:24:13.661124|9b390f1d-3dbc-40c3-8e68-082e7583a755|false|0|0|0|0|false|0|1.0.0|B|0|0|0|0||14|0|true|RU_864_870|false|

This issue is probably because you have changed the device-profile after activating the device. As the device-session is created on activation, you might need to re-activate the device in order to apply the device-profile changes that you have made :slight_smile:

(just had this error myself on an other project)

Thanks for the answer. Yes, we have devices that switch class in the course of their work. The device sends a special packet, and our software switches the class using the API. Maybe you have a solution?