Version FC

Dependencies:   DmTftLibrary eeprom SX1280Lib filesystem mbed

Fork of MSNV2-Terminal_V1-5 by Francis CHATAIN

util.cpp

Committer:
FCH_31
Date:
2018-08-22
Revision:
8:cd489b7c49a0
Child:
12:e9ec35413787

File content as of revision 8:cd489b7c49a0:

/*
 * MISNet   
 *
 *  Util:   Utilities
 *
 *  Created on: August 17, 2018       Author: Francis CHATAIN
 *
 */

#include "mbed.h"
#include <string>

// Convert a byte to string
string binToString (unsigned char *inputData, int dataLength)
{
    char asciiString[dataLength*2 +1];   // 2 characters per byte plus a null at the end.
    for (int i = 0; i<dataLength; i++)    sprintf (asciiString+2*i,"%02X",*(inputData+i)) ;
    asciiString[dataLength*2] = 0 ;      // in theory redundant, the last sprintf should have done this but just to be sure...
    return string (asciiString) ;
}

void        printBytes ( unsigned char *buf, size_t len) 
{ 
    int i; 
    for (i = 0; i < len; i++) 
        printf("%02x", buf[i]); printf("\n"); 
}