Include error local compile Photon

Hi All,

I am having a problem making a system level function available to my user code

I have a very simple snippet

/* myapp.cpp */

#include "application.h"
#include "wifitester.h"
#include "string_convert.h"
#include "dct.h"

void setConfigureSSID();

SYSTEM_MODE(MANUAL);

void setup()
   {
   setConfigureSSID();
   }


void setConfigureSSID()
   {
   const uint8_t* prefix = (const uint8_t*)dct_read_app_data(DCT_SSID_PREFIX_OFFSET);

   if (prefix[0] != 'Z') 
      {
      dct_write_app_data("ZZZ", DCT_SSID_PREFIX_OFFSET, 4);
      }
   }
void loop()
   {
   }

when I compile with

make clean all PLATFORM=photon APP=photon program-dfu

I get the following error

C:\Users\LONDON~1\AppData\Local\Temp\ccBy2XKj.ltrans0.ltrans.o: In function `setConfigureSSID':
C:\spark\firmware\modules\photon\user-part/applications/photon/myapp.cpp:27: undefined reference to `dct_read_app_data'
C:\spark\firmware\modules\photon\user-part/applications/photon/myapp.cpp:31: undefined reference to `dct_write_app_data'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [../../../build/target/user-part/platform-6-m-lto/applications/photon/photon.elf] Error 1
make: *** [modules/photon/user-part] Error 2

Both dct_read_app_data and dct_write_app_data are defined in dct.h but adding that header is not adequate to be able to use these functions. What am I doing wrong?

@HardWater any reason why you want to write to the DCT directly?

For branding purposes we would like to have the SSID show as our company name.

Do you have any idea what needs to be done to get this to compile?

I see that you might have looked into this: https://github.com/spark/firmware/blob/develop/hal/src/photon/softap.cpp#L779

If you are using the Web IDE/Particle-cli, i don’t think that might work…

@peekay123 inputs?

@kennethlimcp is correct. The only way you will be able to modify the SSID is via local compile of the firmware. The web IDE just dosen’t give you access to those libraries otherwise.

1 Like

Hi @kennethlimcp & @peekay123

Yes I have been doing a local compile, but it seems I need to do more then just #include dct.h in order to be able to call those functions dct_read_app_data & dct_write_app_data. I experimented with modify the softap.cpp code directly. That worked fine but I am very interested in being able to accomplish the task within the user code segment rather than the system code segment. When I try to duplicate these few instructions in my user code I fine I cannot call them. Any ideas?

@HardWater, with the Photon’s system/user firmware separation, functions in the system “partition” that are accessible to the user need to be exposed via a HAL/wiring API so the dynamic links are not compromised. I suggest you post an issue on the repo outlining the requirement. It makes sense to have a user-configurable SSID for the softAP. :smile:

2 Likes

Hi @peekay123 what you say makes sense to me but it seems to conflict with @mdma comment

from this other thread Implications of customized system firmware - Photon - #8 by HardWater where similar issues were discussed.

I did a search for the source for dct_read_app_data & dct_write_app_data but cannot find it in the repo only that it is defined as an extern function. I was thinking that maybe there are lower level commands that I need to execute to access the hardware and those commands were accessable.

@HardWater, what @mdma says is true however, when you need to hook into a shared resource (eg. ISR vector table), you will need an API. Also, anything that is done in the WICED library will need to be exposed as the library remains closed to users for now. Those functions are (likely) in the WICED (pre-compiled) image explaining why you can’t find them.

1 Like

Thank You @peekay123 that makes a lot of sense.

1 Like