diff --git a/firmware/targets/f7/api_symbols.csv b/firmware/targets/f7/api_symbols.csv index 720b4b3ce..5d343bf25 100644 --- a/firmware/targets/f7/api_symbols.csv +++ b/firmware/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,7.31,, +Version,+,7.32,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -1239,8 +1239,12 @@ Function,+,furi_hal_pwm_start,void,"FuriHalPwmOutputId, uint32_t, uint8_t" Function,+,furi_hal_pwm_stop,void,FuriHalPwmOutputId Function,+,furi_hal_random_fill_buf,void,"uint8_t*, uint32_t" Function,+,furi_hal_random_get,uint32_t, +Function,+,furi_hal_region_get,const FuriHalRegion*, +Function,+,furi_hal_region_get_band,const FuriHalRegionBand*,uint32_t Function,+,furi_hal_region_get_name,const char*, +Function,+,furi_hal_region_is_frequency_allowed,_Bool,uint32_t Function,+,furi_hal_region_is_provisioned,_Bool, +Function,+,furi_hal_region_set,void,FuriHalRegion* Function,+,furi_hal_resources_deinit_early,void, Function,-,furi_hal_resources_init,void, Function,-,furi_hal_resources_init_early,void, @@ -2051,22 +2055,22 @@ Function,-,powl,long double,"long double, long double" Function,-,printf,int,"const char*, ..." Function,-,prng_successor,uint32_t,"uint32_t, uint32_t" Function,+,protocol_dict_alloc,ProtocolDict*,"const ProtocolBase**, size_t" -Function,-,protocol_dict_decoders_feed,ProtocolId,"ProtocolDict*, _Bool, uint32_t" -Function,-,protocol_dict_decoders_feed_by_feature,ProtocolId,"ProtocolDict*, uint32_t, _Bool, uint32_t" -Function,-,protocol_dict_decoders_feed_by_id,ProtocolId,"ProtocolDict*, size_t, _Bool, uint32_t" -Function,-,protocol_dict_decoders_start,void,ProtocolDict* -Function,-,protocol_dict_encoder_start,_Bool,"ProtocolDict*, size_t" -Function,-,protocol_dict_encoder_yield,LevelDuration,"ProtocolDict*, size_t" +Function,+,protocol_dict_decoders_feed,ProtocolId,"ProtocolDict*, _Bool, uint32_t" +Function,+,protocol_dict_decoders_feed_by_feature,ProtocolId,"ProtocolDict*, uint32_t, _Bool, uint32_t" +Function,+,protocol_dict_decoders_feed_by_id,ProtocolId,"ProtocolDict*, size_t, _Bool, uint32_t" +Function,+,protocol_dict_decoders_start,void,ProtocolDict* +Function,+,protocol_dict_encoder_start,_Bool,"ProtocolDict*, size_t" +Function,+,protocol_dict_encoder_yield,LevelDuration,"ProtocolDict*, size_t" Function,+,protocol_dict_free,void,ProtocolDict* -Function,-,protocol_dict_get_data,void,"ProtocolDict*, size_t, uint8_t*, size_t" -Function,-,protocol_dict_get_data_size,size_t,"ProtocolDict*, size_t" -Function,-,protocol_dict_get_features,uint32_t,"ProtocolDict*, size_t" -Function,-,protocol_dict_get_manufacturer,const char*,"ProtocolDict*, size_t" -Function,-,protocol_dict_get_max_data_size,size_t,ProtocolDict* -Function,-,protocol_dict_get_name,const char*,"ProtocolDict*, size_t" +Function,+,protocol_dict_get_data,void,"ProtocolDict*, size_t, uint8_t*, size_t" +Function,+,protocol_dict_get_data_size,size_t,"ProtocolDict*, size_t" +Function,+,protocol_dict_get_features,uint32_t,"ProtocolDict*, size_t" +Function,+,protocol_dict_get_manufacturer,const char*,"ProtocolDict*, size_t" +Function,+,protocol_dict_get_max_data_size,size_t,ProtocolDict* +Function,+,protocol_dict_get_name,const char*,"ProtocolDict*, size_t" Function,+,protocol_dict_get_protocol_by_name,ProtocolId,"ProtocolDict*, const char*" -Function,-,protocol_dict_get_validate_count,uint32_t,"ProtocolDict*, size_t" -Function,-,protocol_dict_get_write_data,_Bool,"ProtocolDict*, size_t, void*" +Function,+,protocol_dict_get_validate_count,uint32_t,"ProtocolDict*, size_t" +Function,+,protocol_dict_get_write_data,_Bool,"ProtocolDict*, size_t, void*" Function,+,protocol_dict_render_brief_data,void,"ProtocolDict*, FuriString*, size_t" Function,+,protocol_dict_render_data,void,"ProtocolDict*, FuriString*, size_t" Function,+,protocol_dict_set_data,void,"ProtocolDict*, size_t, const uint8_t*, size_t" diff --git a/firmware/targets/f7/furi_hal/furi_hal_region.c b/firmware/targets/f7/furi_hal/furi_hal_region.c index 2fdee0983..0f0cb855c 100644 --- a/firmware/targets/f7/furi_hal/furi_hal_region.c +++ b/firmware/targets/f7/furi_hal/furi_hal_region.c @@ -1,4 +1,48 @@ #include +#include + +const FuriHalRegion furi_hal_region_zero = { + .country_code = "00", + .bands_count = 1, + .bands = { + { + .start = 0, + .end = 1000000000, + .power_limit = 12, + .duty_cycle = 50, + }, + }}; + +static const FuriHalRegion* furi_hal_region = NULL; + +const FuriHalRegion* furi_hal_region_get() { + return &furi_hal_region_zero; +} + +void furi_hal_region_set(FuriHalRegion* region) { + UNUSED(region); +} + +const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency) { + furi_hal_region = &furi_hal_region_zero; + if(!furi_hal_region) { + return NULL; + } + + for(size_t i = 0; i < furi_hal_region->bands_count; i++) { + if(furi_hal_region->bands[i].start <= frequency && + furi_hal_region->bands[i].end >= frequency) { + return &furi_hal_region->bands[i]; + } + } + + return NULL; +} + +bool furi_hal_region_is_frequency_allowed(uint32_t frequency) { + UNUSED(frequency); + return true; +} bool furi_hal_region_is_provisioned() { return true; diff --git a/firmware/targets/furi_hal_include/furi_hal_region.h b/firmware/targets/furi_hal_include/furi_hal_region.h index 04d8cc3d7..a48d9961d 100644 --- a/firmware/targets/furi_hal_include/furi_hal_region.h +++ b/firmware/targets/furi_hal_include/furi_hal_region.h @@ -2,10 +2,40 @@ #include #include +#include #ifdef __cplusplus extern "C" { #endif + +typedef struct { + uint32_t start; + uint32_t end; + int8_t power_limit; + uint8_t duty_cycle; +} FuriHalRegionBand; + +typedef struct { + char country_code[4]; + uint16_t bands_count; + FuriHalRegionBand bands[]; +} FuriHalRegion; + +/** Get Region Data. + * + * Region data may be allocated in Flash or in RAM. + * Keep in mind that we don't do memory management on our side. + * + * @return pointer to FuriHalRegion instance (in RAM or Flash, check before freeing on region update) + */ +const FuriHalRegion* furi_hal_region_get(); + +/** Set device region data + * + * @param region pointer to the FuriHalRegion + */ +void furi_hal_region_set(FuriHalRegion* region); + /** Check if region data provisioned * * @return true if provisioned, false otherwise @@ -26,6 +56,25 @@ bool furi_hal_region_is_provisioned(); */ const char* furi_hal_region_get_name(); +/** Сheck if transmission is allowed on this frequency for your flipper region + * + * @param[in] frequency The frequency + * @param value frequency in Hz + * + * @return true if allowed + */ +bool furi_hal_region_is_frequency_allowed(uint32_t frequency); + +/** Get band data for frequency + * + * + * + * @param[in] frequency The frequency + * + * @return { description_of_the_return_value } + */ +const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency); + #ifdef __cplusplus } #endif \ No newline at end of file