Zgateway srfb (#143)
* compatibility with sonoff rf bridge #81 * update extract_char call
This commit is contained in:
1 parent
974d738212
commit
af5e4e8ec9
6 files changed
+356
-33
No files matched your search
+1
-20
@@ -83,7 +83,7 @@ boolean BTtoMQTT() {
|
||||
|
||||
for(int i =0; i<6;i++)
|
||||
{
|
||||
extract_char(token_char,d[i].extract,d[i].start, d[i].len ,d[i].reverse);
|
||||
extract_char(token_char,d[i].extract,d[i].start, d[i].len ,d[i].reverse, false);
|
||||
if (i == 3) d[5].len = (int)strtol(d[i].extract, NULL, 16) * 2; // extracting the length of the rest data
|
||||
}
|
||||
|
||||
@@ -162,25 +162,6 @@ boolean process_miflora_data(char * rest_data, char * mac_adress){
|
||||
return true;
|
||||
}
|
||||
|
||||
void revert_hex_data(char * in, char * out, int l){
|
||||
//reverting array 2 by 2 to get the data in good order
|
||||
int i = l-2 , j = 0;
|
||||
while ( i != -2 ) {
|
||||
if (i%2 == 0) out[j] = in[i+1];
|
||||
else out[j] = in[i-1];
|
||||
j++;
|
||||
i--;
|
||||
}
|
||||
out[l-1] = '\0';
|
||||
}
|
||||
|
||||
void extract_char(char * token_char, char * subset, int start ,int l, boolean reverse){
|
||||
char tmp_subset[l+1];
|
||||
memcpy( tmp_subset, &token_char[start], l );
|
||||
tmp_subset[l] = '\0';
|
||||
if (reverse) revert_hex_data(tmp_subset, subset, l+1);
|
||||
else strncpy( subset, tmp_subset , l+1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ZgatewayBT_stable
|
||||
|
||||
Reference in new issue
Block a user