We are a Commercial Internet of Things installer based in Cornwall UK and need assistance with very small amounts of Javascript coding. The "payload" decoder below is what we already have:
/*
simple payload decoder.
*/
var TYPE_VDD = 0x07; //VDD 2byte 0-65535mV
var TYPE_PULSE1 = 0x0A; //2bytes relative pulse count
var TYPE_PULSE1_ABS = 0x0B; //4bytes no 0->0xFFFFFFFF
var TYPE_EXT_TEMP1 = 0x0C; //2bytes -3276.5C-->3276.5C
var TYPE_EXT_DIGITAL = 0x0D; //1bytes value 1 or 0
var TYPE_EXT_DISTANCE = 0x0E; //2bytes distance in mm
var TYPE_EXT_DIGITAL2 = 0x1A; // 1bytes value 1 or 0
var TYPE_DEBUG = 0x3D; // 4bytes debug
function bin16dec(bin) {
var num=bin&0xFFFF;
if (0x8000 & num)
num = - (0x010000 - num);
return num;
}
function bin8dec(bin) {
var num=bin&0xFF;
if (0x80 & num)
num = - (0x0100 - num);
return num;
}
function hexToBytes(hex) {
for (var bytes = [], c = 0; c < [login to view URL]; c += 2)
[login to view URL](parseInt([login to view URL](c, 2), 16));
return bytes;
}
function DecodePayload(data){
var obj = new Object();
for(i=0;i<[login to view URL];i++){
//[login to view URL](data[i]);
switch(data[i]){
case TYPE_VDD: //Battery level
obj.vdd=(data[i+1]<<8)|(data[i+2]);
i+=2;
break
case TYPE_PULSE1: //Pulse input 1
var pulse1=(data[i+1]<<8)|(data[i+2]);
var pulse1adjusted=pulse1*10;
obj.pulse1=pulse1;
obj.pulse1adjusted=pulse1adjusted;
i+=2;
break
case TYPE_PULSE1_ABS: //Pulse input 1 absolute value
var pulseAbs=(data[i+1]<<24)|(data[i+2]<<16)|(data[i+3]<<8)|(data[i+4]);
obj.pulseAbs=pulseAbs;
i+=4;
break
case TYPE_EXT_TEMP1: //External temp
var temp=(data[i+1]<<8)|(data[i+2]);
temp=bin16dec(temp);
obj.externalTemperature=temp/10;
i+=2;
break
case TYPE_EXT_DIGITAL: //Digital input
obj.digital=(data[i+1]);
i+=1;
break
case TYPE_EXT_DISTANCE: //Distance sensor input
var distance1=(data[i+1]<<8)|(data[i+2]);
obj.distance=distance1;
i+=2;
break
case TYPE_EXT_DIGITAL2: //Digital input 2
obj.digital2=(data[i+1]);
i+=1;
break
default: //somthing is wrong with data
i=[login to view URL];
break
}
}
return obj;
}
function Decoder(bytes, port) {
if (bytes[0] === 0x3e) {
return {};
}
return DecodePayload(bytes);
}
The code above decodes a payload from one of our sensors. We need to ignore decoded values for " var distance1" above 4000 as these are errors. We can describe in more greater detail but essentially with the right person (with the experience and knowledge of Javascript) it may be an hours work!
As we build our range of sensors and applications we will need increasing amounts of coding support
Hello my name is Chris. I am a js developer with extensive knowledge of development flows and good customer satisfaction. I can have your project ready within 24 hours
With strong Javascript knowledge I can write the code similar to the description you provide with all the rules , I am ready to start now and we can talk more about in chat . Let's talk over in chat and discuss there
Greetings boss,
We will be more than happy to help you because we are professionals with more than 5YEARS experience. ✓What matters most to us are; your trust, perfect functionality of your project, time uniformity and quick delivery.
✓We work in assemblage of professional computer science graduates under Shaunlee Global Circle Limited, we have several skills and expertise.
✓We can definitely give the best of your project.
Kindly HIRE US and you will never regret hiring us.
Hi There,
Hope you are doing well.
Just reviewed your job description and READY to START immediately.
Being a professional developer am sure that can do this project efficiently and on time.
If you would like, I can show you my previous work.
I can work full time in your time zone and start the work right now.
If you hire me, I will deliver you good result.
Waiting for your kind & positive reply and looking forward to work with you.
Thanks
Can you describe in more details. I need to know where you are initializing your threshold value. Please come over the chat. I will fix it in an hour if I get the or understand it. I have 5 years of experience with js.