### Initialize Video Engine Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/video_engine/README.md Initializes and starts the video engine, performing all necessary setup steps. ```c int video_engine_init(void) { // 1. Check if already initialized // 2. Allocate context memory // 3. Initialize frame queue // 4. Automatically call video_engine_start() // 5. Return result } ``` -------------------------------- ### Basic Network Transfer Usage Example Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/network_transfer/README_CN.md Demonstrates the basic workflow of initializing, starting, getting network and encoder types, sending audio, stopping, and deinitializing the network transfer module. ```c #include "network_transfer.h" int main() { // 初始化网络传输模块 if (ntwk_trans_init() != 0) { printf("Network transfer init failed\n"); return -1; } // 启动网络传输 if (ntwk_trans_start(NULL) != 0) { printf("Network transfer start failed\n"); return -1; } // 获取网络类型 network_type_t network_type = ntwk_trans_get_network_type(); printf("Current network type: %d\n", network_type); // 获取音频编码器类型 audio_enc_type_t encoder_type = ntwk_trans_get_audio_encoder_type(); printf("Audio encoder type: %d\n", encoder_type); // 发送音频数据 uint8_t audio_data[1024]; // ... 填充音频数据 if (ntwk_trans_send_audio(audio_data, sizeof(audio_data), encoder_type) != 0) { printf("Send audio failed\n"); } // 停止网络传输 if (ntwk_trans_stop(NULL) != 0) { printf("Network transfer stop failed\n"); } // 反初始化 if (ntwk_trans_deinit() != 0) { printf("Network transfer deinit failed\n"); } return 0; } ``` -------------------------------- ### Audio Engine Initialization Flow Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/audio_engine.md Details the step-by-step process for initializing the Audio Engine, including volume setup, configuration building, and starting the audio engine service. ```default audio_engine_init() ↓ 1. Volume Initialization (audio_engine_volume_init) - Read volume level from configuration - Calculate volume gain table ↓ 2. Build Configuration Structure (audio_engine_cfg_t) - Sample rate configuration - Encoder/decoder type - AEC/NS configuration - PA control configuration - Callback function settings ↓ 3. Start Audio Engine (audio_engine_start) - Initialize Voice Service - Configure microphone stream - Configure speaker stream - Configure encoder/decoder - Configure AEC/NS algorithms - Start audio service ↓ 4. Initialize Prompt Tone (optional) - audio_engine_prompt_tone_init ↓ Initialization Complete ``` -------------------------------- ### Basic Motor Usage Example Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_motor.md Demonstrates the basic usage of the motor module by starting and then stopping the motor using the default PWM channel. ```C #include "motor.h" void example_usage(void) { // Start motor (using default channel) motor_open(PWM_MOTOR_CH_3); // Motor vibrating... // Stop motor motor_close(PWM_MOTOR_CH_3); } ``` -------------------------------- ### Video Engine Start Flow Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/video_engine.md Details the steps involved in starting the video engine, including parameter validation, camera parameter configuration, opening the camera, starting the transfer task, and setting the start flag. ```default 1. Parameter Validation - Check context validity - Check if already started (prevent duplicate start) ↓ 2. Build Camera Parameters - Read configuration from CONFIG macros - camera_parameters_t structure * id: 0 (DVP) or 1 (UVC) * width: CONFIG_VIDEO_ENGINE_RESOLUTION_WIDTH * height: CONFIG_VIDEO_ENGINE_RESOLUTION_HEIGHT * format: 0 (JPEG) or 1 (H.264) ↓ 3. Open Camera - video_engine_camera_turn_on() * Configure DVP (if using DVP) * Create camera controller * Open camera device ↓ 4. Start Video Transfer Task - video_engine_transfer_start() * Create transfer task thread * Set transfer_task_running = true ↓ 5. Set Start Flag - is_started = true ↓ Start Complete ``` -------------------------------- ### Start and Stop Audio Engine Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/audio_engine/README.md Demonstrates the basic usage of starting the audio engine with a configuration and then stopping it. Ensure to check the return value for success. ```c #include "audio_engine.h" /* Callback functions */ static void voice_read_callback(const uint8_t *data, uint32_t size, void *args) { /* Process received audio data */ } static bk_err_t voice_event_callback(voice_evt_t event, void *data, void *args) { /* Handle voice events */ return BK_OK; } int main(void) { audio_engine_cfg_t cfg = { .mic_type = MIC_TYPE_ONBOARD, .mic_sample_rate = 16000, .spk_type = SPK_TYPE_ONBOARD, .spk_sample_rate = 16000, .aec_enable = 1, .eq_enable = 0, .enc_type = AUDIO_ENC_TYPE_G711A, .dec_type = AUDIO_DEC_TYPE_G711A, .event_cb = voice_event_callback, .read_cb = voice_read_callback, .user_data = NULL }; /* Start audio engine */ int ret = audio_engine_start(&cfg); if (ret != AUDIO_ENGINE_SUCCESS) { printf("Failed to start: %s\n", audio_engine_err_to_str(ret)); return ret; } /* Audio engine is now running */ /* Stop audio engine when done */ ret = audio_engine_stop(); if (ret != AUDIO_ENGINE_SUCCESS) { printf("Failed to stop: %s\n", audio_engine_err_to_str(ret)); return ret; } return AUDIO_ENGINE_SUCCESS; } ``` -------------------------------- ### Start Video Engine Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/video_engine/README.md Starts the video engine by opening the camera and initiating the transfer task. ```c int video_engine_start(void) { // 1. Check context validity // 2. Check if already started // 3. Open camera using camera_parameters // 4. Start video transfer task // 5. Set is_started = true // 6. Return result } ``` -------------------------------- ### Basic LED Control Example Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_led_blink.md Demonstrates initializing the LED driver and setting different blink patterns and states for LEDs. ```c #include "led_app.h" void example_usage(void) { // Initialize LED led_driver_init(); // Set green LED fast blink led_app_set(LED_FAST_BLINK_GREEN, LED_LAST_FOREVER); // Set red LED slow blink for 5 seconds led_app_set(LED_SLOW_BLINK_RED, 5000); // Turn off green LED led_app_set(LED_OFF_GREEN, 0); } ``` -------------------------------- ### Custom Camera Parameters and Start Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/zh_CN/developer-guide/video_engine.md Configure custom camera parameters and start the video capture and transfer process. Ensure video_engine_init() is called prior to this. The camera parameters include ID, resolution, format, and rotation. ```c #include "video_engine.h" int custom_video_start(void) { camera_parameters_t params = { .id = 0, // DVP camera .width = 640, // Width .height = 480, // Height .format = 1, // H.264 format .protocol = 0, // Reserved .rotate = 0, // No rotation }; // Open camera int ret = video_engine_camera_turn_on(¶ms); if (ret != BK_OK) { LOGE("Camera turn on failed\n"); return ret; } // Start transfer task ret = video_engine_transfer_start(); if (ret != BK_OK) { LOGE("Transfer start failed\n"); video_engine_camera_close(); return ret; } return BK_OK; } ``` -------------------------------- ### Start Video Engine Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/video_engine.md Starts the video engine using default configuration defined by CONFIG macros. This function automatically opens the camera and starts the transfer task. It is typically called by video_engine_init(). ```C /** * @brief Start video engine (using default configuration) * * This function starts video engine using configuration defined by CONFIG macros. * Will open camera and start transfer task. * * This function is automatically called by video_engine_init(). * * @return int * - BK_OK: Success * - BK_FAIL: Failure */ int video_engine_start(void); ``` -------------------------------- ### LED Driver Initialization Flow Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_led_blink.md Details the step-by-step process for initializing the LED driver, including mutex setup and LED registration. ```text 1. Initialize Mutex - rtos_init_mutex(&led_mutex) ↓ 2. Clear LED Control Block Array - memset(led_pool, 0, sizeof(led_pool)) ↓ 3. Register Red LED - led_register(RED_LED) ↓ 4. Register Green LED - led_register(GREEN_LED) ↓ Initialization Complete ``` -------------------------------- ### Initialize and Start Audio Engine Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/audio_engine.md Use `audio_engine_start` to initialize the audio engine with a custom configuration. Ensure `audio_engine_cfg_t` is properly populated before calling. Returns 0 on success, or a negative error code. ```C int audio_engine_start(audio_engine_cfg_t *cfg); ``` -------------------------------- ### Initialize Audio Engine with Default Configuration Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/audio_engine.md Use `audio_engine_init` for a quick setup using default parameters defined in Kconfig. Returns 0 on success, or a negative error code. ```C int audio_engine_init(void); ``` -------------------------------- ### Basic Dual Screen AVI Player Usage Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_dual_screen_avi_player.md Demonstrates the basic usage of the dual-screen AVI player, including starting playback with a specified file and stopping it. Error handling for the start function is included. ```c #include "bk_dual_screen_avi_player.h" void example_usage(void) { // Start playback bk_err_t ret = bk_dual_screen_avi_player_start("/sdcard/video.avi"); if (ret != BK_OK) { // Handle error return; } // Playing... // Stop playback bk_dual_screen_avi_player_stop(); } ``` -------------------------------- ### Initialization Interface Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/audio_engine.md Functions for starting, stopping, initializing, and deinitializing the audio engine. ```APIDOC ## audio_engine_start ### Description Initializes and starts the audio engine. ### Method int ### Parameters - **cfg** (audio_engine_cfg_t *) - Pointer to the audio engine configuration structure. ### Return Value - 0 (AUDIO_ENGINE_SUCCESS): Success - < 0: Error code (see audio_engine_err_t) ``` ```APIDOC ## audio_engine_stop ### Description Stops the audio engine and cleans up resources. ### Method int ### Return Value - 0: Success - < 0: Error code ``` ```APIDOC ## audio_engine_init ### Description Initializes the audio engine using default configuration parameters from Kconfig. ### Method int ### Return Value - 0: Success - < 0: Error code ``` ```APIDOC ## audio_engine_deinit ### Description Deinitializes the audio engine. ### Method int ### Return Value - 0: Success ``` -------------------------------- ### Video Engine Initialization Error Handling Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/video_engine/README.md Example of checking the return value of video_engine_init() and handling initialization failures. ```c int ret = video_engine_init(); if (ret != BK_OK) { // Initialization failed, resources already cleaned up internally // Can safely try to initialize again LOGE("Init failed, ret=%d\n", ret); } // stop and deinit will try their best to clean up, even if partially failed video_engine_deinit(); // Always call to be safe ``` -------------------------------- ### Basic Network Transfer Initialization and Usage Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/network_transfer.md Demonstrates the basic initialization, starting, and stopping of the network transfer module. Includes setting up audio callbacks and checking network types. ```C #include "network_transfer.h" #include "audio_engine.h" #include "video_engine.h" // Audio read callback (receive data from audio engine) static int audio_read_callback(unsigned char *data, unsigned int len, void *args) { // Send audio data to network return ntwk_trans_send_audio(data, len, ntwk_trans_get_audio_encoder_type()); } int main(void) { // 1. Initialize audio engine audio_engine_init(); // 2. Initialize video engine video_engine_init(); // 3. Initialize network transfer int ret = ntwk_trans_init(); if (ret != 0) { LOGE("Network transfer init failed\n"); return -1; } // 4. Start network transfer char device_id[65] = "your_device_id"; ret = ntwk_trans_start(device_id); if (ret != 0) { LOGE("Network transfer start failed\n"); return -1; } // 5. Check network type network_type_t type = ntwk_trans_get_network_type(); if (type == NETWORK_TYPE_AGORA_RTC) { LOGI("Using Agora RTC\n"); } else if (type == NETWORK_TYPE_VOLC_RTC) { LOGI("Using VolcEngine RTC\n"); } // 6. Audio data will be automatically sent through audio_read_callback // Video data will be automatically sent through video_engine // 7. Received audio data will be automatically played (through ntwk_trans_recv_audio) // 8. Stop network transfer ntwk_trans_stop(device_id); // 9. Deinitialize ntwk_trans_deinit(); return 0; } ``` -------------------------------- ### Incorrect Video Engine Call Sequence: Start Before Init Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/video_engine/README.md Shows an error where video_engine_start() is called before the engine is initialized. ```c // ❌ Incorrect example 2: Start before initialization video_engine_start(); // Error: context is NULL ``` -------------------------------- ### Initialize Key Service Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_key_app.md Call this function to load key configuration, initialize the key driver, and start the key scanning task. ```c void bk_key_service_init(void); ``` -------------------------------- ### Audio Engine Start Flow Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/audio_engine.md Provides a detailed breakdown of the `audio_engine_start()` function, covering parameter validation, voice service configuration, and initialization steps. ```default 1. Parameter Validation - Check configuration pointer validity - Validate sample rate (8000 or 16000) - Check if already started ↓ 2. Configure Voice Service - Microphone configuration (onboard_mic_stream_cfg_t) * ADC sample rate * Digital gain/analog gain * Frame size (20ms) * AEC mode (hardware/software) - Encoder configuration * G.711A/U: 160/320 byte frames * G.722: 80/160 byte frames * OPUS: Default configuration * PCM: Raw data - Decoder configuration * Corresponding decoder configuration for encoder - Speaker configuration (onboard_speaker_stream_cfg_t) * DAC sample rate * PA control (GPIO, delay, etc.) * Digital gain/analog gain - AEC configuration (if enabled) * AEC mode selection * Multiple output ports - EQ configuration (if enabled) ↓ 3. Initialize Voice Service - bk_voice_init(&voice_cfg) ↓ 4. Initialize Voice Read Service - bk_voice_read_init() - Register read callback ↓ 5. Initialize Voice Write Service - bk_voice_write_init() ↓ 6. Start Voice Service - bk_voice_start() - bk_voice_read_start() - bk_voice_write_start() ↓ 7. ASR Initialization (if enabled) - Configure ASR service - Start ASR ↓ Start Complete ``` -------------------------------- ### Basic Countdown Usage Example Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_countdown.md Demonstrates how to manage countdown tickets, update the countdown timer, and handle different event states like provisioning, standby, and OTA. ```C #include "countdown_app.h" void example_usage(void) { uint32_t active_tickets = 0; // Set provisioning countdown ticket active_tickets |= (1 << COUNTDOWN_TICKET_PROVISIONING); // Update countdown (will start 5-minute countdown) update_countdown(active_tickets); // Clear provisioning ticket, set standby ticket active_tickets &= ~(1 << COUNTDOWN_TICKET_PROVISIONING); active_tickets |= (1 << COUNTDOWN_TICKET_STANDBY); // Update countdown (will start 3-minute countdown) update_countdown(active_tickets); // OTA event, pause countdown active_tickets |= (1 << COUNTDOWN_TICKET_OTA); update_countdown(active_tickets); // Countdown stops // Clear all tickets, stop countdown active_tickets = 0; update_countdown(active_tickets); // Countdown stops } ``` -------------------------------- ### State Voting LED Control Example Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_led_blink.md Shows how to use the led_blink function with warning and indication states to automatically select LED behavior based on priority. ```c void state_voting_example(void) { uint32_t warning_state = 0; uint32_t indicates_state = 0; // Set warning state warning_state |= (1 << WARNING_WIFI_FAIL); // Set indication state indicates_state |= (1 << INDICATES_STANDBY); // Automatically select LED state led_blink(&warning_state, indicates_state); // Result: Red fast blink (warning priority higher than indication) } ``` -------------------------------- ### Start Network Transfer for Beken Smart Config Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/projects/beken_genie/index.md Initiates network transfer by starting the agent and device-side RTC. This function calls `ntwk_trans_start(device_id)`, which then invokes the appropriate startup function based on the configured RTC backend. For the Agora backend, it specifically calls `bk_agora_start(device_id)`. ```c bk_sconf_start_network_transfer is responsible for starting agent and device-side RTC. ``` -------------------------------- ### Start Doubao AI Agent Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/thirdparty/agora/index.md Use this cURL command to start the Doubao AI Agent. Ensure all placeholder strings like AGORA_APPID, AGORA_RESTFUL_TOKEN, CHANNEL_NAME, VOLC_API_KEY, VOLC_MODEL_ID, BYTEDANCE_TTS_APPID, and BYTEDANCE_TTS_TOKEN are replaced with your actual credentials and configuration values. ```default curl --location --request POST 'https://api.agora.io/cn/api/conversational-ai-agent/v2/projects/AGORA_APPID/join' --header 'Content-Type: application/json' --header 'Authorization: Basic AGORA_RESTFUL_TOKEN' --data-raw '{ "name": "CHANNEL_NAME", "properties": { "channel": "CHANNEL_NAME", "token": "", "agent_rtc_uid": "1234", "remote_rtc_uids": [ "123" ], "advanced_features": { "enable_bhvs": true, "enable_aivad": false }, "parameters": { "enable_dump": true, "output_audio_codec": "G722" }, "enable_string_uid": false, "idle_timeout": 0, "llm": { "url": "https://ark.cn-beijing.volces.com/api/v3/chat/completions", "api_key": "VOLC_API_KEY", "system_messages": [ { "role": "system", "content": "你是一个有礼貌的AI助理。" } ], "max_history": 10, "greeting_message": "新春快乐,有什么可以帮您?", "failure_message": "很抱歉.", "params": { "model": "VOLC_MODEL_ID" } }, "tts": { "vendor": "bytedance", "params": { "token": "BYTEDANCE_TTS_TOKEN", "app_id": "BYTEDANCE_TTS_APPID", "cluster": "volcano_tts", "speed_ratio": 1.0, "volume_ratio": 0.6, "pitch_ratio": 1.0, "emotion": "happy" } }, "asr": { "language": "zh-CN", "vendor": "tencent" } } }' ``` -------------------------------- ### bk_agora_start Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/projects/beken_genie/README.md Starts the complete Agora RTC and Agent service. This function is available if Agora RTC is enabled. ```APIDOC ## bk_agora_start ### Description Start complete Agora RTC and Agent service. ### Parameters #### Path Parameters - **device_id** (void *) - Required - Device ID string ### Return Value - **int** - Operation result - BK_OK: Start successful - BK_FAIL: Start failed ### See Also - bk_agora_stop() ``` -------------------------------- ### Default Platform Configuration Items Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_factory_config.md Example platform configuration items for system initialization, volume, and agent information. These are typically stored in SRAM cache. ```c // System initialization flag {"sys_initialized", "1", 1, BK_FALSE, 1} // Volume configuration (SRAM cache) {"volume", &s_factory_volume, 4, BK_TRUE, 4} // Agent information (SRAM cache) {"d_agent_info", "\0", 1, BK_TRUE, 588} ``` -------------------------------- ### Vibration Feedback Example Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_motor.md Shows how to implement vibration feedback by controlling the motor's on and off times using `rtos_delay_milliseconds`. ```C void vibration_feedback(void) { // Short vibration (100ms) motor_open(PWM_MOTOR_CH_3); rtos_delay_milliseconds(100); motor_close(PWM_MOTOR_CH_3); // Long vibration (500ms) motor_open(PWM_MOTOR_CH_3); rtos_delay_milliseconds(500); motor_close(PWM_MOTOR_CH_3); } ``` -------------------------------- ### Start AVI Playback Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/projects/beken_genie/index.md Call `bk_avi_play_start()` to begin playing an AVI file after it has been opened. ```c bk_avi_play_start() ``` -------------------------------- ### Download Armino SMP SDK Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/README.md Clones the Armino SMP SDK from GitLab. Ensure you have Git installed and access to the GitLab repository. ```bash mkdir -p ~/armino cd ~/armino git clone https://gitlab.bekencorp.com/armino/bk_avdk_smp.git -b release/v3.1.1 ``` -------------------------------- ### app_event_init Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_app_event.md Initializes the application event system by creating the necessary threads, message queues, and starting the event processing loop. ```APIDOC ## app_event_init ### Description Initializes the application event system. This function creates the event processing thread and message queue, and then starts the event processing loop. ### Function Signature ```c void app_event_init(void); ``` ### Parameters None ### Return Value None ``` -------------------------------- ### Network Provisioning Status Callback Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/projects/volc_rtc/index.md Callback function executed after WiFi connection. It handles starting the agent, saving WiFi and agent information, and network provisioning status updates. ```c bk_sconf_network_provisioning_status_cb(bk_network_provisioning_status_t status, void *user_data) ``` -------------------------------- ### Video Engine Initialization and Usage Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/video_engine/README.md Demonstrates the standard and recommended way to initialize the video engine, check its running status, and deinitialize it. This is the simplest usage flow. ```c #include "video_engine.h" int main(void) { // 1. Initialize video engine (auto-configure and start) int ret = video_engine_init(); if (ret != BK_OK) { printf("Video engine init failed: %d\n", ret); return -1; } printf("Video engine started successfully\n"); // 2. Check running status if (video_engine_is_running()) { printf("Video engine is running\n"); } // ... application runs ... // 3. Clean up resources video_engine_deinit(); return 0; } ``` -------------------------------- ### Dual Screen SPI Controller Configuration Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_dual_screen_avi_player.md Defines the structure for dual-screen SPI controller configuration and provides a default configuration example. This setup is necessary for dual-display operations. ```c typedef struct { bk_display_spi_ctlr_config_t lcd0_config; // LCD0 configuration bk_display_spi_ctlr_config_t lcd1_config; // LCD1 configuration } bk_display_dual_spi_ctlr_config_t; // Default configuration bk_display_dual_spi_ctlr_config_t dual_spi_ctlr_config = { .lcd0_config.lcd_device = &lcd_device_gc9d01, .lcd0_config.spi_id = 0, .lcd0_config.dc_pin = GPIO_7, .lcd0_config.reset_pin = GPIO_6, .lcd1_config.lcd_device = &lcd_device_gc9d01, .lcd1_config.spi_id = 1, .lcd1_config.dc_pin = GPIO_5, .lcd1_config.reset_pin = GPIO_45, }; ``` -------------------------------- ### Handle Audio Engine Errors Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/audio_engine/README.md Shows how to check for errors after starting the audio engine and handle specific error codes. Use the `audio_engine_err_to_str` function to get a human-readable error message. ```c int ret = audio_engine_start(&cfg); if (ret != AUDIO_ENGINE_SUCCESS) { const char *error_msg = audio_engine_err_to_str(ret); printf("Error %d: %s\n", ret, error_msg); switch (ret) { case AUDIO_ENGINE_ERR_INVALID_PARAM: /* Handle invalid parameters */ break; case AUDIO_ENGINE_ERR_VOICE_INIT: /* Handle voice init failure */ break; /* ... other error cases */ } } ``` -------------------------------- ### Enable Sensenova and Agent Startup Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/network_transfer.md Enable Sensenova (Agora integration) with CONFIG_SENSENOVA_ENABLE. Configure agent startup from Beken server (default) or a custom server. ```C // Enable Sensenova (Agora) CONFIG_SENSENOVA_ENABLE=y // Start Agent from Beken server (default) CONFIG_STARTUP_AGENT_FROM_BK_SERVER=y // Or start Agent from custom server // CONFIG_STARTUP_AGENT_FROM_BK_SERVER=n ``` -------------------------------- ### Video Engine Initialization Flow Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/video_engine.md Describes the sequence of operations for initializing the video engine, including checks for existing initialization, memory allocation, frame queue setup, and auto-starting the engine. ```default video_engine_init() ↓ 1. Check if Already Initialized - If initialized and started, return directly - If initialized but not started, call start ↓ 2. Allocate Context Memory - Allocate video_engine_ctx_t structure - Initialize all fields to 0 ↓ 3. Initialize Frame Queue - frame_queue_init_all() - Initialize frame queues for all formats (MJPEG, H264, YUV) ↓ 4. Auto Start Video Engine - video_engine_start() ↓ Initialization Complete ``` -------------------------------- ### Start and Stop Engine Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/video_engine.md Functions to start and stop the video engine. Starting the engine opens the camera and begins the transfer task. Stopping halts the transfer task and closes the camera, but does not release memory. ```APIDOC ## video_engine_start ### Description Starts the video engine using configuration defined by CONFIG macros. This function opens the camera and starts the transfer task. It is automatically called by `video_engine_init()`. ### Function Signature ```c int video_engine_start(void); ``` ### Return Value - `BK_OK`: Success - `BK_FAIL`: Failure ## video_engine_stop ### Description Stops the video transfer task and closes the camera. This function does not release memory or deinitialize the frame queue. Call `video_engine_deinit()` for complete resource cleanup. ### Function Signature ```c int video_engine_stop(void); ``` ### Return Value - `BK_OK`: Success - `BK_FAIL`: Failure ``` -------------------------------- ### Initialization Interface Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_key_app.md Provides functions to initialize the key service, register keys as wake-up sources, and initialize volume control. ```APIDOC ## Initialization Interface ### `bk_key_service_init()` #### Description Initializes the key service. This function loads key configuration, initializes the key driver, and starts the key scanning task. ### `bk_key_register_wakeup_source()` #### Description Registers a key as a system wake-up source. This supports waking the system from deep sleep. ### `volume_init()` #### Description Initializes the volume control function. ``` -------------------------------- ### Start AI Agent Service Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/projects/volc_rtc/README.md Starts the AI Agent service. Ensure network connectivity before calling. This function selects the server to start from, sends an HTTP request, parses the response, and fills the room information. ```c /** * @brief Start AI Agent service * * @param room_info Room information structure pointer (output parameter) * - Function will fill App ID, Room ID, Token and other information * * @param device_id Device ID string * * @return int Operation result * - BK_OK: Start successful * - BK_FAIL: Start failed * * @note This function will: * 1. Select to start from BK server or custom server according to configuration * 2. Send HTTP request to server * 3. Parse response to get room information * 4. Fill room_info structure * * @warning Before calling this function, ensure that network connection is normal * * @see bk_byte_agent_stop() */ int bk_byte_agent_start(byte_rtc_room_info_t *room_info, void *device_id); ``` -------------------------------- ### Turn On Camera Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/video_engine.md Validates and initializes camera parameters with default values, then opens the camera device. The provided parameters structure may be modified. Returns BK_OK on success or BK_FAIL on failure. ```C /** * @brief Open camera (with parameter initialization and validation) * * This function validates and initializes camera parameters with default values, then opens camera device. * * @param parameters Camera parameters (will be validated and modified) * * @return int * - BK_OK: Success * - BK_FAIL: Failure */ int video_engine_camera_turn_on(camera_parameters_t *parameters); ``` -------------------------------- ### Start and Stop Interface Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/network_transfer.md Functions to control the network transfer process, including starting, stopping, and updating. ```APIDOC ## Start and Stop Interface ### `ntwk_trans_start` #### Description Starts the network transfer by calling the start callback function of the underlying RTC backend. #### Parameters - `user_data` (void *): User data pointer, passed to the start callback function. #### Returns - `0`: Success - `< 0`: Failure ### `ntwk_trans_stop` #### Description Stops the network transfer by calling the stop callback function of the underlying RTC backend. #### Parameters - `user_data` (void *): User data pointer, passed to the stop callback function. #### Returns - `0`: Success - `< 0`: Failure ### `ntwk_trans_update` #### Description Updates the network transfer. This function calls the update callback function of the underlying RTC backend and is used for updating Agent configuration, etc. #### Parameters - `user_data` (void *): User data. - `update_info` (void *): Update information. #### Returns - `0`: Success - `< 0`: Failure ``` -------------------------------- ### Start and Stop Transmission Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/network_transfer/README_CN.md Starts and stops the audio network transmission. Returns 0 on success, negative on error. ```APIDOC ## ntwk_trans_start ### Description Starts the network transfer process. ### Parameters #### Path Parameters - `user_data` (void *) - Optional - User-specific data. ### Returns - `int`: 0 on success, negative on error. ## ntwk_trans_stop ### Description Stops the network transfer process. ### Parameters #### Path Parameters - `user_data` (void *) - Optional - User-specific data. ### Returns - `int`: 0 on success, negative on error. ``` -------------------------------- ### Start Complete RTC and Agent Service Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/projects/volc_rtc/README.md Starts both the complete RTC and Agent services. This is an advanced interface that initializes the RTC engine, joins a room, and starts audio/video transmission. It may also mount an SD card file system if a license is enabled. ```c /** * @brief Start complete RTC and Agent service * * @param device_id Device ID string * * @return int Operation result * - BK_OK: Start successful * - BK_FAIL: Start failed * * @note This function will: * 1. Mount SD card file system (if License is enabled) * 2. Start AI Agent service (get room information) * 3. Initialize RTC engine * 4. Join RTC room * 5. Start audio/video transmission * * @warning This is an advanced interface that will start both Agent and RTC * * @see bk_byte_stop() */ int bk_byte_start(void *device_id); ``` -------------------------------- ### Start RTC Only Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/projects/beken_genie/index.md This command starts only the RTC service, leaving the AI Agent unaffected. Useful when you need to manage RTC independently. ```bash agora_rtc start_agora ``` -------------------------------- ### Start Agent Only Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/projects/beken_genie/index.md This command starts only the AI Agent, without initiating the RTC service. This is useful if the RTC service is already managed or not needed. ```bash agora_rtc start_agent ``` -------------------------------- ### Basic Factory Configuration Usage Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_factory_config.md Demonstrates the basic usage of the factory configuration module, including initialization, reading, writing, and syncing configurations to flash. ```c #include "bk_factory_config.h" void example_usage(void) { // Initialize bk_factory_init(); // Read configuration uint32_t volume = 0; int ret = bk_config_read("volume", &volume, sizeof(volume)); if (ret > 0) { // Use configuration value } // Write configuration volume = 10; bk_config_write("volume", &volume, sizeof(volume)); // Sync to Flash bk_config_sync_flash(); } ``` -------------------------------- ### Start Agora RTC and Agent Service Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/projects/beken_genie/README.md Initializes and starts the complete Agora RTC and Agent service. Requires a device ID to be provided. ```c /** * @brief Start complete Agora RTC and Agent service * * @param device_id Device ID string * * @return int Operation result * - BK_OK: Start successful * - BK_FAIL: Start failed * * @see bk_agora_stop() */ int bk_agora_start(void *device_id); ``` -------------------------------- ### Beken Network Provisioning and Agent Startup Configuration Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/projects/volc_rtc/index.md Enable Beken network provisioning and agent startup by setting CONFIG_BK_SMART_CONFIG to 'y' on CPU0. ```kconfig CONFIG_BK_SMART_CONFIG = y ``` -------------------------------- ### Dual Screen AVI Player Interfaces Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_dual_screen_avi_player.md Provides functions to start and stop dual-screen AVI playback. Ensure the file path is valid before starting playback. ```c /** * @brief Start dual-screen AVI playback * * @param file_path AVI file path * @return bk_err_t * - BK_OK: Success * - BK_FAIL: Failure */ bk_err_t bk_dual_screen_avi_player_start(char *file_path); ``` ```c /** * @brief Stop dual-screen AVI playback * * @return bk_err_t * - BK_OK: Success * - BK_FAIL: Failure */ bk_err_t bk_dual_screen_avi_player_stop(void); ``` -------------------------------- ### Initialize Key Service Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_key_app.md Basic initialization for the key service, including registering a wake-up source and initializing volume. Ensure this is called during application startup. ```c #include "key_app_service.h" void app_init(void) { // Initialize key service bk_key_service_init(); // Register wake-up source (optional) bk_key_register_wakeup_source(); // Initialize volume (optional) volume_init(); } ``` -------------------------------- ### PWM Motor Control Example Reference Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/projects/volc_rtc/index.md Provides a reference for detailed PWM usage examples for motor control. The motor vibration strength is controlled by adjusting the PWM duty cycle. ```c cli_pwm.c ``` -------------------------------- ### Build Project: Using Docker (Linux/Mac) Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/get-started/index.md Build the project using Docker on Linux or Mac. Ensure the SDK_DIR is exported and use the provided dbuild.sh script for clean and build commands. ```bash cd ~/armino/bk_solution_ai/projects/beken_genie export SDK_DIR=~/armino/bk_avdk_smp ./dbuild.sh make clean ./dbuild.sh make bk7258 ``` -------------------------------- ### Start Countdown Timer Interface Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_countdown.md Starts a oneshot timer that triggers deep sleep upon expiration. If the timer exists, it's reloaded. The timer expiration forces a deep sleep with RESET_SOURCE_FORCE_DEEPSLEEP. ```C /** * @brief Start countdown timer * * Creates and starts a oneshot timer. When the countdown expires, the system * will automatically enter deep sleep mode. If the timer already exists, it * will be reloaded with the new timeout value. * * @param time_ms Countdown duration in milliseconds * * @note When the countdown expires, it triggers a forced deep sleep * (RESET_SOURCE_FORCE_DEEPSLEEP) */ void start_countdown(uint32_t time_ms); ``` -------------------------------- ### Video System Initialization with Error Handling Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/video_engine/README.md Illustrates a robust error handling flow for initializing the video system. It checks the return code of `video_engine_init` and verifies the running status post-initialization, cleaning up resources on failure. ```c #include "video_engine.h" int initialize_video_system(void) { int ret; // Initialize video engine ret = video_engine_init(); if (ret != BK_OK) { printf("ERROR: Failed to initialize video engine, ret=%d\n", ret); // Attempt to clean up any potential residual resources video_engine_deinit(); return -1; } // Verify initialization success if (!video_engine_is_running()) { printf("ERROR: Video engine initialized but not running\n"); video_engine_deinit(); return -1; } printf("Video system initialized successfully\n"); return 0; } ``` -------------------------------- ### Start Video Transfer Task Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/video_engine.md Starts the video transfer task. This task continuously retrieves frames from the frame queue and processes them via the registered transfer callback. Returns BK_OK on success or BK_FAIL on failure. ```C /** * @brief Start video transfer task * * This function creates a task that continuously gets frames from frame queue and processes through registered transfer callback. * * @return int * - BK_OK: Success * - BK_FAIL: Failure */ int video_engine_transfer_start(void); ``` -------------------------------- ### Register User Configuration Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_factory_config.md Shows how to define and register user-specific configurations. User configurations must reside in Flash memory. ```c // Define user configuration (must be in Flash) static const uint32_t s_default_timeout = 5000; static const struct factory_config_t s_user_config[] = { { .key = "timeout", .value = (void *)&s_default_timeout, .defval_size = 4, .need_sram_cache = BK_TRUE, .value_max_size = 4, }, }; void register_user_config(void) { // Register user configuration bk_regist_factory_user_config(s_user_config, sizeof(s_user_config) / sizeof(s_user_config[0])); // Initialize factory configuration bk_factory_init(); } ``` -------------------------------- ### Disable BK Server Agent Startup Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/thirdparty/volc/index.md Set this configuration to 'n' to disable starting the Agent from the BK server and enable starting from a custom server. This is typically done in the VolcEngine RTC project configuration file. ```default # Disable starting Agent from BK server (enabled by default) # CONFIG_STARTUP_AGENT_FROM_BK_SERVER is not set ``` -------------------------------- ### audio_engine_init Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/projects/beken_genie/README.md Initializes the audio engine. ```APIDOC ## audio_engine_init ### Description Initialize audio engine. ### Return Value - **bk_err_t** - Operation result ``` -------------------------------- ### Parse Agent Information after Server Agent Start Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/projects/beken_genie/index.md Parses return parameters, such as channel name, received after the server starts the agent. This is used to initiate device-side RTC and save the channel name. Requires cJSON library. ```c void bk_sconf_prase_agent_info(char *payload, uint8_t reset) { cJSON *json = NULL; char *tmp_channel = NULL; json = cJSON_Parse(payload); if (!json) { BK_LOGE(TAG, "Error before: [%s]\n", cJSON_GetErrorPtr()); return; } cJSON *channel_name = cJSON_GetObjectItem(json, "channel_name"); if (channel_name && ((channel_name->type & 0xFF) == cJSON_String)) { tmp_channel = channel_name->valuestring; BK_LOGI(TAG, "real channel name:%s\r\n", tmp_channel); } else { BK_LOGE(TAG, "[Error] not find msg\n"); } LOGI("%s %d, bk_sconf_prase_agent_info, tmp_channel:%s\r\n", __func__, __LINE__, tmp_channel); bk_sconf_start_network_transfer(tmp_channel); bk_sconf_save_channel_name(tmp_channel); #if CONFIG_APP_EVT app_event_send_msg(APP_EVT_CLOSE_BLUETOOTH, 0); #endif cJSON_Delete(json); } ``` -------------------------------- ### Countdown Timer Control Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_countdown.md Provides functions to start and stop the countdown timer. Starting a timer initiates a countdown that, upon expiration, triggers a forced deep sleep. Stopping the timer destroys it, requiring a restart to re-enable. ```APIDOC ## start_countdown ### Description Creates and starts a oneshot timer. When the countdown expires, the system will automatically enter deep sleep mode. If the timer already exists, it will be reloaded with the new timeout value. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **time_ms** (uint32_t) - Required - Countdown duration in milliseconds ### Notes When the countdown expires, it triggers a forced deep sleep (RESET_SOURCE_FORCE_DEEPSLEEP). ## stop_countdown ### Description Stops and deletes the countdown timer, releasing associated resources. This function is safe to call even if the timer is not initialized or not running. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Notes After calling this function, the timer is completely destroyed. You need to call start_countdown() again to recreate it. ``` -------------------------------- ### Enable Video Engine Configuration Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/video_engine.md Enable the video engine by setting this Kconfig macro to 'y'. ```C // Enable video engine CONFIG_BK_VIDEO_ENGINE=y ``` -------------------------------- ### Advanced API Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/projects/volc_rtc/README.md APIs for starting and stopping the complete RTC and Agent service. ```APIDOC ## bk_byte_start ### Description Start complete RTC and Agent service. This function will mount the SD card file system (if License is enabled), start the AI Agent service, initialize the RTC engine, join the RTC room, and start audio/video transmission. ### Parameters - **device_id** (void *) - Device ID string. ### Return Value - int: Operation result. - BK_OK: Start successful. - BK_FAIL: Start failed. ### Notes - This is an advanced interface that will start both Agent and RTC. ### See Also - bk_byte_stop() ``` ```APIDOC ## bk_byte_stop ### Description Stop complete RTC and Agent service. This function will stop the RTC service, stop the AI Agent service, release room information memory, and unmount the SD card file system. ### Parameters - **device_id** (void *) - Device ID string. ### Return Value - int: Operation result. - BK_OK: Stop successful. - BK_FAIL: Stop failed. ### See Also - bk_byte_start() ``` -------------------------------- ### Initialize Video Engine Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/video_engine.md Initializes the video engine, including context, frame queue, camera, and transfer task. Configuration is read from CONFIG macros. Use this to set up the video engine for operation. ```C /** * @brief Initialize video engine (using default configuration) * * This function initializes video engine context, frame queue, opens camera, and starts transfer task. * Configuration is read from CONFIG_* macros. * * @return int * - AVDK_ERR_OK: Success * - AVDK_ERR_NOMEM: Out of memory * - Others: Error codes returned by sub-functions */ int video_engine_init(void); ``` -------------------------------- ### Get Network Type Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/network_transfer/README_CN.md Retrieve the current network type using ntwk_trans_get_network_type(). ```c network_type_t ntwk_trans_get_network_type(void); ``` -------------------------------- ### Initialize Audio Engine Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/projects/beken_genie/README.md Initializes the audio engine for the Beken Genie AI Solution. ```c /** * @brief Initialize audio engine * * @return bk_err_t Operation result */ bk_err_t audio_engine_init(void); ``` -------------------------------- ### Get Audio Encoder Type Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/components/network_transfer/README_CN.md Obtain the current audio encoder type with ntwk_trans_get_audio_encoder_type(). ```c audio_enc_type_t ntwk_trans_get_audio_encoder_type(void); ``` -------------------------------- ### led_driver_init Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/docs/bk7258/en/developer-guide/bk_led_blink.md Initializes the LED driver by setting up necessary mutexes and registering the red and green LEDs. ```APIDOC ## led_driver_init ### Description Initializes the LED driver. ### Method void ### Parameters None ### Remarks This function should be called before any other LED control functions. ``` -------------------------------- ### Agent Management API Source: https://github.com/bekencorp/bk_solution_ai/blob/release/v3.1.1/projects/volc_rtc/README.md APIs for managing the AI Agent service, including starting and stopping its operations. ```APIDOC ## bk_byte_agent_start ### Description Start AI Agent service. This function will select to start from BK server or custom server, send an HTTP request, parse the response to get room information, and fill the `room_info` structure. ### Parameters - **room_info** (byte_rtc_room_info_t *) - Output parameter. Function will fill App ID, Room ID, Token and other information. - **device_id** (void *) - Device ID string. ### Return Value - int: Operation result. - BK_OK: Start successful. - BK_FAIL: Start failed. ### Notes - Before calling this function, ensure that the network connection is normal. ### See Also - bk_byte_agent_stop() ``` ```APIDOC ## bk_byte_agent_stop ### Description Stop AI Agent service. This function will select to stop from BK server or custom server, send an HTTP request, and clean up local resources. ### Parameters - **room_info** (byte_rtc_room_info_t *) - Room information structure pointer. - **device_id** (void *) - Device ID string. ### Return Value - int: Operation result. - BK_OK: Stop successful. - BK_FAIL: Stop failed. ### See Also - bk_byte_agent_start() ```