How to create a new C++ project with zigbee stack

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create a new C++ project with zigbee stack

1,994 Views
kucheravy
Contributor I

   I installed MCUExpresso IDE, then installed KW41Z SDK. All that looks good. I could load a zigbee example project (frdmkw41z_wireless_examples_zigbee_3_0_dimmer_switch_freertos) and build it. I didn't try to run it yet. Now, what I would like to do is either change that example project type from C to C++ or create another C++ project from the ground and add the zigbee stack to it. I didn't find how to change the project type and when I create a new C++ project the middleware tab, where I expect to see the zigbee component, is completely empty. What am I doing wrong or what did I miss in setting up the dev environment? I would suppose it is possible to add the zigbee stack to the project manually but I hope there is some sort of automation in this regards.

0 Kudos
7 Replies

1,796 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Alexander

I hope you are doing great.

I recommend adding your drivers or your code to the Zigbee projects. Otherwise, it could create some issues importing the Zigbee stack for all the libraries and paths that the project will need.

Regards,

Mario

0 Kudos

1,797 Views
kucheravy
Contributor I

   That was my initial idea to use the zigbee example as the base project but now to get back to the original question, how, in this case, to convert the zigbee example project from C to C++. I really, really, really, want to use C++ language features for better code structuring. Are there anywhere step by step instructions how to do this?

Thanks,

Alex

0 Kudos

1,796 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Alexander,

 

Unfortunately, we provide some lib files that are precompiled in C. So, we do not support C ++ in our example.

You could try by your side implementing the Zigbee Stack using C++.

Sorry for any inconvenience.

Regards,

Mario

0 Kudos

1,796 Views
kucheravy
Contributor I

   Having a precompiled C library in the project should not be a problem. I judge by Windows. There are core binaries written in C, compiled in C, nevertheless then can be easily integrated into C++ projects. A binary is a binary, we only need the entry points to call the functions and in C++ its extern "C" notation and everything should work. However for me it could take enormous time to try to convert it because everything is new for me here - Eclipse IDE, ARM MCU, etc. I hoped there is somebody who understands the toolchain very well and it would be a matter of half an hour for him to show how to change the project type from C to C++. I need at least simple language instructions like go to that XML file, replace that to that, go to header files, change something there, reference another lib or remove something. I don't even know where to start. I looked at the Eclipse project settings and C++ is disabled for the example projects. Apparently I still can change it but I have to manually edit the project file.

   Besides I remember doing something similar in IAR for 8051. I managed to do that. C++ compiler option was not disabled in that IDE. I changed that. Then, I got a bunch on compiler errors which was not difficult to resolve. Most of the errors were missing #ifdef __cplusplus in the C code. After that everything worked just fine. Here, I don't know where to start.

Alex

0 Kudos

1,797 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Alex,

Unfortunately, we do not provide the I recommend programming in C language. 

What are the functions that you want to use in your project?

Is it possible that you could provide more details about your project? 

Regards,

Mario

0 Kudos

1,796 Views
kucheravy
Contributor I

   At this point it is hard to say what exactly we are going to need. We are at the evaluation stage. We need to figure out what we can and cannot do with MCUXpresso and KW41Z. What I can say is that the project might be complex enough to use C++ for better structuring of the code.

   By the way, I have certain progress with what I'm doing. I almost managed to create a C++ project with a zigbee C example. Now, I'm stuck with two things that I'm still not able to resolve. One, it looks like the Linker is linking the obj files in the wrong order and I'm having "undefined reference to" linker errors in many places even though the references are definitely defined in other objs and two, I don't know how to correctly define certain things in the linker script. When a new project C or C++ is created the linker script managing is set to automatic but there is certain code, fsl_common InstallIRQHandler function, for example, which expects certain symbols to be defined in the linker script. In the case with InstallIRQHandler I'm talking about __RAM_VECTOR_TABLE_SIZE_BYTES. I didn't find anywhere in the SDK how to define such symbols. This is not the only case, there are more. I sort of expected to have a linker script include or something with all such defines.

   Do you have an idea how to resolve these two things?

0 Kudos

1,796 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Alexander,

 

Unfortunately, we do not recommend the creation of a project from scratch for Wireless Connectivity Products. The reason is that wireless examples do not depend completely on the SDK examples.

 

We recommend the usage of the current examples as a base and change only the application level of the examples. 

We can recommend you to check the Connectivity Framework Reference Manual for some guidance of the linker file management, still, that would be the best we can help you.

 "…\KW41_SDK\docs\wireless\Common\Connectivity Framework Reference Manual.pdf"

 

If you desire to develop for this IC with C++ it would be up to you the modifications and the development of the task.

 

If you use one of the basic examples linker files as a base, the linker file structure for those examples will be different from the wireless ones.

 

The MCUxpresso is based on Eclipse, that is the reason that supports the C++, but unfortunately, our setup and examples are not supported.

Sorry for the inconvenience this might cause you. 

 

Regards,

Mario

0 Kudos