nopnop2002 / esp-idf-video-streaming

Capture video from a USB camera using ESP-IDF
MIT License
41 stars 4 forks source link

[Q/A] Do you know how I can use a C++ library in this project ? #24

Open joyel24 opened 2 months ago

joyel24 commented 2 months ago

I would like to use this library in your project but it's C++ : https://github.com/jgromes/RadioLib

@nopnop2002 Sorry for annoying you with that. Do you known if there's a simple way to do that ?

nopnop2002 commented 2 months ago

The Arduino environment has objects such as Serial, i2c, and SPI, and these objects are used to operate the device. ESP-IDF does not have these objects. Serial, i2c, SPI reads/writes should be changed to ESP-IDF components.

Many of the ESP-IDF components use Configuration Structures as arguments to the initialization functions. ESP-IDF examples written in C routinely use designated initializers to fill these structures in a readable and a maintainable way.

C and C++ languages have different rules with regards to the designated initializers. For example, C++23 (currently the default in ESP-IDF) does not support out-of-order designated initialization, nested designated initialization, mixing of designated initializers and regular initializers, and designated initialization of arrays. Therefore, when porting ESP-IDF C examples to C++, some changes to the structure initializers may be necessary. Most C++ libraries cannot be compiled out of the box. It is necessary to rewrite the device initialization in C language.

Considering these points, it is not realistic to use C++ as is. It's less problematic to rewrite everything in C.

joyel24 commented 2 months ago

Thanks for your quick answer.

This is what I excpected. Maybe I can try to use your ported SX1262 driver but I wanted to use FSK modulation for higher bitrare...

nopnop2002 commented 2 months ago

LoRa's packet structure is strictly specified, so communication is possible between different libraries as long as the frequency, SF, BW, and CR match. If frequency, SF, BW, CR match, Communication between SX126x and SX127x is possible

On the other hand, with FSK modulation, there are no regulations regarding the packet structure, and the packet structure depends on the implementation of the library, so communication between different libraries is not guaranteed even if the same frequency is used.

When using FSK modulation, communication is only guaranteed between the same libraries.