Applying a quick fix for "prog_char is deprecated" warning
authorJoseph Morrow <joseph.l.morrow@intel.com>
Fri, 22 Aug 2014 21:43:36 +0000 (17:43 -0400)
committerJoseph Morrow <joseph.l.morrow@intel.com>
Fri, 22 Aug 2014 21:46:04 +0000 (17:46 -0400)
in Arduino. As 'prog_char' is completely removed in later
versions of avr-gcc/g++, people with Ubuntu 14.04 won't be
able to build Arduino out of the box because of this. This
commit clears up some warnings AND allows Ubuntu 14.04 to
build our stack for Arduino (However, the question as to
whether we should update our versions of Ubuntu and/or
Arduino are still up in the air.).

Majorly, this enables Shamit to keep moving along. He is
currently making sure all of our documentation for building
the stack for Arduino is up to par. He will also be seeing
how far our current stack will take us (i.e. will it work on
other embedded devices without any further mods?).

Change-Id: I9a079b7211082e3d3fd418dd5162aaa606a8fc04

csdk/logger/include/logger.h
csdk/logger/src/logger.c
csdk/logger/test/arduino/ArduinoLoggerTest.cpp
csdk/ocsocket/src/ocsocket_arduino.cpp
csdk/ocsocket/test/arduino/ocsocket_test.cpp
csdk/stack/samples/arduino/SimpleClientServer/ocserver/ocserver.cpp
csdk/stack/test/arduino/ArduinoStackTest.cpp

index 9ec0989..6009984 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
 // Use the PCF macro to wrap strings stored in FLASH on the Arduino
 // Example:  OC_LOG(INFO, TAG, PCF("Entering function"));
 #ifdef ARDUINO
-    #define PCF(str)  ((const prog_char*)(F(str)))
+    #define PCF(str)  ((PROGMEM const char *)(F(str)))
 #else
     #define PCF(str) str
 #endif
