From: kyz Date: Wed, 5 Jul 2023 02:00:55 +0000 (+0800) Subject: 增加中间件测试程序 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=ebee2269b743d90999388d0c7e50853223463418;p=yn%2Falarmmonitor.git 增加中间件测试程序 --- diff --git a/als/CMakeLists.txt b/als/CMakeLists.txt index 6a76d9b..15e9acc 100644 --- a/als/CMakeLists.txt +++ b/als/CMakeLists.txt @@ -22,3 +22,5 @@ add_library( ${PROJECT_NAME} STATIC ${SRCS} ) #install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION /app/lib ) #install( TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /app/lib ) +install(FILES ${PROJECT_SOURCE_DIR}/test/als_test DESTINATION /app/test/ ) +install(FILES ${PROJECT_SOURCE_DIR}/test/als_test.txt DESTINATION /app/test/ ) diff --git a/als/test/als_test b/als/test/als_test new file mode 100755 index 0000000..c922ab9 Binary files /dev/null and b/als/test/als_test differ diff --git a/als/test/als_test.txt b/als/test/als_test.txt new file mode 100755 index 0000000..18cc6b8 --- /dev/null +++ b/als/test/als_test.txt @@ -0,0 +1,11 @@ +#将als_test_app测试程序push到板子中 + adb push als_test_app /app/ + chmod a+x als_test_app + +#测试测序中有默认阈值(1000,400),如果不重新设置阈值则采用默认阈值; + +#使用示例: + 1-采用默认阈值 + ./als_test_app + 2-重新设置阈值(上限阈值:500 下限阈值:200) + ./als_test_app 500 200 diff --git a/ble_wificonfig/Server/src/gatt-service.c b/ble_wificonfig/Server/src/gatt-service.c index d070fe1..5cb8f38 100644 --- a/ble_wificonfig/Server/src/gatt-service.c +++ b/ble_wificonfig/Server/src/gatt-service.c @@ -2049,6 +2049,9 @@ static void send_advertise( void ) char local_name[100]; char *uuids[] = { "uuids", AD_SERVICES_UUID, NULL }; + dbus_bool_t discoverable = TRUE; + ad_advertise_discoverable(connection, &discoverable); + sprintf( local_name, "ROCKCHIP-%s", dev_uuid_str() ); ad_advertise_local_name( connection, local_name ); diff --git a/button/CMakeLists.txt b/button/CMakeLists.txt index d217d59..8a24742 100644 --- a/button/CMakeLists.txt +++ b/button/CMakeLists.txt @@ -21,3 +21,18 @@ add_library( ${PROJECT_NAME} STATIC ${SRCS} ) #install( TARGETS ${PROJECT_NAME} RUNTIME DESTINATION /app/lib ) #install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION /app/lib ) #install( TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /app/lib ) + +link_directories( +) + +add_executable( button_test test/button.c ) +target_link_libraries( + button_test + PUBLIC + mg_button + mg_log + log4c + pthread +) + +install( TARGETS button_test RUNTIME DESTINATION /app/test ) diff --git a/button/test/button.c b/button/test/button.c new file mode 100644 index 0000000..5503662 --- /dev/null +++ b/button/test/button.c @@ -0,0 +1,88 @@ +#include +#include +#include "button.h" +#include "mg_log.h" + +char * btn_name[]={ + "BUTTON_1", + "BUTTON_2", + "BUTTON_3", + "BUTTON_4", + "BUTTON_5", + "BUTTON_6", + "BUTTON_7", + "BUTTON_8", +}; + +static char btn_code_str[100]; +static char btn_event_str[100]; +char * btn_code_name( uint32_t btn_code ) +{ + char *p; + p = btn_code_str; + *p = 0; + + if( btn_code&BUTTON_1 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_1" ); } + if( btn_code&BUTTON_2 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_2" ); } + if( btn_code&BUTTON_3 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_3" ); } + if( btn_code&BUTTON_4 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_4" ); } + if( btn_code&BUTTON_5 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_5" ); } + if( btn_code&BUTTON_6 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_6" ); } + if( btn_code&BUTTON_7 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_7" ); } + if( btn_code&BUTTON_8 ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "BUTTON_8" ); } + return p; +} + +char * btn_event_name( uint32_t btn_event ) +{ + char *p; + + p = btn_event_str; + *p = 0; + + if( btn_event&EVENT_SINGLE_CLICK ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_SINGLE_CLICK" ); } + if( btn_event&EVENT_DOUBLE_CLICK ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_DOUBLE_CLICK" ); } + if( btn_event&EVENT_LONG_PRESS ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_LONG_PRESS" ); } + if( btn_event&EVENT_LONG_PRESS_2S ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_LONG_PRESS_2S" ); } + if( btn_event&EVENT_LONG_PRESS_5S ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_LONG_PRESS_5S" ); } + if( btn_event&EVENT_LONG_PRESS_UP ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_LONG_PRESS_UP" ); } + if( btn_event&EVENT_COMB_PRESS ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_COMB_PRESS" ); } + if( btn_event&EVENT_COMB_PRESS_2S ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_COMB_PRESS_2S" ); } + if( btn_event&EVENT_COMB_PRESS_5S ){ if( strlen(p)) strcat( p, "+" ); strcat( p, "EVENT_COMB_PRESS_5S" ); } + + return p; +} + +static void button_single_cb( button_code_t btn_code, button_event_t btn_event, void* value ) +{ + printf( "Single BTN--code:[%s], event:[%s], value:%p\n", btn_code_name(btn_code), btn_event_name(btn_event), value ); +} + +static void button_comb_cb( button_code_t btn_code, button_event_t btn_event, void* value ) +{ + printf( "COMB BTN--code:%x, event:%x, value:%p\n", btn_code, btn_event, value ); +} + +int main( void ) +{ + btn_ctrl_t btn; + btn = mg_button_open("/dev/input/by-path/platform-gpio_keys-event" ); + if( !btn ){ + perror( "open button fail!\n" ); + exit(0); + } + + printf( "register all single button event!\n" ); + mg_button_event_register( btn, 0xFF, EVENT_SINGLE_CLICK|EVENT_DOUBLE_CLICK|EVENT_LONG_PRESS|EVENT_LONG_PRESS_UP, button_single_cb ); + printf( "register button_7+button_8 event!\n" ); + mg_button_event_combonation_register( btn, BUTTON_7|BUTTON_8, EVENT_COMB_PRESS_5S, 0, button_comb_cb ); + printf( "register button_2+button_7 event!\n" ); + mg_button_event_combonation_register( btn, BUTTON_2|BUTTON_7, EVENT_COMB_PRESS_2S, 0, button_comb_cb ); + + while(1){ + sleep(2); + } + mg_button_close( btn ); + exit(0); +} + diff --git a/buzzer/CMakeLists.txt b/buzzer/CMakeLists.txt index 85d1d8c..8ea122d 100644 --- a/buzzer/CMakeLists.txt +++ b/buzzer/CMakeLists.txt @@ -21,3 +21,6 @@ add_library( ${PROJECT_NAME} STATIC ${SRCS} ) #install( TARGETS ${PROJECT_NAME} RUNTIME DESTINATION /app/lib ) #install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION /app/lib ) #install( TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /app/lib ) + +install(FILES ${PROJECT_SOURCE_DIR}/test/buzzer_test DESTINATION /app/test/ ) +install(FILES ${PROJECT_SOURCE_DIR}/test/buzzer_test.txt DESTINATION /app/test/ ) diff --git a/buzzer/test/buzzer_test b/buzzer/test/buzzer_test new file mode 100755 index 0000000..90f764c Binary files /dev/null and b/buzzer/test/buzzer_test differ diff --git a/buzzer/test/buzzer_test.txt b/buzzer/test/buzzer_test.txt new file mode 100755 index 0000000..c8f8c05 --- /dev/null +++ b/buzzer/test/buzzer_test.txt @@ -0,0 +1,9 @@ +#将buzzer_test_app测试程序push到板子中 + adb push buzzer_test_app /app/ + chmod a+x buzzer_test_app + +#测试程序只会运行10s,10s之后就会退出 + +#使用示例: + 200:频率hz 50:占空比% 1000:播放时间ms + ./buzzer_test_app 200 50 1000 diff --git a/led/CMakeLists.txt b/led/CMakeLists.txt index efcfaa3..b83b85d 100644 --- a/led/CMakeLists.txt +++ b/led/CMakeLists.txt @@ -30,3 +30,14 @@ link_directories( ${PROJECT_SOURCE_DIR}/. ) #target_link_libraries( led_test PUBLIC rt pthread mg_led mg_log log4c rt pthread ) +add_executable( light_test test/light.c ) +target_link_libraries( + light_test + PUBLIC + mg_led + mg_log + log4c + pthread +) + +install( TARGETS light_test RUNTIME DESTINATION /app/test ) diff --git a/led/test/led_test.c b/led/test/led_test.c deleted file mode 100644 index d2e87bf..0000000 --- a/led/test/led_test.c +++ /dev/null @@ -1,23 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include "led.h" -#include "mg_log.h" -#include "pthread.h" -#include "semaphore.h" - -#include -#include -#include - -int main( void ) -{ - mg_led_ctrl_t * ctrl = mg_led_open(); - printf( "led test..., open led, ret:%p\n", ctrl ); - return 0; -} - diff --git a/led/test/light.c b/led/test/light.c new file mode 100644 index 0000000..7d9dd06 --- /dev/null +++ b/led/test/light.c @@ -0,0 +1,129 @@ + +#include +#include +#include +#include +#include +#include +#include "led.h" +#include "mg_log.h" +#include "pthread.h" +#include "semaphore.h" + +#include +#include +#include +#include + +#if 0 +char* usage_str = "" +"Usage: light_test [option] ...\n" +"Options:\n" +"\t -t, --type n -- 0:KEY LED 1:ATMOS LED 2:IR LED 3: RING LED\n" +"\t -i, --index n -- KEY LED:1-8, ATMOS LED:1-5, IR LED:0 RING LED:0\n" +"\t -o, --output n -- 0:off, 1:on, 2:flash, 3:breath, 4:slow on, 5slow off\n" +"\t --on_ms n -- \n" +"\t --off_ms n -- \n" +"\t --brightness n -- 0-100 \n" +"\t -h, --help\n" +"\n"; + + +void disp_usage( void ) +{ + printf( usage_str ); +} + +int lopt; +struct option opts[] = { + {"type", required_argument, 0, 't' }, + {"help", no_argument, NULL, 'h' }, + {}, + +}; +#endif + +int main( int argc, char ** argv ) +{ + light_ctrl_t light = mg_led_open(); + if( !light ){ + perror( "open led fail!\n" ); + exit(0); + } +printf( "open key led 1 ...\n" ); + key_led_on( light, LED_ID_KEY_1, 0, 100, 1000 ); + sleep(1); +printf( "open key led 2 ...\n" ); + key_led_off( light, LED_ID_KEY_1, 100, 0, 1000 ); + key_led_on( light, LED_ID_KEY_2, 0, 100, 1000 ); + sleep(1); +printf( "open key led 3 ...\n" ); + key_led_off( light, LED_ID_KEY_2, 100, 0, 1000 ); + key_led_on( light, LED_ID_KEY_3, 0, 100, 1000 ); + sleep(1); +printf( "open key led 4 ...\n" ); + key_led_off( light, LED_ID_KEY_3, 100, 0, 1000 ); + key_led_on( light, LED_ID_KEY_4, 0, 100, 1000 ); + sleep(1); +printf( "open key led 5 ...\n" ); + key_led_off( light, LED_ID_KEY_4, 100, 0, 1000 ); + key_led_on( light, LED_ID_KEY_5, 0, 100, 1000 ); + sleep(1); +printf( "open key led 6 ...\n" ); + key_led_off( light, LED_ID_KEY_5, 100, 0, 1000 ); + key_led_on( light, LED_ID_KEY_6, 0, 100, 1000 ); + sleep(1); +printf( "open key led 7 ...\n" ); + key_led_off( light, LED_ID_KEY_6, 100, 0, 1000 ); + key_led_on( light, LED_ID_KEY_7, 0, 100, 1000 ); + sleep(1); +printf( "open key led 8 ...\n" ); + key_led_off( light, LED_ID_KEY_7, 100, 0, 1000 ); + key_led_on( light, LED_ID_KEY_8, 0, 100, 1000 ); + sleep(1); + key_led_off( light, LED_ID_KEY_8, 100, 0, 1000 ); + +printf( "open atmos led 1 ...\n" ); + atmos_led_on( light, LED_ID_ATMOS_1, 0, 100, 1000 ); + sleep(1); +printf( "open atmos led 2 ...\n" ); + atmos_led_off( light, LED_ID_ATMOS_1, 100, 0, 1000 ); + atmos_led_on( light, LED_ID_ATMOS_2, 0, 100, 1000 ); + sleep(1); +printf( "open atmos led 3 ...\n" ); + atmos_led_off( light, LED_ID_ATMOS_2, 100, 0, 1000 ); + atmos_led_on( light, LED_ID_ATMOS_3, 0, 100, 1000 ); + sleep(1); +printf( "open atmos led 4 ...\n" ); + atmos_led_off( light, LED_ID_ATMOS_3, 100, 0, 1000 ); + atmos_led_on( light, LED_ID_ATMOS_4, 0, 100, 1000 ); + sleep(1); +printf( "open atmos led 5 ...\n" ); + atmos_led_off( light, LED_ID_ATMOS_4, 100, 0, 1000 ); + atmos_led_on( light, LED_ID_ATMOS_5, 0, 100, 1000 ); + sleep(1); + atmos_led_off( light, LED_ID_ATMOS_5, 100, 0, 1000 ); + +printf( "key led flash period 1s ...\n" ); + atmos_led_flash( light, LED_ID_KEY_ALL, 1000, 0 ); + +printf( "atmos led flash period 2s ...\n" ); + atmos_led_flash( light, LED_ID_ATMOS_ALL, 2000, 0 ); + +printf( "open ir led ...\n" ); + ir_led_on( light, 100 ); + sleep(1); + //ir_led_off( light, 100 ); +printf( "ring led flash period 1s ...\n" ); + ring_led_flash( light, 1000, 5000 ); + sleep(5); +printf( "ring led breath period 1s ...\n" ); + ring_led_breath( light, 1000, 0 ); + + while( 1 ) + sleep(1); + + return 0; +} + + diff --git a/tof/CMakeLists.txt b/tof/CMakeLists.txt index 427552b..a77ce71 100644 --- a/tof/CMakeLists.txt +++ b/tof/CMakeLists.txt @@ -16,3 +16,6 @@ add_library( ${PROJECT_NAME} STATIC ${SRCS} ) #install( TARGETS ${PROJECT_NAME} RUNTIME DESTINATION /app/lib ) #install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION /app/lib ) #install( TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION /app/lib ) + +install(FILES ${PROJECT_SOURCE_DIR}/test/tof_test DESTINATION /app/test/ ) +install(FILES ${PROJECT_SOURCE_DIR}/test/tof_test.txt DESTINATION /app/test/ ) diff --git a/tof/test/tof_test b/tof/test/tof_test new file mode 100755 index 0000000..65b9f2d Binary files /dev/null and b/tof/test/tof_test differ diff --git a/tof/test/tof_test.txt b/tof/test/tof_test.txt new file mode 100755 index 0000000..37f4f5d --- /dev/null +++ b/tof/test/tof_test.txt @@ -0,0 +1,7 @@ +#将tof中间件测试程序push进板子 + + adb push TOF_test /app + chmod 777 tof_test + ./tof_test + +#运行后90s会将测量距离修改为1500mm,修改距离120s后会关闭整个测试程序。