void clarusSwParseCode(void) { int x = 0; int z = 65; char id[3] = {'\0'}; /* Convert the one's and zero's into binary */ for(x=0; x<clarus_switch->rawlen; x+=4) { if(clarus_switch->code[x+3] == 1) { clarus_switch->binary[x/4]=1; } else if(clarus_switch->code[x+0] == 1) { clarus_switch->binary[x/4]=2; } else { clarus_switch->binary[x/4]=0; } } for(x=9;x>=5;--x) { if(clarus_switch->binary[x] == 2) { break; } z++; } int unit = binToDecRev(clarus_switch->binary, 0, 5); int state = clarus_switch->binary[11]; int y = binToDecRev(clarus_switch->binary, 6, 9); sprintf(&id[0], "%c%d", z, y); clarusSwCreateMessage(id, unit, state); }
void arctechSwParseBinary(void) { int unit = binToDecRev(arctech_switch->binary, 28, 31); int state = arctech_switch->binary[27]; int all = arctech_switch->binary[26]; int id = binToDecRev(arctech_switch->binary, 0, 25); arctechSwCreateMessage(id, unit, state, all); }
void arctechDimParseBinary(void) { int dimlevel = binToDecRev(arctech_dimmer->binary, 32, 35); int unit = binToDecRev(arctech_dimmer->binary, 28, 31); int state = arctech_dimmer->binary[27]; int all = arctech_dimmer->binary[26]; int id = binToDecRev(arctech_dimmer->binary, 0, 25); arctechDimCreateMessage(id, unit, state, all, dimlevel); }
static void arctechContactParseBinary(void) { int unit = binToDecRev(arctech_contact->binary, 28, 31); int state = arctech_contact->binary[27]; int all = arctech_contact->binary[26]; int id = binToDecRev(arctech_contact->binary, 0, 25); arctechContactCreateMessage(id, unit, state, all); }
void homeEasyOldParseBinary(void) { int systemcode = 15-binToDecRev(home_easy_old->binary, 1, 4); int unitcode = 15-binToDecRev(home_easy_old->binary, 5, 8); int all = home_easy_old->binary[9]; int state = home_easy_old->binary[11]; int check = home_easy_old->binary[10]; if(check == 0) { homeEasyOldCreateMessage(systemcode, unitcode, state, all); } }
static void cleverwattsParseCode(void) { int i = 0, x = 0; int id = 0, state = 0, unit = 0, all = 0; for(i=1;i<cleverwatts->rawlen-1;i+=2) { cleverwatts->binary[x++] = cleverwatts->code[i]; } id = binToDecRev(cleverwatts->binary, 0, 19); state = cleverwatts->binary[20]; unit = binToDecRev(cleverwatts->binary, 21, 22); all = cleverwatts->binary[23]; cleverwattsCreateMessage(id, unit, state, all); }
static void x10ParseCode(void) { int x = 0; int y = 0; for(x=1;x<x10->rawlen-1;x+=2) { x10->binary[y++] = x10->code[x]; } char id[3]; int l = x10letters[binToDecRev(x10->binary, 0, 3)]; int s = x10->binary[18]; int i = 1; int c1 = (binToDec(x10->binary, 0, 7)+binToDec(x10->binary, 8, 15)); int c2 = (binToDec(x10->binary, 16, 23)+binToDec(x10->binary, 24, 31)); if(x10->binary[5] == 1) { i += 8; } if(x10->binary[17] == 1) { i += 4; } i += binToDec(x10->binary, 19, 20); if(c1 == 255 && c2 == 255) { sprintf(id, "%c%d", l, i); x10CreateMessage(id, s); } }
void alectoParseCode(void) { int i = 0, x = 0; int temperature; int id; for(i=1; i<alecto->rawlen-1; i+=2) { alecto->binary[x++] = alecto->code[i]; } id = binToDecRev(alecto->binary, 0, 11); temperature = binToDecRev(alecto->binary, 16, 27); alecto->message = json_mkobject(); json_append_member(alecto->message, "id", json_mknumber(id)); json_append_member(alecto->message, "temperature", json_mknumber(temperature)); }
static void parseCode(void) { int binary[RAW_LENGTH/2]; int temp1 = 0, temp2 = 0, temp3 = 0; int humi1 = 0, humi2 = 0; int id = 0, battery = 0; int channel = 0; int i = 0, x = 0; double humi_offset = 0.0, temp_offset = 0.0; double temperature = 0.0, humidity = 0.0; for(x=1;x<tfa->rawlen-2;x+=2) { if(tfa->raw[x] > AVG_PULSE_LENGTH*PULSE_MULTIPLIER) { binary[i++] = 1; } else { binary[i++] = 0; } } id = binToDecRev(binary, 2, 9); channel = binToDecRev(binary, 12, 13) + 1; temp1 = binToDecRev(binary, 14, 17); temp2 = binToDecRev(binary, 18, 21); temp3 = binToDecRev(binary, 22, 25); /* Convert F to C */ temperature = (int)((float)(((((temp3*256) + (temp2*16) + (temp1))*10) - 9000) - 3200) * ((float)5/(float)9)); humi1 = binToDecRev(binary, 26, 29); humi2 = binToDecRev(binary, 30, 33); humidity = ((humi1)+(humi2*16)); if(binToDecRev(binary, 34, 35) > 1) { battery = 0; } else { battery = 1; } struct settings_t *tmp = settings; while(tmp) { if(fabs(tmp->id-id) < EPSILON && fabs(tmp->channel-channel) < EPSILON) { humi_offset = tmp->humi; temp_offset = tmp->temp; break; } tmp = tmp->next; } temperature += temp_offset; humidity += humi_offset; tfa->message = json_mkobject(); json_append_member(tfa->message, "id", json_mknumber(id, 0)); json_append_member(tfa->message, "temperature", json_mknumber(temperature/100, 2)); json_append_member(tfa->message, "humidity", json_mknumber(humidity, 2)); json_append_member(tfa->message, "battery", json_mknumber(battery, 0)); json_append_member(tfa->message, "channel", json_mknumber(channel, 0)); }
static void parseCode(void) { int binary[RAW_LENGTH/2], x = 0, i = 0; int id = -1, state = -1, unit = -1, systemcode = -1; for(x=0;x<daycom->rawlen;x+=2) { if(daycom->raw[x] > AVG_PULSE_LENGTH*(PULSE_MULTIPLIER/2)) { binary[i++] = 1; } else { binary[i++] = 0; } } id = binToDecRev(binary, 0, 5); systemcode = binToDecRev(binary, 6, 19); unit = binToDecRev(binary, 21, 23 ); state = binary[20]; createMessage(id, systemcode, unit, state); }
static void parseCode(void) { int binary[RAW_LENGTH/4], x = 0, i = 0; for(x=0;x<arctech_switch->rawlen;x+=4) { if(arctech_switch->raw[x+3] > (int)((double)AVG_PULSE_LENGTH*((double)PULSE_MULTIPLIER/2))) { binary[i++] = 1; } else { binary[i++] = 0; } } int unit = binToDecRev(binary, 28, 31); int state = binary[27]; int all = binary[26]; int id = binToDecRev(binary, 0, 25); createMessage(id, unit, state, all, 0); }
void conradRSLCnParseCode(void) { int x = 0; /* Convert the one's and zero's into binary */ for(x=0; x<conrad_rsl_contact->rawlen; x+=2) { if(conrad_rsl_contact->code[x+1] == 1) { conrad_rsl_contact->binary[x/2]=1; } else { conrad_rsl_contact->binary[x/2]=0; } } int id = binToDecRev(conrad_rsl_contact->binary, 6, 31); int check = binToDecRev(conrad_rsl_contact->binary, 0, 3); int check1 = conrad_rsl_contact->binary[32]; int state = conrad_rsl_contact->binary[4]; if(check == 5 && check1 == 1) { conradRSLCnCreateMessage(id, state); } }
static void quiggGT7000ParseCode(void) { int x = 0, dec_unit[4] = {0, 3, 1, 2}; int iParity=1, iParityData=-1; // init for even parity for(x=0; x<quigg_gt7000->rawlen-1; x+=2) { if(quigg_gt7000->raw[x+1] > PULSE_QUIGG_50) { quigg_gt7000->binary[x/2] = 1; if((x / 2) > 11 && (x / 2) < 19) { iParityData = iParity; iParity = -iParity; } } else { quigg_gt7000->binary[x/2] = 0; } } if(iParityData < 0) iParityData=0; int id = binToDecRev(quigg_gt7000->binary, 0, 11); int unit = binToDecRev(quigg_gt7000->binary, 12, 13); int all = binToDecRev(quigg_gt7000->binary, 14, 14); int state = binToDecRev(quigg_gt7000->binary, 15, 15); int dimm = binToDecRev(quigg_gt7000->binary, 16, 16); int parity = binToDecRev(quigg_gt7000->binary, 19, 19); unit = dec_unit[unit]; if((dimm == 1) && (state == 1)) dimm = 2; if (iParityData == parity && dimm < 1) { quiggGT7000CreateMessage(id, state, unit, all); } }
void threechanParseCode(void) { int i = 0, x = 0; int temperature; int id; int humidity; int battery; for(i=1;i<threechan->rawlen-1;i+=2) { threechan->binary[x++] = threechan->code[i]; } id = binToDecRev(threechan->binary, 0, 11); battery = threechan->binary[12]; temperature = binToDecRev(threechan->binary, 18, 27); humidity = binToDecRev(threechan->binary, 28, 35); threechan->message = json_mkobject(); json_append_member(threechan->message, "id", json_mknumber(id)); json_append_member(threechan->message, "temperature", json_mknumber(temperature)); json_append_member(threechan->message, "humidity", json_mknumber(humidity*10)); json_append_member(threechan->message, "battery", json_mknumber(battery)); }
static void parseCode(void) { int i = 0, x = 0, y = 0, binary[RAW_LENGTH/2]; int id = -1, state = -1, unit = -1, all = 0, code = 0; if(beamish_switch->rawlen>RAW_LENGTH) { logprintf(LOG_ERR, "beamish_switch: parsecode - invalid parameter passed %d", beamish_switch->rawlen); return; } for(x=0;x<beamish_switch->rawlen;x+=2) { if(beamish_switch->raw[x] > (int)((double)AVG_PULSE_LENGTH*((double)PULSE_MULTIPLIER/2))) { binary[i++] = 1; } else { binary[i++] = 0; } } id = binToDecRev(binary, 0, 15); code = binToDecRev(binary, 16, 23); for(y=0;y<7;y++) { if(map[y] == code) { unit = y; break; } } if(unit == 5) { state = 1; all = 1; } if(unit == 6) { state = 0; all = 1; } createMessage(id, unit, state, all); }
static void parseCode(void) { int binary[RAW_LENGTH/4], x = 0, i = 0; if(arctech_switch->rawlen>RAW_LENGTH) { logprintf(LOG_ERR, "arctech_switch: parsecode - invalid parameter passed %d", arctech_switch->rawlen); return; } for(x=0;x<arctech_switch->rawlen;x+=4) { if(arctech_switch->raw[x+3] > (int)((double)AVG_PULSE_LENGTH*((double)PULSE_MULTIPLIER/2))) { binary[i++] = 1; } else { binary[i++] = 0; } } int unit = binToDecRev(binary, 28, 31); int state = binary[27]; int all = binary[26]; int id = binToDecRev(binary, 0, 25); createMessage(id, unit, state, all, 0); }
static void parseCode(void) { int x = 0, pRaw = 0, binary[RAW_LENGTH/2]; int iParity = 1, iParityData = -1; // init for even parity int iHeaderSync = 12; // 1100 int iDataSync = 6; // 110 double temp_offset = 0.0; double humi_offset = 0.0; // Decode Biphase Mark Coded Differential Manchester (BMCDM) pulse stream into binary for(x=0; x<=(RAW_LENGTH/2); x++) { if(ninjablocks_weather->raw[pRaw] > PULSE_NINJA_WEATHER_LOWER && ninjablocks_weather->raw[pRaw] < PULSE_NINJA_WEATHER_UPPER) { binary[x] = 1; iParityData = iParity; iParity = -iParity; pRaw++; } else { binary[x] = 0; } pRaw++; } if(iParityData < 0) { iParityData = 0; } // Binary record: 0-3 sync0, 4-7 unit, 8-9 id, 10-12 sync1, 13-19 humidity, 20-34 temperature, 35 even par, 36 footer int headerSync = binToDecRev(binary, 0,3); int unit = binToDecRev(binary, 4,7); int id = binToDecRev(binary, 8,9); int dataSync = binToDecRev(binary, 10,12); double humidity = binToDecRev(binary, 13,19); // % double temperature = binToDecRev(binary, 20,34); // ((temp * (100 / 128)) - 5000) * 10 °C, 2 digits temperature = ((int)((double)(temperature * 0.78125)) - 5000); struct settings_t *tmp = settings; while(tmp) { if(fabs(tmp->id-id) < EPSILON && fabs(tmp->unit-unit) < EPSILON) { humi_offset = tmp->humi; temp_offset = tmp->temp; break; } tmp = tmp->next; } temperature += temp_offset; humidity += humi_offset; if(iParityData == 0 && (iHeaderSync == headerSync || dataSync == iDataSync)) { createMessage(id, unit, temperature, humidity); } }
static void parseCode(void) { int binary[RAW_LENGTH/2], x = 0, dec_unit[4] = {0, 3, 1, 2}; int iParity=1, iParityData=-1; // init for even parity if(quigg_gt7000->rawlen>RAW_LENGTH) { logprintf(LOG_ERR, "quigg_gt7000: parsecode - invalid parameter passed %d", quigg_gt7000->rawlen); return; } for(x=0; x<quigg_gt7000->rawlen-1; x+=2) { if(quigg_gt7000->raw[x+1] > PULSE_QUIGG_50) { binary[x/2] = 1; if((x / 2) > 11 && (x / 2) < 19) { iParityData = iParity; iParity = -iParity; } } else { binary[x/2] = 0; } } if(iParityData < 0) iParityData=0; int id = binToDecRev(binary, 0, 11); int unit = binToDecRev(binary, 12, 13); int all = binToDecRev(binary, 14, 14); int state = binToDecRev(binary, 15, 15); int dimm = binToDecRev(binary, 16, 16); int parity = binToDecRev(binary, 19, 19); int learn = 0; unit = dec_unit[unit]; if((dimm == 1) && (state == 1)) { dimm = 2; } if (iParityData == parity && dimm < 1) { createMessage(id, state, unit, all, learn); } }
static void parseCode(void) { int i = 0, x = 0, type = 0, id = 0, binary[MAX_RAW_LENGTH/2]; double temp_offset = 0.0, humi_offset = 0.0; double humidity = 0.0, temperature = 0.0; int n0 = 0, n1 = 0, n2 = 0, n3 = 0, n3b = 0; int n4 = 0, n5 = 0, n6 = 0, n7 = 0, n8 = 0; int n9 = 0, n10 = 0; int y = 0; int checksum = 1; if(tfa30->rawlen>MAX_RAW_LENGTH) { logprintf(LOG_ERR, "tfa30: parsecode - invalid parameter passed %d", tfa30->rawlen); return; } if(tfa30->rawlen == 80) { // create first nibble for raw length 80 for(y=0;y<4;y+=1) { binary[i++] = 0; } } for(x=0;x<tfa30->rawlen;x+=2) { if(tfa30->raw[x] > AVG_PULSE) { binary[i++] = 0; } else { binary[i++] = 1; } } n10=binToDecRev(binary, 40, 43); n9=binToDecRev(binary, 36, 39); n8=binToDecRev(binary, 32, 35); n7=binToDecRev(binary, 28, 31); n6=binToDecRev(binary, 24, 27); n5=binToDecRev(binary, 20, 23); n4=binToDecRev(binary, 16, 19); n3b=binToDecRev(binary, 12, 18); n3=binToDecRev(binary, 12, 15); n2=binToDecRev(binary, 8, 11); n1=binToDecRev(binary, 4, 7); n0=binToDecRev(binary, 0, 3); id = n3b; struct settings_t *tmp = settings; while(tmp) { if(fabs(tmp->id-id) < EPSILON){ humi_offset = tmp->humi; temp_offset = tmp->temp; break; } tmp = tmp->next; } // Temp if((n1 == 0xa) & (n2 == 0x0)) { type = 0x1; checksum = (n0+n1+n2+n3+n4+n5+n6+n7+n8+n9) & 0xf; if(n10 != checksum) { type=0x5; return; } // Hum } else if((n1 == 0xa) & (n2 == 0xe)) { type = 0x2; checksum = (n0+n1+n2+n3+n4+n5+n6+n7+n8+n9) & 0xf; if(n10 != checksum){ type=0x5; return; } // nothing valid } else { type = 0x5; return; } tfa30->message = json_mkobject(); switch(type) { case 1: temperature = (double)(n5-5)*10 + n6 + n7/10.0; temperature += temp_offset; json_append_member(tfa30->message, "id", json_mknumber(id, 0)); json_append_member(tfa30->message, "temperature", json_mknumber(temperature, 1)); break; case 2: humidity = (double)(n5)*10 + n6; humidity += humi_offset; json_append_member(tfa30->message, "id", json_mknumber(id, 0)); json_append_member(tfa30->message, "humidity", json_mknumber(humidity, 1)); break; default: json_delete(tfa30->message); tfa30->message = NULL; return; break; } }