@@ -104,7 +104,7 @@ typedef enum {
      * @param tag    - Module name
      * @param logStr - log string
      */
-    void OCLog(LogLevel level, const prog_char * tag, const prog_char * logStr);
+    void OCLog(LogLevel level, PROGMEM const char * tag, PROGMEM const char * logStr);
 
     /**
      * Output the contents of the specified buffer (in hex) with the specified priority level.
@@ -114,7 +114,7 @@ typedef enum {
      * @param buffer     - pointer to buffer of bytes
      * @param bufferSize - max number of byte in buffer
      */
-    void OCLogBuffer(LogLevel level, const prog_char * tag, const uint8_t * buffer, uint16_t bufferSize);
+    void OCLogBuffer(LogLevel level, PROGMEM const char * tag, const uint8_t * buffer, uint16_t bufferSize);
 
     /**
      * Output a variable argument list log string with the specified priority level.
index a84411c..64d7064 100644 (file)
@@ -33,15 +33,15 @@ static const uint16_t LINE_BUFFER_SIZE = (16 * 2) + 16 + 1;  // Show 16 bytes, 2
 #elif defined ARDUINO
     #include <stdarg.h>
 
-    prog_char level0[] PROGMEM = "DEBUG";
-    prog_char level1[] PROGMEM = "INFO";
-    prog_char level2[] PROGMEM = "WARNING";
-    prog_char level3[] PROGMEM = "ERROR";
-    prog_char level4[] PROGMEM = "FATAL";
+    PROGMEM char level0[] = "DEBUG";
+    PROGMEM char level1[] = "INFO";
+    PROGMEM char level2[] = "WARNING";
+    PROGMEM char level3[] = "ERROR";
+    PROGMEM char level4[] = "FATAL";
 
-    PROGMEM const prog_char * LEVEL[]  = {level0, level1, level2, level3, level4};
+    PROGMEM const char * LEVEL[]  = {level0, level1, level2, level3, level4};
 
-    static void OCLogString(LogLevel level, const prog_char * tag, const char * logStr);
+    static void OCLogString(LogLevel level, PROGMEM const char * tag, PROGMEM const char * logStr);
 #endif
 
 
@@ -144,7 +144,7 @@ void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint1
      * @param tag    - Module name
      * @param logStr - log string
      */
-    void OCLogString(LogLevel level, const prog_char * tag, const char * logStr) {
+    void OCLogString(LogLevel level, PROGMEM const char * tag, const char * logStr) {
     #ifdef TB_LOG
         if (!logStr || !tag) {
           return;
@@ -174,7 +174,7 @@ void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint1
      * @param buffer     - pointer to buffer of bytes
      * @param bufferSize - max number of byte in buffer
      */
-    void OCLogBuffer(LogLevel level, const prog_char * tag, const uint8_t * buffer, uint16_t bufferSize) {
+    void OCLogBuffer(LogLevel level, PROGMEM const char * tag, const uint8_t * buffer, uint16_t bufferSize) {
     #ifdef TB_LOG
         if (!buffer || !tag || (bufferSize == 0)) {
             return;
@@ -207,7 +207,7 @@ void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint1
      * @param tag    - Module name
      * @param logStr - log string
      */
-    void OCLog(LogLevel level, const prog_char * tag, const prog_char * logStr) {
+    void OCLog(LogLevel level, PROGMEM const char * tag, PROGMEM const char * logStr) {
     #ifdef TB_LOG
         if (!logStr || !tag) {
           return;
@@ -241,7 +241,7 @@ void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint1
      * @param tag    - Module name
      * @param format - variadic log string
      */
-    void OCLogv(LogLevel level, const prog_char * tag, const char *format, ...)
+    void OCLogv(LogLevel level, PROGMEM const char * tag, const char * format, ...)
     {
     #ifdef TB_LOG
         char buffer[LINE_BUFFER_SIZE];
@@ -280,7 +280,7 @@ void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint1
      * @param tag    - Module name
      * @param format - variadic log string
      */
-    void OCLogv(LogLevel level, const prog_char * tag, const __FlashStringHelper *format, ...)
+    void OCLogv(LogLevel level, PROGMEM const char * tag, const __FlashStringHelper *format, ...)
     {
     #ifdef TB_LOG
         char buffer[LINE_BUFFER_SIZE];
index c7be7fe..f1f89ab 100644 (file)
 #include "ArduinoLoggerTest.h"
 #include "logger.h"
 
-const prog_char tag[] PROGMEM = "Arduino";
-const prog_char msg[] PROGMEM = "Arduino Logger Test";
+PROGMEM const char tag[] = "Arduino";
+PROGMEM const char msg[] = "Arduino Logger Test";
 
-const prog_char debugMsg[] PROGMEM = "this is a DEBUG message";
-const prog_char infoMsg[] PROGMEM = "this is a INFO message";
-const prog_char warningMsg[] PROGMEM = "this is a WARNING message";
-const prog_char errorMsg[] PROGMEM = "this is a ERROR message";
-const prog_char fatalMsg[] PROGMEM = "this is a FATAL message";
+PROGMEM const char debugMsg[] = "this is a DEBUG message";
+PROGMEM const char infoMsg[] = "this is a INFO message";
+PROGMEM const char warningMsg[] = "this is a WARNING message";
+PROGMEM const char errorMsg[] = "this is a ERROR message";
+PROGMEM const char fatalMsg[] = "this is a FATAL message";
 
-const prog_char multiLineMsg[] PROGMEM = "this is a DEBUG message\non multiple\nlines";
+PROGMEM const char multiLineMsg[] = "this is a DEBUG message\non multiple\nlines";
 
 
 //-----------------------------------------------------------------------------
index d280e23..0939dfb 100644 (file)
@@ -28,7 +28,7 @@
 #include <logger.h>
 
 /// Ensures the literal string to be stored in Flash memory
-#define PCF(str) ((const prog_char*)(F(str)))
+#define PCF(str) ((PROGMEM const char *)(F(str)))
 
 /// Module Name
 #define MOD_NAME PCF("ocsocket")
index 982526f..1271143 100644 (file)
@@ -80,7 +80,7 @@ unsigned char TEST_BUF[] = {
 };
 unsigned int TEST_BUF_LEN = sizeof(TEST_BUF);
 
-#define PCF(str) ((const prog_char*)(F(str)))
+#define PCF(str) ((PROGMEM const char *)(F(str)))
 
 #define MOD_NAME PCF("ocsocket_test")
 
index 5b23bc6..844af57 100644 (file)
@@ -19,9 +19,9 @@ extern "C" {
 
 const char *getResult(OCStackResult result);
 
-#define PCF(str) ((const prog_char*)(F(str)))
+#define PCF(str) ((PROGMEM const char *)(F(str)))
 
-const prog_char TAG[] PROGMEM = "ArduinoServer";
+PROGMEM const char TAG[] = "ArduinoServer";
 
 int gQuitFlag = 0;
 int gLEDUnderObservation = 0;
index 417a675..f17bed4 100644 (file)
 #include "ocstackinternal.h"
 #include <string.h>
 
-#define PCF(str) ((const prog_char*)(F(str)))
+#define PCF(str) ((PROGMEM const char *)(F(str)))
 
-const prog_char TAG[] PROGMEM = "Arduino";
+PROGMEM const char TAG[] = "Arduino";
 static OCUri SERVICE_URI = "coap://127.0.0.1:5683/";
 
 #if 0  // Turn off logger test stuff
-const prog_char tag[] PROGMEM = "Arduino";
-const prog_char msg[] PROGMEM = "Arduino Logger Test";
+PROGMEM const char tag[] = "Arduino";
+PROGMEM const char msg[] = "Arduino Logger Test";
 
-const prog_char debugMsg[] PROGMEM = "this is a DEBUG message";
-const prog_char infoMsg[] PROGMEM = "this is a INFO message";
-const prog_char warningMsg[] PROGMEM = "this is a WARNING message";
-const prog_char errorMsg[] PROGMEM = "this is a ERROR message";
-const prog_char fatalMsg[] PROGMEM = "this is a FATAL message";
+PROGMEM const char debugMsg[] = "this is a DEBUG message";
+PROGMEM const char infoMsg[] = "this is a INFO message";
+PROGMEM const char warningMsg[] = "this is a WARNING message";
+PROGMEM const char errorMsg[] = "this is a ERROR message";
+PROGMEM const char fatalMsg[] = "this is a FATAL message";
 
-const prog_char multiLineMsg[] PROGMEM = "this is a DEBUG message\non multiple\nlines";
+PROGMEM const char multiLineMsg[] = "this is a DEBUG message\non multiple\nlines";
 #endif
 
 void EXPECT_EQ(int a, int b)  {