bds_plugin/react-native-ble-quick-sdk-bds-plugin/Plugin.js
function generateBLEPayloadParser(profileData) {
	var outputSrc = "";
		
	log(" ***************************************************************************");
	log("    Generating JavaScript source file for BLE Payload parser "  );
	log(" ***************************************************************************");
	
	outputSrc =   outputSrc +  addLicenseText();
  
	outputSrc =   outputSrc +     	 
	"//" + "\r\n" +
	"//  PayloadParser.js" + "\r\n" +
	"//" + "\r\n" +
	"//  Autogenerated source" + "\r\n" +
	"//" + "\r\n" +
	"// ---------------------------------" + "\r\n" +
	"//  BLE Payload parser " + "\r\n" + 
	"// ---------------------------------" + "\r\n" + "\r\n" +
" 'use strict'" + "\r\n" +

" var Int64LE = require('int64-buffer').Int64LE; " + "\r\n" +

" import DLog from '../common/DLog'; " + "\r\n" +
" const dp =require('./PayloadDefs'); "  + "\r\n" + "\r\n";

for (var x = 0; x < profileData.Services.length; x++) 
{
	var service = profileData.Services[x];
	var serviceNameStr =  prepareSrcString(service.Name);
	var svcNameSnakeStr =  prepareSrcStringAsSnakeCase(service.Name);

		for( var y = 0; y < service.Characteristics.length; y++)
        {
			var characteristic = service.Characteristics[y];
			var characteristicNameStr =  prepareSrcString(characteristic.Name);
			var characteristicNameSnakeStr =  prepareSrcStringAsSnakeCase(characteristic.Name);
			var chr_json_filename = "chr_" + characteristicNameSnakeStr;
			
			outputSrc = outputSrc + 			
			"  var " + chr_json_filename + "_JSON = require('../device_services/profile/chr/" + chr_json_filename + "'); " + "\r\n" +
			"  var " + chr_json_filename + "_uuid = " + chr_json_filename + "_JSON.Characteristic.uuid; "  + "\r\n" +
			"  if(" + chr_json_filename + "_JSON.Characteristic.Value != undefined ){  "  + "\r\n" +
			"  		var " + chr_json_filename + "_format = " + chr_json_filename + "_JSON.Characteristic.Value.Field.Format; "  + "\r\n" +
			"  } " + "\r\n";
			
		}
}

	outputSrc =   outputSrc +   "\r\n" +
	" var nPayloadParserObjCnt = 0; " + "\r\n" +
	" var instancePayloadParser = null; " + "\r\n" +

	" const BLE_CHARC_VALUE_MAX_LEN = 20; " + "\r\n" +   "\r\n" +


	" export function getPayloadParserInstance() " + "\r\n" +
	" { " + "\r\n" +
		
	"     if(nPayloadParserObjCnt > 0 ) " + "\r\n" +
	"     { " + "\r\n" +
	"          DLog.printDebugMsg('Its a singleton class, returning existing instance of PayloadParser class '); " + "\r\n" +
	"         return instancePayloadParser; " + "\r\n" +
	"     } " + "\r\n"  +
		
	"      nPayloadParserObjCnt++; " + "\r\n" +
	"      DLog.printDebugMsg('PayloadParser Object Count is ' + nPayloadParserObjCnt); " + "\r\n" +
		
		
		
	"     instancePayloadParser = new PayloadParser(); " + "\r\n" +
		

	"     return instancePayloadParser; " + "\r\n" +
		
		
	" } " + "\r\n" +   "\r\n" +

	" class PayloadParser  { " + "\r\n" +
		
	"     constructor(props){ " + "\r\n" +


	"     } " + "\r\n" +   "\r\n" +

		

	"     parse(svc_class_name,args) " + "\r\n" +
	"     { " + "\r\n" +
	"         switch(args.characteristic) " + "\r\n" +
	"         {  " + "\r\n";

	for (var x = 0; x < profileData.Services.length; x++) 
	{
		var service = profileData.Services[x];
		var serviceNameStr =  prepareSrcString(service.Name);
		var svcNameSnakeStr =  prepareSrcStringAsSnakeCase(service.Name);

			for( var y = 0; y < service.Characteristics.length; y++)
			{
				var characteristic = service.Characteristics[y];
				var characteristicNameStr =  prepareSrcString(characteristic.Name);
				var characteristicNameSnakeStr =  prepareSrcStringAsSnakeCase(characteristic.Name);
				var chr_json_filename = "chr_" + characteristicNameSnakeStr;
				var pkt_chr_name = "pkt_" + characteristicNameSnakeStr;
				
				outputSrc = outputSrc + 			
	"			  case "+ chr_json_filename +"_uuid.toUpperCase() : " + "\r\n" +
	"                 DLog.printDebug(this,' Characteristics format is = '+ " +  chr_json_filename + "_format );" + "\r\n" +                
	"                 if( " + chr_json_filename + "_format == 'uint8' || " + "\r\n" +
	"                    " + chr_json_filename + "_format == 'uint16' || " + "\r\n" +
	"                    " + chr_json_filename + "_format == 'uint32' || " + "\r\n" +
	"                    " + chr_json_filename + "_format == 'uint64') " + "\r\n" +
	"                 {" + "\r\n" +

	"                     let " + pkt_chr_name + " = {" + "\r\n" +
	"                         "+  characteristicNameStr +" : {" + "\r\n" +
	"                             'FMT':' '," + "\r\n" +
	"                         }" + "\r\n" +
	"                     }" + "\r\n" +
						
	"                     " + pkt_chr_name + "."+ characteristicNameStr +".FMT = " + chr_json_filename + "_format;" + "\r\n" +
						
	"                     return this.parseDatapayloadPkt(args.value, " + pkt_chr_name + ");" + "\r\n" +
	"                 }" + "\r\n" +
	"                 else" + "\r\n" +
	"                 {" + "\r\n" +
	"                     if(dp." + pkt_chr_name + " != undefined) {" + "\r\n" +
	"                         return this.parseDatapayloadPkt(args.value,dp." + pkt_chr_name + ");" + "\r\n" +
	"                     }" + "\r\n" +
	"                     break;" + "\r\n" +
	"                 } " + "\r\n";

			}
	}



	outputSrc =   outputSrc + 
	"             default : " + "\r\n" +
	"                 return null; " + "\r\n" +
					
	"         } " + "\r\n" +
			
	"         return null; " + "\r\n" +
	"     } " + "\r\n" + "\r\n" + 
		

	"     parseDatapayloadPkt(packetArr, datapayloadDef)" + "\r\n" +
	"     { " + "\r\n" + 
			
	"         var packetBytBuf  = this.byteArray2DVByteBuffer(packetArr); " + "\r\n" + 
	"         if(packetBytBuf === null) " + "\r\n" + 
	"         { " + "\r\n" + 
	"             DLog.printDebug(this,'packetBytBuf is NUll '); " + "\r\n" + 
	"             return 'parse_error'; " + "\r\n" + 
	"         } " + "\r\n" + "\r\n" + 

	"         var datapayloadStruct =  {}; " + "\r\n" + 
	"         var totaldatapayloadStructKeys =  Object.keys(datapayloadStruct).length; " + "\r\n" + 
	"         var totaldatapayloadStructValues =  Object.values(datapayloadStruct).length; " + "\r\n" + 
			
	"         var totalFields = Object.keys(datapayloadDef).length; " + "\r\n" + "\r\n" + 
	"         DLog.printDebug(this,'total datapayload Fields =  ' + totalFields + " + "\r\n" + 
	"                         ' /totaldatapayloadStructKeys =  ' + totaldatapayloadStructKeys  + " + "\r\n" + 
	"                         ' /totaldatapayloadStructValues =  ' + totaldatapayloadStructValues ); " + "\r\n" + "\r\n" + 
	"         for (var [keyFieldName, valueFieldDef] of Object.entries(datapayloadDef)) { " + "\r\n" + 

	"             datapayloadStruct[keyFieldName] = this.extractData(packetBytBuf, valueFieldDef); " + "\r\n" + 
	"         } " + "\r\n" + "\r\n" + 
			
	"         totaldatapayloadStructKeys =  Object.keys(datapayloadStruct).length " + "\r\n" + 
	"         totaldatapayloadStructValues =  Object.values(datapayloadStruct).length; " + "\r\n" + "\r\n" + 
	"         DLog.printDebug(this,'/totaldatapayloadStructKeys =  ' + totaldatapayloadStructKeys  +  " + "\r\n" + 
	"                         ' /totaldatapayloadStructValues =  ' + totaldatapayloadStructValues );  " + "\r\n" + 
			
	"         DLog.printDebug(this,datapayloadStruct);  " + "\r\n" + "\r\n" + 
	"         return datapayloadStruct;  " + "\r\n" + 
	"     } " + "\r\n" + "\r\n" + 
	"     extractData(payloadDataBytBuf, payloadDataFieldDef) " + "\r\n" + 
	"     { " + "\r\n" + 
	"         let dataPos = payloadDataFieldDef.POS || 0; " + "\r\n" + 
	"         let dataType = payloadDataFieldDef.FMT || 'uint8'; " + "\r\n" + 
	"         let dataLenInBytes = payloadDataFieldDef.LEN || 1; " + "\r\n" + "\r\n" + 
	"         DLog.printDebug(this,' payloadDataFieldDef =  ' + dataPos + '/' + dataType + '/' + dataLenInBytes); " + "\r\n" + "\r\n" + 
			
	"         switch (dataType) { " + "\r\n" + 
	"             case 'uint8': " + "\r\n" + 
	"                 return payloadDataBytBuf.getUint8(dataPos, true); // LITTLE_ENDIAN  " + "\r\n" + 
	"             case 'uint16': " + "\r\n" + 
	"                 return payloadDataBytBuf.getUint16(dataPos, true); " + "\r\n" + 
	"             case 'uint32': " + "\r\n" + 
	"                 return payloadDataBytBuf.getUint32(dataPos, true); " + "\r\n" + 
	"             case 'uint64': " + "\r\n" + 
	"                 return null; " + "\r\n" + 
	"             case 'string_ascii': " + "\r\n" + 
	"                 return this.extractStringData(payloadDataBytBuf, dataPos, dataLenInBytes) " + "\r\n" + 
	"             default: " + "\r\n" + 
	"                 return null; " + "\r\n" + 
	"         } " + "\r\n" + 
	"     } " + "\r\n" + "\r\n" + 
	"     extractStringData(payloadDataBytBuf, keyvalueSeekPos, keyvalueLen) { " + "\r\n" + 
	"         var keyvalueStr = ''; " + "\r\n" + 

	"         if(keyvalueLen > BLE_CHARC_VALUE_MAX_LEN) " + "\r\n" + 
	"         { " + "\r\n" + 
	"             keyvalueLen = BLE_CHARC_VALUE_MAX_LEN; " + "\r\n" + 
	"         } " + "\r\n" + "\r\n" + 
			
			 
				
	"         var keyvalueSeekPos = 0; " + "\r\n" + 
	"         for(var m=0;m<keyvalueLen;m++) " + "\r\n" + 
	"         { " + "\r\n" + 
					
	"              var keyvaluebyte     = payloadDataBytBuf.getUint8(keyvalueSeekPos, true); " + "\r\n" + 
	"              keyvalueStr = keyvalueStr + String.fromCharCode(keyvaluebyte); " + "\r\n" + 
					
	"              DLog.printDebug(this, 'keyvalueStr= ' + keyvalueStr); " + "\r\n" + 
	"              keyvalueSeekPos++; " + "\r\n" + 
	"         } " + "\r\n" + 
	"         DLog.printDebug(this, 'keyvalueStr= ' + keyvalueStr); " + "\r\n" + 
			
			
	"         return keyvalueStr; " + "\r\n" + 

	"      }" + "\r\n" +  "\r\n" + 


	"     byteArray2DVByteBuffer(byteArray) " + "\r\n" + 
	"     { " + "\r\n" + 
	"         var byteArrayLen = byteArray.length; " + "\r\n" + "\r\n" + 
	"         if(byteArrayLen < 1) " + "\r\n" + 
	"         { " + "\r\n" + 
	"             DLog.printDebug(this,'packet byte arr size is zero = ' + byteArrayLen); " + "\r\n" + 
	"             return null; " + "\r\n" + 
	"         } " + "\r\n" + "\r\n" + 
			
	"         DLog.printDebug(this,'packet byte arr size = ' + byteArrayLen); " + "\r\n" + "\r\n" + 
			
	"         var objUint8Array   = new Uint8Array(new ArrayBuffer(byteArrayLen)); " + "\r\n" + 
			
	"         objUint8Array.set(byteArray); " + "\r\n" + "\r\n" + 
			
			
	"         var dvByteBuf  = new DataView(objUint8Array.buffer); " + "\r\n" + 
			
	"         for(var m=0;m<byteArrayLen;m++) " + "\r\n" + 
	"         { " + "\r\n" + 
				
	"             DLog.printDebug(this,'DVByteBuf = ' + dvByteBuf.getUint8(m)); " + "\r\n" + 
	"         } " + "\r\n" + 
			
	"         return dvByteBuf; " + "\r\n" + 
	"     } " + "\r\n" + 
		

		
	"   } " + "\r\n";

	FileManager.CreateFile(".\\protocols\\PayloadParser.js", outputSrc);

	
	log("PayloadParser.js generated sucessfully	" );
	log(" ---------------------------------------------------------------------");
		
}
function generateBLEPayloadParser(profileData) {
	var outputSrc = "";
		
	log(" ***************************************************************************");
	log("    Generating JavaScript source file for BLE Payload parser "  );
	log(" ***************************************************************************");
	
	outputSrc =   outputSrc +  addLicenseText();
  
	outputSrc =   outputSrc +     	 
	"//" + "\r\n" +
	"//  PayloadParser.js" + "\r\n" +
	"//" + "\r\n" +
	"//  Autogenerated source" + "\r\n" +
	"//" + "\r\n" +
	"// ---------------------------------" + "\r\n" +
	"//  BLE Payload parser " + "\r\n" + 
	"// ---------------------------------" + "\r\n" + "\r\n" +
" 'use strict'" + "\r\n" +

" var Int64LE = require('int64-buffer').Int64LE; " + "\r\n" +

" import DLog from '../common/DLog'; " + "\r\n" +
" const dp =require('./PayloadDefs'); "  + "\r\n" + "\r\n";

for (var x = 0; x < profileData.Services.length; x++) 
{
	var service = profileData.Services[x];
	var serviceNameStr =  prepareSrcString(service.Name);
	var svcNameSnakeStr =  prepareSrcStringAsSnakeCase(service.Name);

		for( var y = 0; y < service.Characteristics.length; y++)
        {
			var characteristic = service.Characteristics[y];
			var characteristicNameStr =  prepareSrcString(characteristic.Name);
			var characteristicNameSnakeStr =  prepareSrcStringAsSnakeCase(characteristic.Name);
			var chr_json_filename = "chr_" + characteristicNameSnakeStr;
			
			outputSrc = outputSrc + 			
			"  var " + chr_json_filename + "_JSON = require('../device_services/profile/chr/" + chr_json_filename + "'); " + "\r\n" +
			"  var " + chr_json_filename + "_uuid = " + chr_json_filename + "_JSON.Characteristic.uuid; "  + "\r\n" +
			"  if(" + chr_json_filename + "_JSON.Characteristic.Value != undefined ){  "  + "\r\n" +
			"  		var " + chr_json_filename + "_format = " + chr_json_filename + "_JSON.Characteristic.Value.Field.Format; "  + "\r\n" +
			"  } " + "\r\n";
			
		}
}

	outputSrc =   outputSrc +   "\r\n" +
	" var nPayloadParserObjCnt = 0; " + "\r\n" +
	" var instancePayloadParser = null; " + "\r\n" +

	" const BLE_CHARC_VALUE_MAX_LEN = 20; " + "\r\n" +   "\r\n" +


	" export function getPayloadParserInstance() " + "\r\n" +
	" { " + "\r\n" +
		
	"     if(nPayloadParserObjCnt > 0 ) " + "\r\n" +
	"     { " + "\r\n" +
	"          DLog.printDebugMsg('Its a singleton class, returning existing instance of PayloadParser class '); " + "\r\n" +
	"         return instancePayloadParser; " + "\r\n" +
	"     } " + "\r\n"  +
		
	"      nPayloadParserObjCnt++; " + "\r\n" +
	"      DLog.printDebugMsg('PayloadParser Object Count is ' + nPayloadParserObjCnt); " + "\r\n" +
		
		
		
	"     instancePayloadParser = new PayloadParser(); " + "\r\n" +
		

	"     return instancePayloadParser; " + "\r\n" +
		
		
	" } " + "\r\n" +   "\r\n" +

	" class PayloadParser  { " + "\r\n" +
		
	"     constructor(props){ " + "\r\n" +


	"     } " + "\r\n" +   "\r\n" +

		

	"     parse(svc_class_name,args) " + "\r\n" +
	"     { " + "\r\n" +
	"         switch(args.characteristic) " + "\r\n" +
	"         {  " + "\r\n";

	for (var x = 0; x < profileData.Services.length; x++) 
	{
		var service = profileData.Services[x];
		var serviceNameStr =  prepareSrcString(service.Name);
		var svcNameSnakeStr =  prepareSrcStringAsSnakeCase(service.Name);

			for( var y = 0; y < service.Characteristics.length; y++)
			{
				var characteristic = service.Characteristics[y];
				var characteristicNameStr =  prepareSrcString(characteristic.Name);
				var characteristicNameSnakeStr =  prepareSrcStringAsSnakeCase(characteristic.Name);
				var chr_json_filename = "chr_" + characteristicNameSnakeStr;
				var pkt_chr_name = "pkt_" + characteristicNameSnakeStr;
				
				outputSrc = outputSrc + 			
	"			  case "+ chr_json_filename +"_uuid.toUpperCase() : " + "\r\n" +
	"                 DLog.printDebug(this,' Characteristics format is = '+ " +  chr_json_filename + "_format );" + "\r\n" +                
	"                 if( " + chr_json_filename + "_format == 'uint8' || " + "\r\n" +
	"                    " + chr_json_filename + "_format == 'uint16' || " + "\r\n" +
	"                    " + chr_json_filename + "_format == 'uint32' || " + "\r\n" +
	"                    " + chr_json_filename + "_format == 'uint64') " + "\r\n" +
	"                 {" + "\r\n" +

	"                     let " + pkt_chr_name + " = {" + "\r\n" +
	"                         "+  characteristicNameStr +" : {" + "\r\n" +
	"                             'FMT':' '," + "\r\n" +
	"                         }" + "\r\n" +
	"                     }" + "\r\n" +
						
	"                     " + pkt_chr_name + "."+ characteristicNameStr +".FMT = " + chr_json_filename + "_format;" + "\r\n" +
						
	"                     return this.parseDatapayloadPkt(args.value, " + pkt_chr_name + ");" + "\r\n" +
	"                 }" + "\r\n" +
	"                 else" + "\r\n" +
	"                 {" + "\r\n" +
	"                     if(dp." + pkt_chr_name + " != undefined) {" + "\r\n" +
	"                         return this.parseDatapayloadPkt(args.value,dp." + pkt_chr_name + ");" + "\r\n" +
	"                     }" + "\r\n" +
	"                     break;" + "\r\n" +
	"                 } " + "\r\n";

			}
	}



	outputSrc =   outputSrc + 
	"             default : " + "\r\n" +
	"                 return null; " + "\r\n" +
					
	"         } " + "\r\n" +
			
	"         return null; " + "\r\n" +
	"     } " + "\r\n" + "\r\n" + 
		

	"     parseDatapayloadPkt(packetArr, datapayloadDef)" + "\r\n" +
	"     { " + "\r\n" + 
			
	"         var packetBytBuf  = this.byteArray2DVByteBuffer(packetArr); " + "\r\n" + 
	"         if(packetBytBuf === null) " + "\r\n" + 
	"         { " + "\r\n" + 
	"             DLog.printDebug(this,'packetBytBuf is NUll '); " + "\r\n" + 
	"             return 'parse_error'; " + "\r\n" + 
	"         } " + "\r\n" + "\r\n" + 

	"         var datapayloadStruct =  {}; " + "\r\n" + 
	"         var totaldatapayloadStructKeys =  Object.keys(datapayloadStruct).length; " + "\r\n" + 
	"         var totaldatapayloadStructValues =  Object.values(datapayloadStruct).length; " + "\r\n" + 
			
	"         var totalFields = Object.keys(datapayloadDef).length; " + "\r\n" + "\r\n" + 
	"         DLog.printDebug(this,'total datapayload Fields =  ' + totalFields + " + "\r\n" + 
	"                         ' /totaldatapayloadStructKeys =  ' + totaldatapayloadStructKeys  + " + "\r\n" + 
	"                         ' /totaldatapayloadStructValues =  ' + totaldatapayloadStructValues ); " + "\r\n" + "\r\n" + 
	"         for (var [keyFieldName, valueFieldDef] of Object.entries(datapayloadDef)) { " + "\r\n" + 

	"             datapayloadStruct[keyFieldName] = this.extractData(packetBytBuf, valueFieldDef); " + "\r\n" + 
	"         } " + "\r\n" + "\r\n" + 
			
	"         totaldatapayloadStructKeys =  Object.keys(datapayloadStruct).length " + "\r\n" + 
	"         totaldatapayloadStructValues =  Object.values(datapayloadStruct).length; " + "\r\n" + "\r\n" + 
	"         DLog.printDebug(this,'/totaldatapayloadStructKeys =  ' + totaldatapayloadStructKeys  +  " + "\r\n" + 
	"                         ' /totaldatapayloadStructValues =  ' + totaldatapayloadStructValues );  " + "\r\n" + 
			
	"         DLog.printDebug(this,datapayloadStruct);  " + "\r\n" + "\r\n" + 
	"         return datapayloadStruct;  " + "\r\n" + 
	"     } " + "\r\n" + "\r\n" + 
	"     extractData(payloadDataBytBuf, payloadDataFieldDef) " + "\r\n" + 
	"     { " + "\r\n" + 
	"         let dataPos = payloadDataFieldDef.POS || 0; " + "\r\n" + 
	"         let dataType = payloadDataFieldDef.FMT || 'uint8'; " + "\r\n" + 
	"         let dataLenInBytes = payloadDataFieldDef.LEN || 1; " + "\r\n" + "\r\n" + 
	"         DLog.printDebug(this,' payloadDataFieldDef =  ' + dataPos + '/' + dataType + '/' + dataLenInBytes); " + "\r\n" + "\r\n" + 
			
	"         switch (dataType) { " + "\r\n" + 
	"             case 'uint8': " + "\r\n" + 
	"                 return payloadDataBytBuf.getUint8(dataPos, true); // LITTLE_ENDIAN  " + "\r\n" + 
	"             case 'uint16': " + "\r\n" + 
	"                 return payloadDataBytBuf.getUint16(dataPos, true); " + "\r\n" + 
	"             case 'uint32': " + "\r\n" + 
	"                 return payloadDataBytBuf.getUint32(dataPos, true); " + "\r\n" + 
	"             case 'uint64': " + "\r\n" + 
	"                 return null; " + "\r\n" + 
	"             case 'string_ascii': " + "\r\n" + 
	"                 return this.extractStringData(payloadDataBytBuf, dataPos, dataLenInBytes) " + "\r\n" + 
	"             default: " + "\r\n" + 
	"                 return null; " + "\r\n" + 
	"         } " + "\r\n" + 
	"     } " + "\r\n" + "\r\n" + 
	"     extractStringData(payloadDataBytBuf, keyvalueSeekPos, keyvalueLen) { " + "\r\n" + 
	"         var keyvalueStr = ''; " + "\r\n" + 

	"         if(keyvalueLen > BLE_CHARC_VALUE_MAX_LEN) " + "\r\n" + 
	"         { " + "\r\n" + 
	"             keyvalueLen = BLE_CHARC_VALUE_MAX_LEN; " + "\r\n" + 
	"         } " + "\r\n" + "\r\n" + 
			
			 
				
	"         var keyvalueSeekPos = 0; " + "\r\n" + 
	"         for(var m=0;m<keyvalueLen;m++) " + "\r\n" + 
	"         { " + "\r\n" + 
					
	"              var keyvaluebyte     = payloadDataBytBuf.getUint8(keyvalueSeekPos, true); " + "\r\n" + 
	"              keyvalueStr = keyvalueStr + String.fromCharCode(keyvaluebyte); " + "\r\n" + 
					
	"              DLog.printDebug(this, 'keyvalueStr= ' + keyvalueStr); " + "\r\n" + 
	"              keyvalueSeekPos++; " + "\r\n" + 
	"         } " + "\r\n" + 
	"         DLog.printDebug(this, 'keyvalueStr= ' + keyvalueStr); " + "\r\n" + 
			
			
	"         return keyvalueStr; " + "\r\n" + 

	"      }" + "\r\n" +  "\r\n" + 


	"     byteArray2DVByteBuffer(byteArray) " + "\r\n" + 
	"     { " + "\r\n" + 
	"         var byteArrayLen = byteArray.length; " + "\r\n" + "\r\n" + 
	"         if(byteArrayLen < 1) " + "\r\n" + 
	"         { " + "\r\n" + 
	"             DLog.printDebug(this,'packet byte arr size is zero = ' + byteArrayLen); " + "\r\n" + 
	"             return null; " + "\r\n" + 
	"         } " + "\r\n" + "\r\n" + 
			
	"         DLog.printDebug(this,'packet byte arr size = ' + byteArrayLen); " + "\r\n" + "\r\n" + 
			
	"         var objUint8Array   = new Uint8Array(new ArrayBuffer(byteArrayLen)); " + "\r\n" + 
			
	"         objUint8Array.set(byteArray); " + "\r\n" + "\r\n" + 
			
			
	"         var dvByteBuf  = new DataView(objUint8Array.buffer); " + "\r\n" + 
			
	"         for(var m=0;m<byteArrayLen;m++) " + "\r\n" + 
	"         { " + "\r\n" + 
				
	"             DLog.printDebug(this,'DVByteBuf = ' + dvByteBuf.getUint8(m)); " + "\r\n" + 
	"         } " + "\r\n" + 
			
	"         return dvByteBuf; " + "\r\n" + 
	"     } " + "\r\n" + 
		

		
	"   } " + "\r\n";

	FileManager.CreateFile(".\\protocols\\PayloadParser.js", outputSrc);

	
	log("PayloadParser.js generated sucessfully	" );
	log(" ---------------------------------------------------------------------");
		
}
/////////////// source generators ///////////////////////////////////////////