### Start Mock WS Backend Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/solution/mimiclaw/README.md Install the required library and start the mock backend server on your PC. This allows for end-to-end testing of WS interactions before migrating agent loops. ```bash cd examples/solution/mimiclaw python3 -m pip install websockets python3 tools/mock_ws_backend.py --host 0.0.0.0 --port 8080 ``` -------------------------------- ### Navigate to NetHub Example Directory Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/nethub/docs/NetHubQuickBringup.md Change the current directory to the NetHub example directory to start the build process. ```bash cd examples/wifi/nethub ``` -------------------------------- ### Smart Audio Initialization and Playback Example Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/multimedia/smart_audio_bl616/README_en.md Initialize the playback control component with a callback function and start playing a network stream. This example also demonstrates checking the playback state and adjusting volume. ```c void main() { ...; /* Initialize the playback control component */ smtaudio_init(media_evt); ... /* Play the network stream using system sounds */ smtaudio_start(MEDIA_SYSTEM, "https://www.kozco.com/tech/LRMonoPhase4.mp3", 0, 1); ... /* Get the current status of the playback control component and control the volume. */ if (SMTAUDIO_STATE_MUTE != smtaudio_get_state()) { smtaudio_vol_up(10); } } ``` -------------------------------- ### Example: Start BLE Advertising Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/docs/zh/samples/atmoudle/atmoudle.md Example of starting BLE advertising for a server role after initialization. ```default AT+BLEINIT=2 // 角色:服务器 AT+BLEADVSTART ``` -------------------------------- ### Smart Audio Initialization and Playback Example Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/multimedia/smart_audio_bl616/README.md Demonstrates how to initialize the Smart Audio component, register an event callback, start playing network audio, and control volume based on the current state. ```c // 回调函数,会注册到播控组件中,用于接收播放事件 static void media_evt(int type, smtaudio_player_evtid_t evt_id) { switch (evt_id) { case SMTAUDIO_PLAYER_EVENT_START: /* 开始播放事件 */ ... break; case SMTAUDIO_PLAYER_EVENT_ERROR: /* 播放错误事件 */ ... break; case SMTAUDIO_PLAYER_EVENT_STOP: /* 播放结束事件 */ ... break; case SMTAUDIO_PLAYER_EVENT_PAUSE: /* 播放暂停事件 */ ... break; case SMTAUDIO_PLAYER_EVENT_RESUME: /* 恢复播放事件 */ ... break; case SMTAUDIO_PLAYER_EVENT_UNDER_RUN: /* 播放缓冲数据不足事件 */ ... break; case SMTAUDIO_PLAYER_EVENT_OVER_RUN: /* 播放缓冲数据溢出事件 */ ... break; default: break; } } void main() { ...; /* 初始化播控组件 */ smtaudio_init(media_evt); ... /* 使用系统声音播放网络流 */ smtaudio_start(MEDIA_SYSTEM, "https://www.kozco.com/tech/LRMonoPhase4.mp3", 0, 1); ... /* 获取当前播控组件状态,并控制音量 */ if (SMTAUDIO_STATE_MUTE != smtaudio_get_state()) { smtaudio_vol_up(10); } } ``` -------------------------------- ### Get Help Information Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/tools/harness-automation/doc/quickstart.rst Display help information for the start script, including available arguments and options. ```bash # bash ./start.sh -h ``` ```windows # windows command line start.bat -h ``` -------------------------------- ### LVGL Demos Main Application Structure Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/lvgl/lvgl_v9/demos/README.md Example `main` function demonstrating LVGL initialization, display setup, demo creation using `lv_demos_create`, and the main event loop with timer handling. ```c //! main.c #include "lvgl.h" #include "demos/lv_demos.h" ...static lv_display_t* hal_init(void) { lv_display_t* disp = NULL; ... /* TODO: init display and indev */ ... return disp; } int main(int argc, char ** argv) { lv_init(); lv_display_t* disp = hal_init(); if (disp == NULL) { LV_LOG_ERROR("lv_demos initialization failure!"); return 1; } if (!lv_demos_create(&argv[1], argc - 1)) { lv_demos_show_help(); goto demo_end; } while (1) { uint32_t delay = lv_timer_handler(); if (delay < 1) delay = 1; /*delay for at least 1 ms*/ else if(delay == LV_NO_TIMER_READY) delay = LV_DEF_REFR_PERIOD; /*handle LV_NO_TIMER_READY. Another option is to `sleep` for longer*/ usleep(delay * 1000); } demo_end: lv_deinit(); return 0; } ``` -------------------------------- ### Start wpa_supplicant with Debugging on Windows Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/wifi6/wpa_supplicant/wpa_supplicant/README-Windows.txt Example command to start wpa_supplicant on Windows, specifying the interface, configuration file, and enabling debugging output. The interface name can be derived from win_if_list.exe output. ```bash wpa_supplicant.exe -i'{769E012B-FD17-4935-A5E3-8090C38E25D2}' -c wpa_supplicant.conf -d ``` -------------------------------- ### Install MQTT-C Library and Includes Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lib/mqtt/MQTT-C/CMakeLists.txt Installs the MQTT-C library to the system's library directory and its include files to the system's include directory. This setup is essential for making the MQTT-C library available for use in other projects. ```cmake install(TARGETS mqttc DESTINATION ${CMAKE_INSTALL_LIBDIR} ) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ``` -------------------------------- ### BLE Scanning Example Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/samples/atmoudle/atmoudle.md Example sequence for initializing BLE as a client, starting a scan, and then stopping it. ```default AT+BLEINIT=1 // 角色:客户端 AT+BLESCAN=1 // 开始扫描 AT+BLESCAN=0 // 停止扫描 ``` -------------------------------- ### Create Installation Directories Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/wifi6/wpa_supplicant/hs20/server/hs20-osu-server.txt Sets up the necessary directories for the OSU server installation. ```bash sudo mkdir -p /home/user/hs20-server sudo chown $USER /home/user/hs20-server mkdir -p /home/user/hs20-server/spp mkdir -p /home/user/hs20-server/AS ``` -------------------------------- ### Build MQuickJS Example Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/mquickjs/README.md Navigate to the example directory and build the project for the specified chip and board. ```bash cd examples/mquickjs make CHIP=bl616 BOARD=bl616dk ``` -------------------------------- ### Install Make Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/get_started/get_started.md Install the make utility using the apt package manager. ```bash $ cd ~ $ sudo apt install make -y ``` -------------------------------- ### Audio Recording and Streaming Setup Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/multimedia/xrecord/README.md Initializes and starts multiple audio recording streams, each with a unique identifier and saving to a specified URL. This function sets up ring buffers, tasks for writing data, and registers callbacks for data handling. ```C #include "app_config.h" #include #include #include #include #include #include "audio/test2.wav.c" #include static const char *TAG = "appwsrec"; #define PIECE_SIZE (2560 * 1) #define RINGBUFFER_SIZE (PIECE_SIZE * 50 + 1) typedef struct _rec_mgr { dev_ringbuf_t ringbuffer; char *rbuffer; int piece_size; int src_data_r_pos; int quit; msp_event_t wait_evt; rec_hdl_t hdl; int over_print; } rec_mgr_t; #define REC_MGR_COUT 3 rec_mgr_t *g_rec_mgr[REC_MGR_COUT]; static void write_data_task(void *arg) { rec_mgr_t *rec_mgr = (rec_mgr_t *)arg; while(!rec_mgr->quit) { if (rec_mgr->src_data_r_pos + rec_mgr->piece_size > sizeof(local_audio_test2)) { int remain_len = sizeof(local_audio_test2) - rec_mgr->src_data_r_pos; if (remain_len > 0) { ringbuffer_write(&rec_mgr->ringbuffer, (uint8_t *)&local_audio_test2[rec_mgr->src_data_r_pos], remain_len); rec_mgr->src_data_r_pos += remain_len; LOGD(TAG, "last piece"); } else { if (rec_mgr->over_print == 0) { LOGD(TAG, "write finish [%d]", rec_mgr->src_data_r_pos); rec_mgr->over_print = 1; } } } else { ringbuffer_write(&rec_mgr->ringbuffer, (uint8_t *)&local_audio_test2[rec_mgr->src_data_r_pos], rec_mgr->piece_size); rec_mgr->src_data_r_pos += rec_mgr->piece_size; // LOGD(TAG, "write 2 ringbuffer, %d, 0x%x", rec_mgr->piece_size, arg); } if (ringbuffer_available_read_space(&rec_mgr->ringbuffer) > 0) msp_event_set(&rec_mgr->wait_evt, 0x01, MSP_EVENT_OR); msp_msleep(80); } } static void data_ready(void *arg) { unsigned int flags; rec_mgr_t *rec_mgr = (rec_mgr_t *)arg; // LOGD(TAG, "read wait..."); msp_event_get(&rec_mgr->wait_evt, 0x01, MSP_EVENT_OR_CLEAR, &flags, MSP_WAIT_FOREVER); } static void data_release(void *arg) { if (arg) { rec_mgr_t *rec_mgr = (rec_mgr_t *)arg; msp_event_set(&rec_mgr->wait_evt, 0x01, MSP_EVENT_OR); } } void app_ws_rec_start(const char *url, const char *save_name) { for (int i = 0; i < REC_MGR_COUT; i++) { rec_mgr_t *rec_mgr = msp_zalloc_check(sizeof(rec_mgr_t)); rec_mgr->src_data_r_pos = 0; rec_mgr->piece_size = PIECE_SIZE; rec_mgr->rbuffer = msp_malloc_check(RINGBUFFER_SIZE); ringbuffer_create(&rec_mgr->ringbuffer, rec_mgr->rbuffer, RINGBUFFER_SIZE); rec_mgr->quit = 0; msp_task_new("ws-rec-w", write_data_task, (void *)rec_mgr, 4096); msp_event_new(&rec_mgr->wait_evt, 0); char buf[64]; snprintf(buf, sizeof(buf), "ringbuffer://handle=%u", &rec_mgr->ringbuffer); char buf2[128]; time_t tt = time(NULL); if (i == 0) { snprintf(buf2, sizeof(buf2), "%s/%d_%s_%s" ,url, tt, "mic", save_name); } else if (i == 1) { snprintf(buf2, sizeof(buf2), "%s/%d_%s_%s" ,url, tt, "ref", save_name); } else if (i == 2) { snprintf(buf2, sizeof(buf2), "%s/%d_%s_%s" ,url, tt, "proc", save_name); } rec_hdl_t hdl = record_register(buf, buf2); record_set_data_ready_cb(hdl, data_ready, (void *)rec_mgr); record_set_data_release_cb(hdl, data_release, (void *)rec_mgr); record_set_chunk_size(hdl, rec_mgr->piece_size); record_start(hdl); rec_mgr->hdl = hdl; g_rec_mgr[i] = rec_mgr; LOGD(TAG, "start mic rec [%d]\n", i); } } ``` -------------------------------- ### Build and Install hostapd and hs20_spp_server Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/wifi6/wpa_supplicant/hs20/server/hs20-osu-server.txt Compiles hostapd and hs20_spp_server, then copies them to the designated installation path. ```bash make hostapd hlr_auc_gw cp hostapd hlr_auc_gw /home/user/hs20-server/AS ``` ```bash cd ../hs20/server make clean make cp hs20_spp_server /home/user/hs20-server/spp ``` -------------------------------- ### Install Executables and Programs Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls/programs/psa/CMakeLists.txt Installs the built executables to the 'bin' directory with specified permissions and installs shell scripts. ```cmake install(TARGETS ${executables} DESTINATION "bin" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) install(PROGRAMS key_ladder_demo.sh DESTINATION "bin") ``` -------------------------------- ### Start HTTP OTA Server Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/sta/wifi_ota_by_http/README.md Start a simple HTTP server in the directory containing the OTA binary file. ```bash $ python3 https.py ``` -------------------------------- ### Build and Run Generic Example Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lib/libpeer/README.md Steps to clone the library, build the project, download test media, and run the generic example with a provided URL. ```bash sudo apt -y install git cmake git clone --recursive https://github.com/sepfy/libpeer cd libpeer cmake -S . -B build && cmake --build build wget http://www.live555.com/liveMedia/public/264/test.264 # Download test video file wget https://mauvecloud.net/sounds/alaw08m.wav # Download test audio file ./examples/generic/sample -u ``` -------------------------------- ### Start MQTT Broker with SSL Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/sta/wifi_mqtt/README_ssl.md Start the Mosquitto MQTT broker using a specified SSL configuration file. ```bash mosquitto -c ssl/mos.conf ``` -------------------------------- ### Example: Stop BLE Advertising Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/docs/zh/samples/atmoudle/atmoudle.md Example sequence to start and then stop BLE advertising for a server role. ```default AT+BLEINIT=2 // 角色:服务器 AT+BLEADVSTART AT+BLEADVSTOP ``` -------------------------------- ### Perform CoAP GET Request Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/src/cli/README_COAP.md Initiate a CoAP GET request to a specified IPv6 address and resource URI. This example shows a basic GET request. ```bash > coap get fdde:ad00:beef:0:d395:daee:a75:3964 test-resource Done coap response from [fdde:ad00:beef:0:2780:9423:166c:1aac] with payload: 30 ``` -------------------------------- ### Example: Get HTTP Data in Passive Mode Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/samples/atmoudle/atmoudle.md Example demonstrating how to set passive receive mode and then retrieve data using AT+HTTPRECVDATA. ```text AT+HTTPRECVMODE=1 // For example, the host MCU receives a notification of 100 bytes of data in connection 0, the message is "+HTTPC:0,100". // You can read these 100 bytes of data with the following command: AT+HTTPRECVDATA=0,100 ``` -------------------------------- ### Build the SoftAP WiFi Configuration Demo Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/sta/smartconfig_softap/README.md Navigate to the demo directory and use 'make' to build the project for the specified chip and board. ```bash cd examples/wifi/sta/smartconfig_softap make CHIP=bl602 BOARD=bl602dk ``` -------------------------------- ### Example Registry Import File for wpasvc.exe Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/wifi6/wpa_supplicant/wpa_supplicant/README-Windows.txt This file (win_example.reg) provides an example of how to set up wpasvc.exe parameters in the Windows registry. It can be imported as a starting point for configuration. ```plaintext See win_example.reg for an example on how to setup wpasvc.exe parameters in registry. It can also be imported to registry as a starting point for the configuration. ``` -------------------------------- ### Compile with Make Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/get_started/get_started.md Navigate to the example directory and use the 'make' command with specified chip and board names to compile the project. ```bash $ cd examples/helloworld $ make CHIP=chip_name BOARD=board_name ## chip_name 为芯片型号,可以填写 bl702、bl616、bl808、bl606p, board_name 为开发板名称,详见 bsp/board 目录 ``` -------------------------------- ### Enable Examples During Configuration Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/multimedia/libfvad/README.md Optional flag to enable example programs during the configure step. Requires libsndfile development files. ```bash ./configure --enable-examples ``` -------------------------------- ### HTTP Test GET and POST Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/sta/wifi_http/README.md Connect to a Wi-Fi router using the `wifi_sta_connect` command, then use `wifi_http_test` to perform HTTP GET and POST requests to a specified URL. This example demonstrates fetching a page from www.gov.cn. ```bash bouffalolab />wifi_sta_connect BL_TEST 12345678 bouffalolab />wifi_http_test http://www.gov.cn ... Http client GET request server success ... Http client POST request server success ``` -------------------------------- ### Initialize and Use libSRTP Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lib/srtp/libsrtp/README.md A basic C example demonstrating the initialization of libSRTP, setting up a policy with a master key and salt, and protecting RTP packets in a loop. ```c srtp_t session; srtp_policy_t policy; // Set key to predetermined value uint8_t key[30] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D}; // initialize libSRTP srtp_init(); // default policy values memset(&policy, 0x0, sizeof(srtp_policy_t)); // set policy to describe a policy for an SRTP stream srtp_crypto_policy_set_rtp_default(&policy.rtp); srtp_crypto_policy_set_rtcp_default(&policy.rtcp); policy.ssrc = ssrc; policy.key = key; policy.next = NULL; // allocate and initialize the SRTP session srtp_create(&session, &policy); // main loop: get rtp packets, send srtp packets while (1) { char rtp_buffer[2048]; unsigned len; len = get_rtp_packet(rtp_buffer); srtp_protect(session, rtp_buffer, &len); send_srtp_packet(rtp_buffer, len); } ``` -------------------------------- ### Install Smart Audio Component Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/multimedia/smart_audio_bl616/README.md Use 'yoc init' to initialize a project and 'yoc install smart_audio' to add the component. ```bash yoc init yoc install smart_audio ``` -------------------------------- ### Compile helloworld for BL616C/CL Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/README.md Navigate to the demo directory and execute the make command with the appropriate chip and board configurations. This is an example for BL616C/CL. ```bash cd examples/helloworld make CHIP=bl616 BOARD=bl616dk ``` -------------------------------- ### Example TWT Setup: 32.768 ms SP, 8.192 sec Wake Interval Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/spi_wifi/README.md Example command to set up TWT with a Service Period of 32.768 ms and a Wake Interval of 8.192 seconds. This command is used in a hostless environment. ```shell wifi_mgmr_sta_twt_setup -s 1 -t 1 -e 13 -n 128 -m 1000 ``` -------------------------------- ### CoAPS Client: Connect, Get, and Put Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/src/cli/README_COAPS.md On a CoAPS client node, start CoAPS, connect to a peer, retrieve a resource, and update it. ```bash > coaps start Done > coaps connect Done coaps connected > coaps get test-resource Done coaps response from fdde:ad00:beef:0:9903:14b:27e0:5744 with payload: 68656c6c6f576f726c6400 > coaps put test-resource con payload Done coaps response from fdde:ad00:beef:0:9903:14b:27e0:5744 ``` -------------------------------- ### Project Configuration with menuconfig Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/CLAUDE.md Illustrates how to launch the graphical configuration interface for the project, similar to Linux's Kconfig system. ```bash # 打开配置菜单 make menuconfig CHIP=bl616 BOARD=bl616dk ``` -------------------------------- ### Setup pyspinel Environment Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/thread/openthread_ncp/README.md Installs necessary Python modules and clones the pyspinel repository. Pyspinel is used for managing OpenThread NCPs/RCPs. ```shell # Install python modules pip3 install --user pyserial ipaddress # Clone pyspinel git clone https://github.com/openthread/pyspinel.git ``` -------------------------------- ### Key Derivation Driver Setup Entry Point Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/proposed/psa-driver-interface.md Implement this entry point to initialize a key derivation operation. Ensure the operation object is zero-initialized before passing it. ```c psa_status_t acme_key_derivation_setup( acme_key_derivation_operation_t *operation, psa_algorithm_t alg, const psa_crypto_driver_key_derivation_inputs_t *inputs); ``` -------------------------------- ### Get IP Addresses on OTCLI Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/thread/openthread_wifi_br/README.md After starting the Thread network, retrieve the IP addresses assigned to the OTCLI. This includes both Thread-specific and link-local IPv6 addresses. ```shell bouffalolab />otc ipaddr ipaddr fdef:ca56:3b51:5bf4:0:ff:fe00:6000 fd41:20be:97bf:1:c017:4b66:f036:eb1a fdef:ca56:3b51:5bf4:a79:f4bc:cd40:d915 fe80:0:0:0:bc2a:4222:ded0:7032 Done ``` -------------------------------- ### Compile helloworld for BL602 Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/README.md Navigate to the demo directory and execute the make command with the appropriate chip and board configurations. This is an example for BL602. ```bash cd examples/helloworld make CHIP=bl602 BOARD=bl602dk ``` -------------------------------- ### Get WiFi TWT Status Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/pmu/wl_ble_lp/README.md Retrieve the status of negotiated TWT flows. This is useful for verifying TWT setup and identifying flow IDs for teardown. ```bash wifi_mgmr_sta_twt_statusget ``` -------------------------------- ### Flash with Command Line Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/get_started/get_started.md Navigate to the example directory and use the 'make flash' command with the chip name and COM port to flash the device. ```bash $ cd examples/helloworld $ make flash CHIP=chip_name COMX=port_name ## port_name 为串口号名称 ``` -------------------------------- ### TCP Client Test Setup Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/sta/wifi_tcp/README.md On a Linux host, start netcat to listen on port 3365. Then, on the BL device, connect to your WiFi and initiate the TCP client test. ```bash $ nc -lp 3365 ``` ```bash bouffalolab />wifi_sta_connect BL_TEST 12345678 bouffalolab />wifi_tcp_test 192.168.1.2 3365 bouffalolab />tcp client task start ... Server ip Address : 192.168.1.2:3365 TCP client connect server success! Press CTRL-C to exit. ``` -------------------------------- ### Compile helloworld for BL702L/BL704L Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/README.md Navigate to the demo directory and execute the make command with the appropriate chip and board configurations. This is an example for BL702L/BL704L. ```bash cd examples/helloworld make CHIP=bl702l BOARD=bl702ldk ``` -------------------------------- ### Basic and Ninja Build Commands Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/CLAUDE.md Demonstrates how to initiate a basic build using 'make' and a faster build using 'ninja'. Includes commands for multi-core chip builds. ```bash # 进入示例目录并构建 cd examples/helloworld make CHIP=bl616 BOARD=bl616dk # 使用 ninja 构建(更快) make ninja CHIP=bl616 BOARD=bl616dk # 多核芯片构建(BL618DG) make CHIP=bl618dg BOARD=bl618dgdk CPU_ID=ap # AP 核心 make CHIP=bl618dg BOARD=bl618dgdk CPU_ID=np # NP 核心 ``` -------------------------------- ### TCP Server Echo Test Setup Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/sta/wifi_tcp/README.md On the BL device, connect to WiFi and start the TCP server echo test on port 3365. On the host PC, connect to the BL device's IP address and port using netcat. ```bash bouffalolab />wifi_sta_connect BL_TEST 12345678 bouffalolab />wifi_tcp_echo_test 3365 bouffalolab />tcp server task start ... Server ip Address : 0.0.0.0:3365 # host pc connected log new client connected from (192.168.1.2, 57480) Press CTRL-C to exit. recv 7 len data ``` ```bash $ nc -v 192.168.1.3 3365 Connection to 192.168.1.3 3365 port [tcp/*] succeeded! 123456 # enter something 123456 # echo received data ``` -------------------------------- ### MQTT Client Initialization and Connection Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lwip/lwip/doc/mqtt_client.txt Demonstrates how to initialize an MQTT client, either statically or dynamically, and establish a connection to an MQTT broker. ```APIDOC ## MQTT Client Initialization and Connection ### Description This section covers the initial steps required to use the MQTT client, including memory allocation and establishing a connection to the MQTT server. ### Static Allocation ```c mqtt_client_t static_client; example_do_connect(&static_client); ``` ### Dynamic Allocation ```c mqtt_client_t *client = mqtt_client_new(); if(client != NULL) { example_do_connect(&client); } ``` ### Establishing Connection ```c void example_do_connect(mqtt_client_t *client) { struct mqtt_connect_client_info_t ci; err_t err; /* Setup an empty client info structure */ memset(&ci, 0, sizeof(ci)); /* Minimal amount of information required is client identifier, so set it here */ ci.client_id = "lwip_test"; /* Initiate client and connect to server, if this fails immediately an error code is returned otherwise mqtt_connection_cb will be called with connection result after attempting to establish a connection with the server. For now MQTT version 3.1.1 is always used */ err = mqtt_client_connect(client, ip_addr, MQTT_PORT, mqtt_connection_cb, 0, &ci); /* For now just print the result code if something goes wrong */ if(err != ERR_OK) { printf("mqtt_connect return %d\n", err); } } ``` ### Checking Connection Status ```c /* Connection to server can also be probed by calling mqtt_client_is_connected(client) */ ``` ``` -------------------------------- ### Example of Inadequate Pointer Arithmetic (Subtraction) Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lib/srtp/libsrtp/fuzzer/README.md This C code illustrates a scenario where pointer arithmetic subtraction might lead to issues. The condition 'end - n > start' could be incorrectly evaluated if 'n' is large, potentially causing problems. ```c if ( end - n > start ) { ``` -------------------------------- ### Initialize and Run Music Demo Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/lvgl/lvgl_v8_with_osd/demos/music/README.md After initializing LVGL and its drivers, call the lv_demo_music() function to start the music player demo. ```c lv_init(); // Initialize drivers // ... lv_demo_music(); ``` -------------------------------- ### Example of Inadequate Pointer Arithmetic (Addition) Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lib/srtp/libsrtp/fuzzer/README.md This C code demonstrates a potential pointer arithmetic overflow. If 'n' is large enough, the addition 'start + n' can overflow, causing the 'memset' to operate on an unintended memory region, potentially leading to a page fault. ```c if ( start + n < end ) { memset(start, 0, n); } ``` -------------------------------- ### Configure AP with Vendor Elements Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/api_reference/wifi6.md Example demonstrating how to start a WiFi AP with custom vendor-specific elements in the Beacon frames. Ensure the `ap_vendor_elements` string is a continuous raw IE hex string without prefixes or separators, adhering to the SDK's length limitations. ```C void demo_start_ap_with_vendor_elements(void) { wifi_mgmr_ap_params_t config = { 0 }; config.ssid = "bl_ap_vendor"; config.key = "12345678"; config.akm = "WPA2"; config.channel = 6; config.use_ipcfg = true; config.use_dhcpd = true; /* * ap_vendor_elements 是连续 raw IE hex string。不要添加 * "0x"、空格或 ':' 分隔符。SDK 内部会自动添加 * "SET ap_vendor_elements "。 * * 单个 Vendor Specific IE 示例: * dd0411223301 * * IE 结构: * dd element id,0xdd 表示 Vendor Specific IE * 04 payload 长度,表示 length 字段后还有 4 字节 * 112233 OUI * 01 vendor data * * 支持多个 IE。直接拼接完整 IE hex string: * dd0411223301dd05aabbcc0203 * * 多 IE 结构: * dd0411223301 IE1,payload 长度为 4 字节 * dd05aabbcc0203 IE2,payload 长度为 5 字节 * * 当前 SDK 限制为 strlen(ap_vendor_elements) <= 564, * 约等于 282 字节原始 IE 数据。 */ config.ap_vendor_elements = "dd0411223301"; wifi_mgmr_ap_start(&config); } ``` -------------------------------- ### Start wpasvc Service Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/wifi6/wpa_supplicant/wpa_supplicant/README-Windows.txt Start the wpa_supplicant service using the 'net start' command. ```bash net start wpasvc ``` -------------------------------- ### Build MQTT-C Unit Tests and Examples Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lib/mqtt/MQTT-C/README.md Use the provided Makefile to build all unit tests and examples for MQTT-C on UNIX-like systems. The output will be placed in the 'bin/' directory. ```bash $ make all ``` -------------------------------- ### Install Poetry Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/tools/tcat_ble_client/README.md Install the poetry module if it is not already installed. This is a prerequisite for managing project dependencies. ```bash python3 -m pip install poetry ``` -------------------------------- ### Example: Enable multi-connection mode Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/docs/zh/samples/atmoudle/atmoudle.md Example command to set the AT+CIPMUX mode to 1, enabling multi-connection support. ```default AT+CIPMUX=1 ``` -------------------------------- ### Compile with Ninja Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/get_started/get_started.md Navigate to the example directory and use the 'make ninja' command with specified chip and board names to compile the project using Ninja. ```bash $ cd examples/helloworld $ make ninja CHIP=chip_name BOARD=board_name ## chip_name 为芯片型号,可以填写 bl702、bl616、bl808、bl606p, board_name 为开发板名称,详见 bsp/board 目录 ``` -------------------------------- ### start Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/src/cli/README_COMMISSIONER.md Starts the commissioner service. ```APIDOC ## start ### Description Start the commissioner service. ### Usage `commissioner start` ``` -------------------------------- ### Start Mimiclaw Agent Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/solution/mimiclaw/README.md Start the Mimiclaw agent. This command initiates the local agent path and starts Telegram polling once Wi-Fi is ready. ```text mimiclaw_start ``` -------------------------------- ### Initialize Wi-Fi Control Configuration Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/bsp/common/msg_router/linux_host/userspace/nethub/bflbwifictrl/README.md Demonstrates the common initialization flow for the Wi-Fi control library, including configuration setup and backend selection. ```c bflbwifi_ctrl_config_t cfg; bflbwifi_ctrl_config_init(&cfg); bflbwifi_ctrl_config_use_vchan(&cfg); bflbwifi_init_ex(&cfg); ``` -------------------------------- ### Example: Establish BLE Connection Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/docs/zh/samples/atmoudle/atmoudle.md Example of initializing BLE as a client and establishing a connection to a specific remote address with a timeout. ```default AT+BLEINIT=1 // 角色:客户端 AT+BLECONN=0,"11:22:33:44:55:66",0,10 ``` -------------------------------- ### Install lcov and genhtml on Ubuntu/Debian Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/sta/wifi_gcov_dump/GCOV_README.md Installs the lcov tool for coverage analysis and genhtml for generating HTML reports. Firefox is an optional browser installation. ```bash sudo apt-get install lcov # Install browser (optional) sudo apt-get install firefox ``` -------------------------------- ### Flash MQuickJS Example Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/mquickjs/README.md Flash the built example to the target board using the specified chip and communication port. ```bash make flash CHIP=bl616 COMX=/dev/ttyUSB0 ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/tools/harness-automation/doc/quickstart.rst Install the required Python libraries for the harness automation using the provided requirements file. Ensure Python 2.7 is installed. ```bash pip install -r requirements.txt ``` -------------------------------- ### Build and Install libfvad Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/multimedia/libfvad/README.md Standard commands to configure, build, and install the libfvad library using autoconf/automake. Ensure build dependencies are installed first. ```bash ./configure make sudo make install ``` -------------------------------- ### Initialize and Connect MQTT Client Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lib/mqtt/MQTT-C/README.md Instantiate and initialize an MQTT client structure, then establish a connection to an MQTT broker. ```c struct mqtt_client client; /* instantiate the client */ mqtt_init(&client, ...); /* initialize the client */ mqtt_connect(&client, ...); /* send a connection request to the broker. */ ``` -------------------------------- ### Start Scanning Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/api_reference/ble.md Starts BLE scanning for advertising devices. ```APIDOC ## ble_start_scan ### Description Starts BLE scanning for advertising devices. ### Method CLI Command ### Parameters - **scan_type** (int) - Required - Scan type: 0 (passive: only listen to broadcast data), 1 (active: listen and send scan_req if conditions met). - **filter_policy** (int) - Required - Filter policy for broadcast packets: 0 (no duplicate filtering), 1 (enable duplicate filtering), 2 (only receive from whitelist, except adv_direct_ind to own address), 4 (use extended filtering). - **scan_interval** (int) - Required - Scan interval (0.625ms * N, range: 2.5ms to 10.24s, should be >= scan_window). - **scan_window** (int) - Required - Scan window (0.625ms * N, range: 2.5ms to 10.24s, should be <= scan_interval). ### Example ``` ble_start_scan 0 0 0x80 0x40 ``` ``` -------------------------------- ### Compile and Program WiFi TCP Example Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/samples/wifi6/wifi_tcp.md Navigate to the wifi_tcp example directory and compile the project using make. Ensure your Makefile has CHIP and BOARD parameters configured. ```bash cd examples/wifi/sta/wifi_tcp make ``` -------------------------------- ### Start Advertising Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/api_reference/ble.md Starts BLE advertising with specified parameters. ```APIDOC ## ble_start_adv ### Description Starts BLE advertising with specified parameters. ### Method CLI Command ### Parameters - **adv_type** (int) - Required - Advertising type: 0 (adv_ind: connectable, scannable), 1 (adv_scan_ind: non-connectable, scannable), 2 (adv_nonconn_ind: non-connectable, non-scannable), 3 (adv_direct_ind: connectable to specific device, non-scannable). - **adv_mode** (int) - Required - Advertising mode: 0 (General discoverable), 1 (Non-discoverable), 2 (Limited discoverable). - **min_interval** (int) - Required - Minimum advertising interval (0.625ms * N, range: 20ms to 10.24s). - **max_interval** (int) - Required - Maximum advertising interval (0.625ms * N, range: 20ms to 10.24s). ### Example ``` ble_start_adv 0 0 0x80 0x80 ``` ``` -------------------------------- ### Start Channel Monitor Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/src/cli/README.md Starts the channel monitor. Requires OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE. ```bash > channel monitor start channel monitor start Done ``` -------------------------------- ### Platform-Specific Installation Directories Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/net/lib/mqtt/MQTT-C/CMakeLists.txt Sets up installation directories for libraries and headers, handling differences between Unix-like systems and others. ```cmake if(UNIX) include(GNUInstallDirs) mark_as_advanced(CLEAR CMAKE_INSTALL_BINDIR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR) else() set(CMAKE_INSTALL_LIBDIR "lib") set(CMAKE_INSTALL_INCLUDEDIR "include") endif() ``` -------------------------------- ### Start CoAP Service Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/src/cli/README_COAP.md Starts the application's CoAP service. ```APIDOC ## start ### Description Starts the application's CoAP service. ### Method POST ### Endpoint `/start` ### Request Example ```bash > coap start ``` ### Response #### Success Response (200) Indicates the CoAP service has started successfully. #### Response Example ``` Done ``` ``` -------------------------------- ### Enable Benchmark Demo Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/solution/solution_dualcore/wifi_np/app/src/lv_demos/benchmark/README.md To run the benchmark demo, enable it in the configuration file and call the `lv_demo_benchmark()` function after initializing LVGL and drivers. ```c #define LV_USE_DEMO_BENCHMARK 1 // ... after lv_init() and driver initialization lv_demo_benchmark(); ``` -------------------------------- ### Build NetHub for BL616 Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/examples/wifi/nethub/README.md Build the NetHub example for the BL616 chip. Ensure you are in the examples/wifi/nethub directory. ```bash cd examples/wifi/nethub # BL616 make CHIP=bl616 BOARD=bl616dk ``` -------------------------------- ### Start CoAPS Server Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/src/cli/README_COAPS.md Starts the CoAPS server on the current node. ```APIDOC ## coaps start ### Description Starts the CoAPS server. ### Request Example ```bash > coaps start Done ``` ``` -------------------------------- ### CoAP CLI Start Server Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/src/cli/README_COAP.md Starts the CoAP server on the device. ```APIDOC ## start ### Description Starts the CoAP server on the device. ### Method `coap start` ### Example ```bash > coap start Done ``` ``` -------------------------------- ### Key Derivation Driver Setup Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/crypto/mbedtls/mbedtls_v3/docs/proposed/psa-driver-interface.md The entry point for initializing a key derivation operation. It takes the operation object, algorithm, and initial inputs. ```APIDOC ## acme_key_derivation_setup ### Description Initializes a key derivation operation. ### Signature ```c psa_status_t acme_key_derivation_setup( acme_key_derivation_operation_t *operation, psa_algorithm_t alg, const psa_crypto_driver_key_derivation_inputs_t *inputs); ``` ### Parameters * `operation`: A zero-initialized operation object. * `alg`: The algorithm for the key derivation operation (does not include a key agreement component). * `inputs`: An opaque pointer to the initial inputs for the key derivation. ``` -------------------------------- ### Launch Testbed Configuration Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/tools/harness-simulation/README.md Execute this command on the POSIX machine to start OT FTD simulations, OTBR simulations, and sniffer simulations based on the provided configuration file. ```bash $ ./launch_testbed.py -c config.yml ``` -------------------------------- ### TCAT Start Command Source: https://github.com/bouffalolab/bouffalo_sdk/blob/master/components/wireless/thread/openthread/src/cli/README_TCAT.md Starts the TCAT server and enables BLE advertisement. ```APIDOC ## start ### Description Starts the TCAT server and BLE advertisement. ### Usage tcat start ### Example ```bash tcat start Done ``` ```