antirez / protoview

Flipper Zero app to display known and unknown signals
BSD 2-Clause "Simplified" License
505 stars 18 forks source link

error: implicit declaration of function 'furi_hal_subghz_load_preset' #19

Open michelep opened 1 year ago

michelep commented 1 year ago

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/appsubghz.o] Error 1

lserni commented 11 months ago

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.

    /* 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.