+/**
+ * Output the contents of the specified buffer (in hex) with the specified priority level.
+ *
+ * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag - Module name
+ * @param buffer - pointer to buffer of bytes
+ * @param bufferSize - max number of byte in buffer
+ */
+void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize)
+{
+ if (!buffer || !tag || (bufferSize == 0))
+ {
+ return;
+ }
+
+ // No idea why the static initialization won't work here, it seems the compiler is convinced
+ // that this is a variable-sized object.
+ char lineBuffer[LINE_BUFFER_SIZE];
+ memset(lineBuffer, 0, sizeof lineBuffer);
+ int lineIndex = 0;
+ int i;
+ for (i = 0; i < bufferSize; i++)
+ {
+ // Format the buffer data into a line
+ snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
+ lineIndex++;
+ // Output 16 values per line
+ if (((i+1)%16) == 0)
+ {
+ OCLogv(level, tag, "%s", lineBuffer);
+ memset(lineBuffer, 0, sizeof lineBuffer);
+ lineIndex = 0;
+ }
+ }
+ // Output last values in the line, if any
+ if (bufferSize % 16)
+ {
+ OCLogv(level, tag, "%s", lineBuffer);
+ }
+}
+
+void OCPrintCALogBuffer(LogLevel level, const char *tag, const uint8_t *buffer,
+ uint16_t bufferSize, uint8_t isHeader)
+{
+ if (!buffer || !tag || (bufferSize == 0))
+ {
+ return;
+ }
+
+ // No idea why the static initialization won't work here, it seems the compiler is convinced
+ // that this is a variable-sized object.
+ char lineBuffer[S_LINE_BUFFER_SIZE];
+ int lineIndex = 0;
+ int i;
+ for (i = 0; i < bufferSize; i++)
+ {
+ // Format the buffer data into a line
+ snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
+ lineIndex++;
+ // Output 50 values per line
+ if (((i+1)%50) == 0)
+ {
+ if (1 == isHeader)
+ {
+ OCLogv(level, tag, "| Analyzer(Header) | %s", lineBuffer);
+ }
+ else
+ {
+ OCLogv(level, tag, "| Analyzer(Body) | %s", lineBuffer);
+ }
+ memset(lineBuffer, 0, sizeof lineBuffer);
+ lineIndex = 0;
+ }
+ }
+
+ if (bufferSize % 50)
+ {
+ if (1 == isHeader)
+ {
+ OCLogv(level, tag, "| Analyzer(Header) | %s", lineBuffer);
+ }
+ else
+ {
+ OCLogv(level, tag, "| Analyzer(Body) | %s", lineBuffer);
+ }
+ }
+}
+
+void OCSetLogLevel(LogLevel level, bool hidePrivateLogEntries)
+{
+ g_level = level;
+ g_hidePrivateLogEntries = hidePrivateLogEntries;
+}
+
+bool OCGetPrivateLogLevel()
+{
+ return g_hidePrivateLogEntries;
+}
+
+#ifndef __TIZEN__
+void OCLogConfig(oc_log_ctx_t *ctx)
+{