Extract hexDump function
This commit is contained in:
		
							
								
								
									
										23
									
								
								src/util.h
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/util.h
									
									
									
									
									
								
							@@ -246,6 +246,19 @@ enum class ExtendedChar {
 | 
				
			|||||||
    GreekSmallLetterPhi = 0xed,
 | 
					    GreekSmallLetterPhi = 0xed,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					String hexDump(String in) {
 | 
				
			||||||
 | 
					    String out;
 | 
				
			||||||
 | 
					    for (size_t i = 0; i < in.length(); ++i) {
 | 
				
			||||||
 | 
					        auto hexChar = String(in[i], HEX);
 | 
				
			||||||
 | 
					        if (hexChar.length() == 1) {
 | 
				
			||||||
 | 
					            out.concat('0');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        out.concat(hexChar);
 | 
				
			||||||
 | 
					        out.concat(' ');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return out;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Message syntax:
 | 
					 * Message syntax:
 | 
				
			||||||
 * separator: ~
 | 
					 * separator: ~
 | 
				
			||||||
@@ -299,13 +312,5 @@ void sendTextToSign(
 | 
				
			|||||||
    Serial1.print(toSend);
 | 
					    Serial1.print(toSend);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Serial.println("Text sent to device: " + toSend);
 | 
					    Serial.println("Text sent to device: " + toSend);
 | 
				
			||||||
    Serial.print("Hex dump: ");
 | 
					    Serial.println("Hex dump: " + hexDump(toSend));
 | 
				
			||||||
    for (size_t i = 0; i < toSend.length(); ++i) {
 | 
					 | 
				
			||||||
        auto hexChar = String(toSend[i], HEX);
 | 
					 | 
				
			||||||
        if (hexChar.length() == 1) {
 | 
					 | 
				
			||||||
            hexChar = '0' + hexChar;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        Serial.print(hexChar + ' ');
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    Serial.println();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user