Creating Payload mapping script

The payload mapping script implements the codec functionality and exports it by the name codec. The skeleton code is shown as follows:

function CodecName() {
    this.encode = function (impactRequest) {

        // implementation of encoder for north-bound (downlink) request 
    }
     
    this.decode = function (decodeCtx) {
 
        // implementation of decoder for south-bound (uplink) payload
    }
 
}

// instantiate and export codec 
var codec = new CodecName();
 
(codec);

The codec function includes two sub functions:

  1. encode – which is used to Encode downlink requests
  2. cecode – which is used to Decode uplink request