I’ve installed Chirpstack V4 on an AWS cloud server and I’m trying to send uplink messages to Datacake. Since I wasn’t able to see the messages on datacake I was trying to identify where the problem was (I’m new both to Chirpstack and Datacake) and noticed that I was getting a message on the device Events list referring “Code: UPLINK_CODEC Level: ERROR” for each message received from the device.
I was using a decoder supplied by the device manufacturer (RAK10701), but since it is for V3 I’ve added a wrapper function to convert to the new format used on V4, this is the full decoder code:
// v3 to v4 compatibility wrapper
function decodeUplink_old(input) {
return {
data: Decode(input.fPort, input.bytes, input.variables)
};
}
function Decode(fPort, bytes, variables) {
var decoded = {};
// avoid sending Downlink ACK to integration (Cargo)
if ((fPort === 1) || (fPort === 2)){
var lonSign = (bytes[0] >> 7) & 0x01 ? -1 : 1;
var latSign = (bytes[0] >> 6) & 0x01 ? -1 : 1;
Any help or tip on this issue will be a great help, including how to be able to debug this problem, in all the other reports I’ve seen about an “Exception generated by quickjs” I always saw some additional detail about the error, here I’m not seeing any additional error information.
I had the same issues with my codec, i had to use chatgpt and provode the codec then the errors and read the sensor datasheet turns out something else in the code from milesight was the issue and i asked gpt to isolate and only work for modbus sensors it worked, had tocuse gpt4 over 3.5 for some reason was better with js
According to the description and the UPLINK_CODEC message, the error occurs inside the decoder when executing JavaScript code. The cause is most likely in this line:
javascript
decoded.error = “Need more GPS precision (hdop must be <” + maxHdop
" & sats must be >= " + minSats + “) current hdop: " + hdop + " & sats:” + sats;
There is a missing + operator between the lines. Try replacing it with:
javascript
decoded.error = “Need more GPS precision (hdop must be <” + maxHdop +
" & sats must be >= " + minSats + “) current hdop: " + hdop + " & sats:” + sats;
This omission causes a runtime error in the QuickJS engine, and Chirpstack logs it as Exception generated by quickjs.
It’s also useful to temporarily simplify the decoder - for example, to output only fPort and bytes to make sure that the code runs at all. And be sure to check that the correct { data: … } object or null is returned.
If you still have difficulties, try testing the decoder on a local machine or through an external online JavaScript editor to catch syntax errors faster.