STM32-Arduino icon indicating copy to clipboard operation
STM32-Arduino copied to clipboard

MDNS in Particle Build does not feature `setService()`

Open ScruffR opened this issue 9 years ago • 6 comments

When using Particle Build to flash this sample to the Duo, you'll get a "file not found" message for #include "MDNS.h". For Particle Build you'd need to import the MDNS library and the include statement would then be #include "MDNS/MDNS.h"

But then you'll get another error message "'class MDNS' has no member called 'setService'". Changing this to addService(...) the sketch builds.

ScruffR avatar Apr 23 '16 15:04 ScruffR

Hi @ScruffR, since that sample is created for Arduino, you need to add related libraries to Particle Build manually, so the path where you put the library to may differ from Arduino and the header file search scheme may differ from Particle Build as well, which will definitely lead to the error "file not found". So you need to specify the header file path if the header file is not located in the same path as application.ino.

And in the latest release, the addService(...) has been replaced with setService(...). See:
https://github.com/redbear/STM32-Arduino/blob/master/arduino/libraries/RedBear_Duo/src/MDNS.h#L49

Please have it a try again on Particle Build when firmware v0.2.4 is available.

Kind regards.

XuGuohui avatar May 26 '16 07:05 XuGuohui

hi @ScruffR : Our MDNS library is base on here.But we changed a little bit code of it ,so you can try v1.1.1.

JacksonLv avatar May 26 '16 07:05 JacksonLv

Thanks for the update, but I just tried that and now I can't even build the sample with the workarounds outlined in my OP. (I know this repo is mainly targeting Arduino IDE, but the #if defined(ARDUINO) ... #else ... suggested to me it should also work with Build)

How would I build that demo in Particle Build now? This is what I get with this commit of the demo and these minor alterations which account for the offset in line numbers

#if defined(ARDUINO) 
SYSTEM_MODE(MANUAL);//do not connect to cloud
#include "MDNS.h"
#else
#pragma SPARK_NO_PREPROCESSOR
#include "Particle.h"
SYSTEM_MODE(AUTOMATIC);//connect to cloud
// MDNS needs to be imported from Particle Build Library repository
#include "MDNS/MDNS.h"
#endif

Errors:

duo_webserver.cpp:47:36: error: 'BLE_APPEARANCE_UNKNOWN' was not declared in this scope
 #define BLE_PERIPHERAL_APPEARANCE  BLE_APPEARANCE_UNKNOWN
                                    ^

duo_webserver.cpp:62:12: note: in expansion of macro 'BLE_PERIPHERAL_APPEARANCE'
   LOW_BYTE(BLE_PERIPHERAL_APPEARANCE), HIGH_BYTE(BLE_PERIPHERAL_APPEARANCE) 
            ^
duo_webserver.cpp:62:37: error: 'LOW_BYTE' was not declared in this scope
   LOW_BYTE(BLE_PERIPHERAL_APPEARANCE), HIGH_BYTE(BLE_PERIPHERAL_APPEARANCE) 
                                     ^
duo_webserver.cpp:47:36: error: 'BLE_APPEARANCE_UNKNOWN' was not declared in this scope
 #define BLE_PERIPHERAL_APPEARANCE  BLE_APPEARANCE_UNKNOWN
                                    ^
duo_webserver.cpp:62:50: note: in expansion of macro 'BLE_PERIPHERAL_APPEARANCE'
   LOW_BYTE(BLE_PERIPHERAL_APPEARANCE), HIGH_BYTE(BLE_PERIPHERAL_APPEARANCE) 
                                                  ^
duo_webserver.cpp:62:75: error: 'HIGH_BYTE' was not declared in this scope
   LOW_BYTE(BLE_PERIPHERAL_APPEARANCE), HIGH_BYTE(BLE_PERIPHERAL_APPEARANCE) 
                                                                           ^

duo_webserver.cpp:70:29: error: 'LOW_BYTE' was not declared in this scope
   LOW_BYTE(MIN_CONN_INTERVAL), HIGH_BYTE(MIN_CONN_INTERVAL), 
                             ^

duo_webserver.cpp:70:59: error: 'HIGH_BYTE' was not declared in this scope
   LOW_BYTE(MIN_CONN_INTERVAL), HIGH_BYTE(MIN_CONN_INTERVAL), 
                                                           ^

duo_webserver.cpp:71:29: error: 'LOW_BYTE' was not declared in this scope
   LOW_BYTE(MAX_CONN_INTERVAL), HIGH_BYTE(MAX_CONN_INTERVAL), 
                             ^

duo_webserver.cpp:71:59: error: 'HIGH_BYTE' was not declared in this scope
   LOW_BYTE(MAX_CONN_INTERVAL), HIGH_BYTE(MAX_CONN_INTERVAL), 
                                                           ^

duo_webserver.cpp:72:25: error: 'LOW_BYTE' was not declared in this scope
   LOW_BYTE(SLAVE_LATENCY), HIGH_BYTE(SLAVE_LATENCY), 
                         ^

duo_webserver.cpp:72:51: error: 'HIGH_BYTE' was not declared in this scope
   LOW_BYTE(SLAVE_LATENCY), HIGH_BYTE(SLAVE_LATENCY), 
                                                   ^

duo_webserver.cpp:73:36: error: 'LOW_BYTE' was not declared in this scope
   LOW_BYTE(CONN_SUPERVISION_TIMEOUT), HIGH_BYTE(CONN_SUPERVISION_TIMEOUT)
                                    ^

duo_webserver.cpp:73:73: error: 'HIGH_BYTE' was not declared in this scope
   LOW_BYTE(CONN_SUPERVISION_TIMEOUT), HIGH_BYTE(CONN_SUPERVISION_TIMEOUT)
                                                                         ^

