BT data transfer

Hello Community,

i'm currently working with NRF5340dk.
My application collects data from sensors for now and display it on the terminal emulator.
Next step for me is to send these datas to my phone (for example) through BT.
i tried to gather all the data to a .txt file to be able to send them as a file to my phone 
but it doesnt work for the moment, there's no file being created.
for the part of BT data sending i have no idea where to begin.
i tried the BT sample on Zephyr but it did not help me much.

do you have any recommendation for me to follow or tuto's to read that can help me get the job done 
please feel free to link me anything that can be useful .

i'm putting below the code i putted in my main to create the file 

 int function(){
        char *filename = "bt_file.txt";

        FILE *fp =fopen("bt_file.txt","w");
        if(fp == NULL)
        {
        printf("Eroor opening the file %s", filename);
        return -1;
        }
        for (char ch = 'a'; ch < 'z'; ch++)
        fputc(ch, fp);

        // close the file
        fclose(fp);
        return 0;
        }
 

thank you for stopping by 
i really appreciate your help in advance 

  • Hello again, 
    i found some useful link

    i tried to use it but i have the same error no matter what i do 

    Building ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-mkdir’ from solution ‘build’ in configuration ‘Common’
    1> Checking ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-mkdir’
    1> 'modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-mkdir' is up to date
    Building ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-download’ from solution ‘build’ in configuration ‘Common’
    1> Checking ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-download’
    1> 'modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-download' is up to date
    Building ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-update’ from solution ‘build’ in configuration ‘Common’
    1> Checking ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-update’
    1> 'modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-update' is up to date
    Building ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-patch’ from solution ‘build’ in configuration ‘Common’
    1> Checking ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-patch’
    1> 'modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-patch' is up to date
    Building ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-configure’ from solution ‘build’ in configuration ‘Common’
    1> Checking ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-configure’
    1> 'modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-configure' is up to date
    Building ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-build’ from solution ‘build’ in configuration ‘Common’
    1> Checking ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-build’
    1> modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-build does not exist.
    1> Combining ‘modules/nrf/samples/spm_subimage-prefix/src/spm_subimage-stamp/spm_subimage-build’
    1> C:\Users\rzaafouri\ncs\v1.8.0\toolchain\opt\bin\cmake.exe --build . --
    1> [1/163] Building C object modules/nrfxlib/nrfxlib/nrf_security/src/mbedtls/CMakeFiles/mbedcrypto_base_vanilla.dir/C_/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_slot_management.c.obj
    1> FAILED: modules/nrfxlib/nrfxlib/nrf_security/src/mbedtls/CMakeFiles/mbedcrypto_base_vanilla.dir/C_/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_slot_management.c.obj 
    1> C:\Users\rzaafouri\ncs\v1.8.0\toolchain\opt\bin\arm-none-eabi-gcc.exe -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DPSA_CRYPTO_SECURE -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/include -Izephyr/include/generated -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/lib/libc/minimal/include -IC:/Users/rzaafouri/ncs/v1.8.0/nrf/include -IC:/Users/rzaafouri/ncs/v1.8.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/Users/rzaafouri/ncs/v1.8.0/modules/hal/nordic/nrfx -IC:/Users/rzaafouri/ncs/v1.8.0/modules/hal/nordic/nrfx/drivers/include -IC:/Users/rzaafouri/ncs/v1.8.0/modules/hal/nordic/nrfx/mdk -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/modules/hal_nordic/nrfx/. -Ic:/users/rzaafouri/ncs/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include -Ic:/users/rzaafouri/ncs/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -IC:/Users/rzaafouri/ncs/v1.8.0/nrf/samples/spm/kernel/include -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/arch/arm/include -IC:/Users/rzaafouri/ncs/v1.8.0/nrfxlib/crypto/nrf_cc312_platform/include -Imodules/nrfxlib/nrfxlib/nrf_security/include/mbedtls_generated/mbedtls -Imodules/nrfxlib/nrfxlib/nrf_security/include/mbedtls_generated -Imodules/nrfxlib/nrfxlib/nrf_security/include -IC:/Users/rzaafouri/ncs/v1.8.0/nrfxlib/nrf_security/include -IC:/Users/rzaafouri/ncs/v1.8.0/mbedtls/library -IC:/Users/rzaafouri/ncs/v1.8.0/mbedtls/include -IC:/Users/rzaafouri/ncs/v1.8.0/mbedtls/include/mbedtls -IC:/Users/rzaafouri/ncs/v1.8.0/mbedtls/include/psa -IC:/Users/rzaafouri/ncs/v1.8.0/nrfxlib/nrf_security/include/mbedcrypto_glue/mbedtls/threading -Os -imacros C:/Users/rzaafouri/ncs/v1.8.0/zephyr/tests/bluetooth/shell/build_nrf5340dk_nrf5340_cpuapp_ns/spm/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee -imacros C:/Users/rzaafouri/ncs/v1.8.0/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.8.0/nrf/samples/spm=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.8.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.8.0=WEST_TOPDIR -ffunction-sections -fdata-sections -mcmse -std=c99 -nostdinc -MD -MT modules/nrfxlib/nrfxlib/nrf_security/src/mbedtls/CMakeFiles/mbedcrypto_base_vanilla.dir/C_/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_slot_management.c.obj -MF modules\nrfxlib\nrfxlib\nrf_security\src\mbedtls\CMakeFiles\mbedcrypto_base_vanilla.dir\C_\Users\rzaafouri\ncs\v1.8.0\mbedtls\library\psa_crypto_slot_management.c.obj.d -o modules/nrfxlib/nrfxlib/nrf_security/src/mbedtls/CMakeFiles/mbedcrypto_base_vanilla.dir/C_/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_slot_management.c.obj -c C:/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_slot_management.c
    1> C:/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_slot_management.c:22: fatal error: opening dependency file modules\nrfxlib\nrfxlib\nrf_security\src\mbedtls\CMakeFiles\mbedcrypto_base_vanilla.dir\C_\Users\rzaafouri\ncs\v1.8.0\mbedtls\library\psa_crypto_slot_management.c.obj.d: No such file or directory
    1>    22 | 
    1>       | 
    1> compilation terminated.
    1> [2/163] Building C object modules/nrfxlib/nrfxlib/nrf_security/src/mbedtls/CMakeFiles/mbedcrypto_base_vanilla.dir/C_/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_driver_wrappers.c.obj
    1> FAILED: modules/nrfxlib/nrfxlib/nrf_security/src/mbedtls/CMakeFiles/mbedcrypto_base_vanilla.dir/C_/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_driver_wrappers.c.obj 
    1> C:\Users\rzaafouri\ncs\v1.8.0\toolchain\opt\bin\arm-none-eabi-gcc.exe -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DPSA_CRYPTO_SECURE -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/include -Izephyr/include/generated -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/lib/libc/minimal/include -IC:/Users/rzaafouri/ncs/v1.8.0/nrf/include -IC:/Users/rzaafouri/ncs/v1.8.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/Users/rzaafouri/ncs/v1.8.0/modules/hal/nordic/nrfx -IC:/Users/rzaafouri/ncs/v1.8.0/modules/hal/nordic/nrfx/drivers/include -IC:/Users/rzaafouri/ncs/v1.8.0/modules/hal/nordic/nrfx/mdk -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/modules/hal_nordic/nrfx/. -Ic:/users/rzaafouri/ncs/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include -Ic:/users/rzaafouri/ncs/v1.8.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -IC:/Users/rzaafouri/ncs/v1.8.0/nrf/samples/spm/kernel/include -IC:/Users/rzaafouri/ncs/v1.8.0/zephyr/arch/arm/include -IC:/Users/rzaafouri/ncs/v1.8.0/nrfxlib/crypto/nrf_cc312_platform/include -Imodules/nrfxlib/nrfxlib/nrf_security/include/mbedtls_generated/mbedtls -Imodules/nrfxlib/nrfxlib/nrf_security/include/mbedtls_generated -Imodules/nrfxlib/nrfxlib/nrf_security/include -IC:/Users/rzaafouri/ncs/v1.8.0/nrfxlib/nrf_security/include -IC:/Users/rzaafouri/ncs/v1.8.0/mbedtls/library -IC:/Users/rzaafouri/ncs/v1.8.0/mbedtls/include -IC:/Users/rzaafouri/ncs/v1.8.0/mbedtls/include/mbedtls -IC:/Users/rzaafouri/ncs/v1.8.0/mbedtls/include/psa -IC:/Users/rzaafouri/ncs/v1.8.0/nrfxlib/nrf_security/include/mbedcrypto_glue/mbedtls/threading -Os -imacros C:/Users/rzaafouri/ncs/v1.8.0/zephyr/tests/bluetooth/shell/build_nrf5340dk_nrf5340_cpuapp_ns/spm/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee -imacros C:/Users/rzaafouri/ncs/v1.8.0/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.8.0/nrf/samples/spm=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.8.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/Users/rzaafouri/ncs/v1.8.0=WEST_TOPDIR -ffunction-sections -fdata-sections -mcmse -std=c99 -nostdinc -MD -MT modules/nrfxlib/nrfxlib/nrf_security/src/mbedtls/CMakeFiles/mbedcrypto_base_vanilla.dir/C_/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_driver_wrappers.c.obj -MF modules\nrfxlib\nrfxlib\nrf_security\src\mbedtls\CMakeFiles\mbedcrypto_base_vanilla.dir\C_\Users\rzaafouri\ncs\v1.8.0\mbedtls\library\psa_crypto_driver_wrappers.c.obj.d -o modules/nrfxlib/nrfxlib/nrf_security/src/mbedtls/CMakeFiles/mbedcrypto_base_vanilla.dir/C_/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_driver_wrappers.c.obj -c C:/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_driver_wrappers.c
    1> C:/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_driver_wrappers.c:1065:5: error: expected declaration or statement at end of input
    1>  1065 |     return( PSA_ERROR_NOT_SUPPORTED );
    1>       |     ^~~~~~
    1> C:/Users/rzaafouri/ncs/v1.8.0/mbedtls/library/psa_crypto_driver_wrappers.c:1065:5: fatal error: opening dependency file modules\nrfxlib\nrfxlib\nrf_security\src\mbedtls\CMakeFiles\mbedcrypto_base_vanilla.dir\C_\Users\rzaafouri\ncs\v1.8.0\mbedtls\library\psa_crypto_driver_wrappers.c.obj.d: No such file or directory
    1> compilation terminated.
    1> ninja: build stopped: subcommand failed.
    Build failed
    

    do you know how can we solve this error please ?

    Thank you in advance

  • Hello

    First of all I would recommend you to send raw data over BT, instead of sending a larger file, this will make everything easier for you.

    For how to send data I would recommend having a look at the Peripheral UART BLE sample, which uses the Nordic UART Service (NUS). I believe NUS could be a fitting option for sending data in your application.

    If you want to learn more about how a BLE service is set up and how it works, here's a tutorial on that.

    Best regards,

    Einar

Related