增加中间件测试程序
authorkyz <kongyuzhong@gmail.com>
Wed, 5 Jul 2023 02:00:55 +0000 (10:00 +0800)
committerkyz <kongyuzhong@gmail.com>
Wed, 5 Jul 2023 02:00:55 +0000 (10:00 +0800)
15 files changed:
als/CMakeLists.txt
als/test/als_test [new file with mode: 0755]
als/test/als_test.txt [new file with mode: 0755]
ble_wificonfig/Server/src/gatt-service.c
button/CMakeLists.txt
button/test/button.c [new file with mode: 0644]
buzzer/CMakeLists.txt
buzzer/test/buzzer_test [new file with mode: 0755]
buzzer/test/buzzer_test.txt [new file with mode: 0755]
led/CMakeLists.txt
led/test/led_test.c [deleted file]
led/test/light.c [new file with mode: 0644]
tof/CMakeLists.txt
tof/test/tof_test [new file with mode: 0755]
tof/test/tof_test.txt [new file with mode: 0755]

index 6a76d9b41b63e1e940e2afcd5da3313105fa5be8..15e9accd84b886cdbf80cafdc5165508ce4c1dd6 100644 (file)
@@ -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 (executable)
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 (executable)
index 0000000..18cc6b8
--- /dev/null
@@ -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
index d070fe15f9b95f47196061af5b34b8d1a593a1b2..5cb8f385a4f2c51f91375abae20a6cf71e6e74c5 100644 (file)
@@ -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 );
 
index d217d593be4fcfcc4841811217f0fbeaffa5e756..8a247424bc02fd78e7f0ad285ab0007b6d22e384 100644 (file)
@@ -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 (file)
index 0000000..5503662
--- /dev/null
@@ -0,0 +1,88 @@
+#include <stdio.h>
+#include <stdint.h>
+#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);
+}
+
index 85d1d8caa95f20d052b195a60331c00299c3b25b..8ea122dbf1918c68461243e3e3d0f0a13d01798f 100644 (file)
@@ -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 (executable)
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 (executable)
index 0000000..c8f8c05
--- /dev/null
@@ -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
index efcfaa3fd2b0d99c239b6112baead94ac0fde1ff..b83b85dd65fe919e61b41ae45fa7cd1e3451ff15 100644 (file)
@@ -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 (file)
index d2e87bf..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <time.h>
-#include "led.h"
-#include "mg_log.h"
-#include "pthread.h"
-#include "semaphore.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-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 (file)
index 0000000..7d9dd06
--- /dev/null
@@ -0,0 +1,129 @@
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <time.h>
+#include "led.h"
+#include "mg_log.h"
+#include "pthread.h"
+#include "semaphore.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <getopt.h>
+
+#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;
+}
+
+
index 427552ba027dfd8b2af21c95df3fd50b4187552d..a77ce7160574b75007a950af22bc9fb718e8ef24 100644 (file)
@@ -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 (executable)
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 (executable)
index 0000000..37f4f5d
--- /dev/null
@@ -0,0 +1,7 @@
+#将tof中间件测试程序push进板子
+
+       adb push TOF_test /app
+        chmod 777 tof_test
+       ./tof_test
+
+#运行后90s会将测量距离修改为1500mm,修改距离120s后会关闭整个测试程序。