duo_webserver.cpp:105:20: error: 'BLE_GAP_ADV_TYPE_ADV_IND' was not declared in this scope
   .adv_type      = BLE_GAP_ADV_TYPE_ADV_IND,
                    ^

duo_webserver.cpp:106:20: error: 'BLE_GAP_ADDR_TYPE_PUBLIC' was not declared in this scope
   .dir_addr_type = BLE_GAP_ADDR_TYPE_PUBLIC,
                    ^

duo_webserver.cpp:108:20: error: 'BLE_GAP_ADV_CHANNEL_MAP_ALL' was not declared in this scope
   .channel_map   = BLE_GAP_ADV_CHANNEL_MAP_ALL,
                    ^

duo_webserver.cpp:109:20: error: 'BLE_GAP_ADV_FP_ANY' was not declared in this scope
   .filter_policy = BLE_GAP_ADV_FP_ANY
                    ^

duo_webserver.cpp:115:3: error: 'BLE_GAP_AD_TYPE_FLAGS' was not declared in this scope
   BLE_GAP_AD_TYPE_FLAGS,
   ^

duo_webserver.cpp:116:3: error: 'BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE' was not declared in this scope
   BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE,
   ^

duo_webserver.cpp:119:3: error: 'BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE' was not declared in this scope
   BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE,
   ^

duo_webserver.cpp:126:3: error: 'BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME' was not declared in this scope
   BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME,
   ^

duo_webserver.cpp: In function 'void mdns_init()':
duo_webserver.cpp:173:9: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:313): Spark is now Particle. [-Wdeprecated-declarations]
         Spark.publish("mdns/setup", "success");
         ^
duo_webserver.cpp:180:3: warning: 'Spark' is deprecated (declared at ../wiring/inc/spark_wiring_cloud.h:313): Spark is now Particle. [-Wdeprecated-declarations]
   Spark.publish("mdns/setup", "error");
   ^
duo_webserver.cpp: In function 'void setup()':
duo_webserver.cpp:312:18: error: 'BLE_UUID_GAP' was not declared in this scope
   ble.addService(BLE_UUID_GAP);
                  ^

duo_webserver.cpp:313:25: error: 'BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME' was not declared in this scope
   ble.addCharacteristic(BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME, ATT_PROPERTY_READ|ATT_PROPERTY_WRITE, (uint8_t*)BLE_DEVICE_NAME, sizeof(BLE_DEVICE_NAME));
                         ^

duo_webserver.cpp:314:25: error: 'BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE' was not declared in this scope
   ble.addCharacteristic(BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE, ATT_PROPERTY_READ, appearance, sizeof(appearance));
                         ^

duo_webserver.cpp:315:25: error: 'BLE_UUID_GAP_CHARACTERISTIC_PPCP' was not declared in this scope
   ble.addCharacteristic(BLE_UUID_GAP_CHARACTERISTIC_PPCP, ATT_PROPERTY_READ, conn_param, sizeof(conn_param));
                         ^

duo_webserver.cpp:318:18: error: 'BLE_UUID_GATT' was not declared in this scope
   ble.addService(BLE_UUID_GATT);
                  ^

duo_webserver.cpp:319:25: error: 'BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED' was not declared in this scope
   ble.addCharacteristic(BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED, ATT_PROPERTY_INDICATE, change, sizeof(change));
                         ^

duo_webserver.cpp:326:7: error: 'class BLEDevice' has no member named 'setAdvertisementParams'
   ble.setAdvertisementParams(&adv_params);
       ^

duo_webserver.cpp:329:7: error: 'class BLEDevice' has no member named 'setAdvertisementData'
   ble.setAdvertisementData(sizeof(adv_data), adv_data);
       ^

duo_webserver.cpp:330:7: error: 'class BLEDevice' has no member named 'setScanResponseData'
   ble.setScanResponseData(sizeof(scan_response), scan_response);
       ^

duo_webserver.cpp: In function 'void loop()':
duo_webserver.cpp:380:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
         if (endsWith(buffer, "GET /H")) {
                                      ^
duo_webserver.cpp:383:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
         if (endsWith(buffer, "GET /L")) {
                                      ^
make[1]: *** [../build/target/user/platform-88duo_webserver.o] Error 1
make: *** [user] Error 2

Maybe it would be good to have a contributed "library" on Particle Build that allows users there to just pick a sample which builds out the box (or with explicit build messages to actively import required third party libraries if not bundled).

Or at least dedicate a repo (or subfolder in this repo) for Particle users which bundles the required files to manually add to Build in order to successfully build any sample - unless there already is and I just can't find it.

ScruffR avatar May 26 '16 08:05 ScruffR

You can not compile the example on Particle Build now, as the build farm hasn't been updated before v0.2.4 is available. We manage to release firmware v0.2.4 this week, but it still takes a bit short time to make it available on Particle Build.

Maybe it would be good to have a contributed "library" on Particle Build that allows users there to just pick a sample which builds out the box (or with explicit build messages to actively import required third party libraries if not bundled).

That's what we exactly want to do, while we have limit time and resources to contribute the libraries. But I think it'll come to developers sooner or later and any contribution from developers would be really appreciated.

Thanks!

XuGuohui avatar May 26 '16 08:05 XuGuohui

Hi @ScruffR ,

You can now build applications for Duo firmware v0.2.4 on Particle Build!

Cheers!

XuGuohui avatar May 27 '16 17:05 XuGuohui

I'll give it a try Thanks!

ScruffR avatar May 27 '16 20:05 ScruffR