MFRC522 cannot work with Praticle.function() command

Hi Makers,
I am using RFID device with Particle Cloud service on Electron. I got some errors when I try with Sample code MFRC522_Dumpinfo.ino
I add command “Particle.function(“Alarm”, AlarmToggle);” with related standard code for this command such as AlarmToggle and my handler functions
The error syntax show

Line 1
../wiring/inc/spark_wiring_cloud.h:191:25: no matching function for call to 'CloudClass::_function(const char [6], String (*&)(String))'
Line 2
../wiring/inc/spark_wiring_cloud.h:191:25: invalid conversion from 'String (*)(String)' to 'int (*)(String)' [-fpermissive]

When I expand full error, it indicated

Processing  mfrc522_dumpinfo.ino
Checking library MFRC522...
Installing library MFRC522 0.1.4 to lib/MFRC522 ...
Library MFRC522 0.1.4 installed.
make -C ../modules/electron/user-part all
make[1]: Entering directory '/firmware/modules/electron/user-part'
make -C ../../../user 
make[2]: Entering directory '/firmware/user'
Building cpp file: src/mfrc522_dumpinfo.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-10-msrc/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=10 -DPLATFORM_NAME=electron -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD00A -DUSBD_PID_CDC=0xC00A -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=10 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=1.5.2 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../third_party/miniz/miniz -I../services/inc -I../third_party/nanopb/nanopb -I../communication/inc -I../hal/inc -I../hal/shared -I../hal/src/electron -I../hal/src/stm32f2xx -I../hal/src/stm32 -I../third_party/freertos/freertos/FreeRTOS/Source/include -I../third_party/freertos/freertos/FreeRTOS/Source/portable/GCC/ARM_CM3 -I../platform/shared/inc -I../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F2xx/CMSIS/Include -I../platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I../dynalib/inc -Isrc -I./libraries -Ilib/MFRC522/src -I. -MD -MP -MF ../build/target/user/platform-10-msrc/mfrc522_dumpinfo.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DSPARK_PLATFORM_NET=UBLOXSARA -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc  -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x8080000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=6 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,1512 -DMODULE_DEPENDENCY2=0,0,0 -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fno-rtti -fcheck-new -std=gnu++14 -c -o ../build/target/user/platform-10-msrc/mfrc522_dumpinfo.o src/mfrc522_dumpinfo.cpp
In file included from ../wiring/inc/spark_wiring.h:51:0,
                 from ./inc/application.h:42,
                 from ./inc/Particle.h:5,
                 from src/mfrc522_dumpinfo.cpp:1:
../wiring/inc/spark_wiring_cloud.h: In instantiation of 'static bool CloudClass::function(const T&, Types ...) [with T = char [6]; Types = {String (*)(String)}]':
mfrc522_dumpinfo.ino:87:43:   required from here
../wiring/inc/spark_wiring_cloud.h:191:25: error: no matching function for call to 'CloudClass::_function(const char [6], String (*&)(String))'
         return _function(name, args...);
                         ^
../wiring/inc/spark_wiring_cloud.h:194:17: note: candidate: static bool CloudClass::_function(const char*, int (*)(String)) <near match>
     static bool _function(const char *funcKey, user_function_int_str_t* func)
                 ^
../wiring/inc/spark_wiring_cloud.h:194:17: note:   conversion of argument 2 would be ill-formed:
../wiring/inc/spark_wiring_cloud.h:191:25: error: invalid conversion from 'String (*)(String)' to 'int (*)(String)' [-fpermissive]
         return _function(name, args...);
                         ^
../wiring/inc/spark_wiring_cloud.h:199:17: note: candidate: static bool CloudClass::_function(const char*, user_std_function_int_str_t, void*)
     static bool _function(const char *funcKey, user_std_function_int_str_t func, void* reserved=NULL)
                 ^
../wiring/inc/spark_wiring_cloud.h:199:17: note:   no known conversion for argument 2 from 'String (*)(String)' to 'user_std_function_int_str_t {aka std::function<int(String)>}'
../wiring/inc/spark_wiring_cloud.h:213:17: note: candidate: template<class T> static bool CloudClass::_function(const char*, int (T::*)(String), T*)
     static bool _function(const char *funcKey, int (T::*func)(String), T *instance) {
                 ^
../wiring/inc/spark_wiring_cloud.h:213:17: note:   template argument deduction/substitution failed:
../wiring/inc/spark_wiring_cloud.h:191:25: note:   mismatched types 'int (T::*)(String)' and 'String (*)(String)'
         return _function(name, args...);
                         ^
../build/module.mk:274: recipe for target '../build/target/user/platform-10-msrc/mfrc522_dumpinfo.o' failed
make[2]: *** [../build/target/user/platform-10-msrc/mfrc522_dumpinfo.o] Error 1
make[2]: Leaving directory '/firmware/user'
../../../build/recurse.mk:11: recipe for target 'user' failed
make[1]: *** [user] Error 2
make[1]: Leaving directory '/firmware/modules/electron/user-part'
../build/recurse.mk:11: recipe for target 'modules/electron/user-part' failed
make: *** [modules/electron/user-part] Error 2

May you figure the problem and share idea for solving the error?
Thanks you
Aooddy

You should show your code as well.
The reason is most likely hidden in what you only described verbally here

We prefer first hand insight over second hand tales :wink:

However, the reason for the error is that your function handler does not fit the signature Particle.function() requires.
It should be int fn(String) or int fn(const char*) but you have something like String fn(String).

Hi again
I found my fault ready. It comes form I modify variable type of AlarmToggle Function to be String. I read at Cloud function() reference. System allow to use integer variable only.
Thanks you for rapid reply for ScuffR

Cheers,
Aooddy

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.