antirez/protoview

error: implicit declaration of function 'furi_hal_subghz_load_preset'

Opened this issue · 1 comments

While build latest release on Unleashed firmware as base, i got this error:

applications_user/protoview/app_subghz.c: In function 'radio_begin':
applications_user/protoview/app_subghz.c:52:9: error: implicit declaration of function 'furi_hal_subghz_load_preset'; did you mean 'furi_hal_subghz_read_packet'? [-Werror=implicit-function-declaration]
52 | furi_hal_subghz_load_preset(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| furi_hal_subghz_read_packet
CC applications_user/protoview/signal_file.c
cc1: all warnings being treated as errors
scons: *** [build/f7-firmware-D/.extapps/protoview/app_subghz.o] Error 1

lserni commented

The API changed between releases 0.85.2 and 0.86.0-rc .

Disclaimer: while I do have some experience with C and HW gadgets, I had never seen inside any Flipper sources before a hour ago. With this in mind, these are the smallest modifications that get my version of the code to compile and run.

  • I had to change the lib path to be able to find cc1101.h and cc1101_regs.h (I guess I could have copied them in my working directory, taking them from the 0.94 firmware tree which is where I made the lib point to)
  • in view_info.c, I had to include <lib/toolbox/random_name.c> to get the random_name function (I don't think this is the right way to do it, but ufbt did not complain)
  • in app_subghz.c, I also included cc1101_configs.h, then changed the code as follows:
    /* The CC1101 preset can be either one of the standard presets, if
     * the modulation "custom" field is NULL, or a custom preset we
     * defined in custom_presets.h. */
    const uint8_t *preset;
    if (ProtoViewModulations[app->modulation].custom == NULL) {
        switch (ProtoViewModulations[app->modulation].preset) {
            case FuriHalSubGhzPresetOok650Async:
                preset = subghz_device_cc1101_preset_ook_650khz_async_regs;
                break;
            case FuriHalSubGhzPresetOok270Async:
                preset = subghz_device_cc1101_preset_ook_270khz_async_regs;
                break;
            case FuriHalSubGhzPreset2FSKDev238Async:
                preset = subghz_device_cc1101_preset_2fsk_dev2_38khz_async_regs;
                break;
            case FuriHalSubGhzPreset2FSKDev476Async:
                preset = subghz_device_cc1101_preset_2fsk_dev47_6khz_async_regs;
                break;
            default:
                furi_crash(NULL);
        }
    } else {
        preset = ProtoViewModulations[app->modulation].custom;
    }
    furi_hal_subghz_load_custom_preset(preset);

With these modifications, the code compiles and the modified code above runs on my Flipper.
The app does intercept and correctly decode signals (I checked with a garage opener and a radio thingy I had).
The app still does not work fully, because if I check "Real Time capture", it crashes carping about "furi_check".

The PROPER way of doing things would be (at least) to retrieve a handle to the cc1101 device and use e.g. subghz_devices_reset(device); instead of furi_hal_subghz_reset(); and so on, but I wasn't able to do that so far.