kybarg / ssp

Node.JS implementation of Encrypted Smiley ® Secure Protocol (eSSP, SSP)
MIT License
5 stars 2 forks source link

COMMAND_CANNOT_BE_PROCESSED #1

Closed VictorJacobo closed 5 months ago

VictorJacobo commented 5 months ago

I have a problem with the Smart Payout, I tried to use the comand SET_DENOMINATION_ROUTE but always get this error:

{
  command: 'SET_DENOMINATION_ROUTE',
  tx: {
    createdAt: 1715715364874,
    encrypted: <Buffer 7f 00 11 7e 3c 07 6d f5 89 ed 64 2e d1 69 43 3d 8a 4b 53 c9 ff 01>,
    plain: <Buffer 7f 00 09 3b 00 14 00 00 00 4d 58 4e 3c d2>
  },
  rx: {
    createdAt: 1715715364936,
    encrypted: <Buffer 7f 00 11 7e 6e a9 43 1b fd 45 b1 47 b4 34 24 82 46 51 b0 11 73 97>,
    plain: <Buffer 7f 00 01 f5 3e 0a>
  }
}
{
  success: false,
  status: 'COMMAND_CANNOT_BE_PROCESSED',
  command: 'SET_DENOMINATION_ROUTE',
  info: { errorCode: undefined, error: 'Unknown error' }
}

This is the code:

const SSP = require('./lib/index.js')
const channels = [{ value: 0, country_code: 'XXX' }]

const serialPortConfig = {
  baudRate: 9600, // default: 9600
  dataBits: 8, // default: 8
  stopBits: 2, // default: 2
  parity: 'none', // default: 'none'
}

const eSSP = new SSP({
  id: 0x00,
  timeout: 1000, // default: 3000
  encryptAllCommand: true, // default: true
  fixedKey: '0123456701234567', // default: '0123456701234567'
})

eSSP.on('DATA_RECEIVED', data => {
  console.log(data)
})

eSSP.on('DEBUG', data => {
  console.log(data)
})

eSSP.on('OPEN', () => {
  console.log('Port opened!')
})

eSSP.on('CLOSE', () => {
  console.log('Port closed!')
})

eSSP.on('READ_NOTE', result => {
  console.log('READ_NOTE', result)
  console.log(channels[result.channel])

  if (channels[result.channel].value === 500) {
    eSSP.command('REJECT_BANKNOTE')
  }
})

eSSP.on('NOTE_REJECTED', result => {
  console.log('NOTE_REJECTED', result)

  eSSP.command('LAST_REJECT_CODE').then(result => {
    console.log(result)
  })
})

eSSP
  .open('COM5', serialPortConfig)
  .then(() => eSSP.command('SYNC'))
  .then(() => eSSP.command('HOST_PROTOCOL_VERSION', { version: 6 }))
  .then(() => eSSP.initEncryption())
  .then(() => eSSP.command('GET_SERIAL_NUMBER'))
  .then(result => {
    console.log(eSSP.keys.encryptKey)
    console.log('SERIAL NUMBER:', result.info.serial_number)
    return
  })
  .then(() => eSSP.command('UNIT_DATA'))
  .then(() => eSSP.command('SETUP_REQUEST'))
  .then(result => {
    for (let i = 0; i < result.info.channel_value.length; i++) {
      channels[i + 1] = {
        value: result.info.expanded_channel_value[i],
        country_code: result.info.expanded_channel_country_code[i],
      }
    }
    console.log('channels', channels)
    return
  })
  .then(() =>
    eSSP.command('SET_CHANNEL_INHIBITS', {
      channels: Array(channels.length).fill(1),
    }),
  )
  .then(() => eSSP.command('SET_DENOMINATION_ROUTE', { route: 'payout', value: 20, country_code: 'MXN', isHopper: false }))
  .then(() => eSSP.command('SET_DENOMINATION_ROUTE', { route: 'payout', value: 50, country_code: 'MXN', isHopper: false }))
  .then(() => eSSP.command('SET_DENOMINATION_ROUTE', { route: 'payout', value: 100, country_code: 'MXN', isHopper: false }))
  .then(() => eSSP.enable())
  .then(() => {
    console.log('GO!!!')
  })
  .catch(error => {
    console.log(error)
  })`
kybarg commented 5 months ago

@VictorJacobo not sure, but that could be due incorrect value. Please check real_value_multiplier from SETUP_REQUEST command. 20 migh be 20 cents whcih is not supported by tou device as it supports bills ony. So 20 MXN bill value might be 2000 (20 * real_value_multiplier)

Also for real word app make sure to use real_value_multiplier.

VictorJacobo commented 5 months ago

Incredible, that worked. Thank you very much, I'm really new to this validator stuff.

ulissesgrz commented 4 months ago

@VictorJacobo como te puedo contactar ? saludos

HugoBaez commented 3 months ago

vpvbbj2019@gmail.com