Custom Codec limited length?


#1

Is there a limit size for the custom codec ?

I’ve succeeded in submitting different codec but for some reasons when I push the submit button for my last code : nothing happens.

The only different thing is that my code is longer (45 lines) than previous code i’ve submitted.

// Decode decodes an array of bytes into an object.
//  - fPort contains the LoRaWAN fPort number
//  - bytes is an array of bytes, e.g. [225, 230, 255, 0]
// The function must return an object, e.g. {"temperature": 22.5}
function Decode(fPort, bytes) {
	
	var date = new Date();
	var currentTime = date.toISOString();
	
	var header = bytes[0] >> 6;
	
	switch(header) {
		case 0:
			pression = (bytes[0] & 0b00111111) << 6 | bytes[1] >> 2;
			humidity = (bytes[1] & 0b00000011) << 5 | bytes[2] >> 3;
			height_1 = (bytes[2] & 0b00000111) << 9 | bytes[3] << 1 | bytes[4] >> 7;
			height_1_delta_1 = (bytes[4] & 0b01111111) << 1 | bytes[5] >> 7;
			height_2 = (bytes[5] & 0b01111111) << 5 | bytes[6] >> 3;
			height_2_delta_2 = (bytes[6] & 0b0000111) << 5 | bytes[7] >> 3;
			temperature = (bytes[7] & 0b0000111) << 7 | bytes[8] >> 1;
			temperature_delta_1 = (bytes[8] & 0b0000001) << 7 | bytes[9] >> 1;
			temperature_delta_2 = (bytes[9] & 0b0000001) << 7 | bytes[10] >> 1;
			temperature_delta_3 = (bytes[10] & 0b0000001) << 7 | bytes[11] >> 1;
			return {"frameType":"mesure", "pression":{"value": pression, "timestamp": currentTime}, "humidity":humidity, "height_1_delta_1":height_1_delta1, "height_2":height_2, "height_2_delta_2":height_2_delta_2, "temperature":temperature, "temperature_delta_1":temperature_delta_1, "temperature_delta_2":temperature_delta_2, "temperature_delta_3":temperature_delta_3};
		case 1:
			pression = (bytes[0] & 0b00111111) << 6 | bytes[1] >> 2;
			humidity = (bytes[1] & 0b00000011) << 5 | bytes[2] >> 3;
			temperature = (bytes[2] & 0b0000111) << 7 | bytes[3] >> 1;
			battery = (bytes[3] & 0b0000001) << 9 | bytes[4] << 1 | bytes[5] >> 7;
			accelerometer_X = (bytes[5] & 0b01111110);
			accelerometer_Y = (bytes[5] & 0b0000001) << 5 | bytes[6] >> 3;
			accelerometer_Z = (bytes[6] & 0b0000111) << 3 | bytes[7] >> 5;
			return {"frameType":"status", "pression":pression, "humidity":humidity, "temperature":temperature, "battery":battery, "accelerometer_X":accelerometer_X, "accelerometer_Y":accelerometer_Y, "accelerometer_Z":accelerometer_Z};
		case 2:
			pression = (bytes[0] & 0b00111111) << 6 | bytes[1] >> 2;
			humidity = (bytes[1] & 0b00000011) << 5 | bytes[2] >> 3;
			temperature = (bytes[2] & 0b0000111) << 7 | bytes[3] >> 1;
			battery = (bytes[3] & 0b0000001) << 9 | bytes[4] << 1 | bytes[5] >> 7;
			accelerometer_X = (bytes[5] & 0b01111110);
			accelerometer_Y = (bytes[5] & 0b0000001) << 5 | bytes[6] >> 3;
			accelerometer_Z = (bytes[6] & 0b0000111) << 3 | bytes[7] >> 5;
			height_1 = (bytes[7] & 0b0011111) << 7 | bytes[8] >> 1;
			return {"frameType":"status", "pression":pression, "humidity":humidity, "temperature":temperature, "battery":battery, "accelerometer_X":accelerometer_X, "accelerometer_Y":accelerometer_Y, "accelerometer_Z":accelerometer_Z, "height_1":height_1};
	}
}

#2

EDIT : Actually it wasn’t related to the size but lag because i was using a distant access to my servers.