code: func GetNextDeviceQueueItemForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceQueueItem, error) {
  	var qi DeviceQueueItem
  	err := sqlx.Get(db, &qi, `
          select
              *
          from
              device_queue
          where
              dev_eui = $1
          order by
              f_cnt
          limit 1`,
  		devEUI[:],
  	)
  	if err != nil {
  		return qi, handlePSQLError(err, "select error")
  	}
  
  	// In case the transmission is pending and hasn't timed-out yet, do not
  	// return it.
  	if qi.IsPending && qi.TimeoutAfter != nil && qi.TimeoutAfter.After(time.Now()) {
  		return DeviceQueueItem{}, ErrDoesNotExist
  	}
  
  	return qi, nil
  }
docs: // GetNextDeviceQueueItemForDevEUI returns the next device-queue item for the
  // given DevEUI, ordered by f_cnt (note that the f_cnt should never roll over).