Closed HaViGit closed 1 year ago
Hello
I see two straightforward ways to do this. The good one depends on how "clean" you want the result to be.
1) The quick-and-dirty way Simply locate the file RF433any.cpp (this depends on your OS, environment...) and update the line number 588. From: snprintf(tmp, sizeof(tmp), "%02x", get_nth_byte(i)); To: snprintf(tmp, sizeof(tmp), "%02X", get_nth_byte(i));
Doing it "like this" is a bit ugly, as you update library code and such an update won't survive a lib re-install, update etc. But it is straightforward, one unique character is updated!
2) The correct way (without updating lib)
You have to re-write the to_str() method. For example add the code below to the file 02_output-received-code.ino:
char* my_BitVector_to_str(const BitVector *bv) {
if (!bv->get_nb_bits())
return nullptr;
byte nb_bytes = bv->get_nb_bytes();
char *ret = (char*)malloc(nb_bytes * 3);
char tmp[3];
int j = 0;
for (int i = nb_bytes - 1; i >= 0 ; --i) {
snprintf(tmp, sizeof(tmp), "%02X", bv->get_nth_byte(i));
ret[j] = tmp[0];
ret[j + 1] = tmp[1];
ret[j + 2] = (i > 0 ? ' ' : '\0');
j += 3;
}
return ret;
}
And then later in the file, you replace the line: char buf = pdec->get_pdata()->to_str(); with the line: char buf = my_BitVector_to_str(pdec->get_pdata());
I've attached the resulting file to this post, 02_output-received-code_updt.ino, in a zip. file.zip
Hope it helps,
Reg, Seb
Hi Seb,
Thank you so much for your detailed response, I appreciate it and I'm going to use the neat solution. In my house I use a lot of 433 mHz transmitters (with Tasmota, Home Assistant and NodeRED) and I am building an RF-Sniffer as a tool to test and install. Your software is very suitable for this.
Best regards,
Hans.
First of all thanks for sharing this library, it works fine. Still a question, I'm using the 02_output-received-code sketch and would like to display the received code in uppercase like 2A CB 91. Can you help me with that?