diff --git a/seeed-ambd-firmware.ino b/seeed-ambd-firmware.ino index 2c25560..1bab483 100644 --- a/seeed-ambd-firmware.ino +++ b/seeed-ambd-firmware.ino @@ -1,18 +1,6 @@ #include "elog.h" -#include "ble_task.h" -#include "ble_callback.h" -#include "ble_common.h" -#include "ble_main.h" -#include "gcs_client.h" -#include "gap_config.h" -#include "bas_client.h" -#include "gatt.h" - -#include "rpc_system_header.h" -#include "rpc_wifi_api.h" #include "wifi_main.h" -#include "wifi_callback.h" -#include "wifi_tcpip_adapter.h" + /*init the easylogger moudle*/ void app_elog_init(void) @@ -34,204 +22,11 @@ void app_elog_init(void) /* start EasyLogger */ elog_start(); } -#define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] -#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -static void print_scan_result(rtw_scan_result_t *record) -{ - - printf("%s\t ", (record->bss_type == RTW_BSS_TYPE_ADHOC) ? "Adhoc" : "Infra"); - printf(MAC_FMT, MAC_ARG(record->BSSID.octet)); - printf(" %d\t ", record->signal_strength); - printf(" %d\t ", record->channel); - printf(" %d\t ", record->wps_type); - printf("%s\t\t ", (record->security == RTW_SECURITY_OPEN) ? "Open" : (record->security == RTW_SECURITY_WEP_PSK) ? "WEP" : (record->security == RTW_SECURITY_WPA_TKIP_PSK) ? "WPA TKIP" : (record->security == RTW_SECURITY_WPA_AES_PSK) ? "WPA AES" : (record->security == RTW_SECURITY_WPA2_AES_PSK) ? "WPA2 AES" : (record->security == RTW_SECURITY_WPA2_TKIP_PSK) ? "WPA2 TKIP" : (record->security == RTW_SECURITY_WPA2_MIXED_PSK) ? "WPA2 Mixed" : (record->security == RTW_SECURITY_WPA_WPA2_MIXED) ? "WPA/WPA2 AES" : "Unknown"); - - printf(" %s ", record->SSID.val); - printf("\r\n"); -} -// Set these to your desired credentials. -const char *ssid = "wio terminal"; -const char *password = "123456789"; -const uint8_t bssid[6] = {0xd2, 0xfb, 0xe2, 0x64, 0x6f, 0xc5}; extern void erpc_system_init(); - -// void setup() -// { -// wifi_init(); -// app_elog_init(); -// // //delay(1000); - -// // // // // wifi_scan_networks(app_scan_result_handler, NULL); -// // // // // delay(5000); -// // // // // // rpc_wifi_on(RTW_MODE_STA); -// // tcpip_adapter_init(); -// // binary_t b_bssid; -// // binary_t b_ssid; -// // binary_t b_password; -// // b_bssid.data = (uint8_t *)bssid; -// // b_bssid.dataLength = 6; -// // b_ssid.data = (uint8_t *)ssid; -// // b_ssid.dataLength = strlen(ssid)+1; -// // b_password.data = (uint8_t *)password; -// // b_password.dataLength = strlen(password)+1; -// // tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); -// // wifi_off(); -// // vTaskDelay(20); -// // if (wifi_on(RTW_MODE_STA) < 0){ -// // printf("\n\rERROR: Wifi on STA failed!"); -// // } - -// // wifi_scan_start(); -// // while (wifi_is_scaning()) -// // { -// // printf("*"); -// // delay(200); -// // } -// // uint16_t networkNum = wifi_scan_get_ap_num(); -// // static rtw_scan_result_t networks[50]; -// // printf("networkNum:%d", networkNum); -// // if(networkNum != 0) -// // { -// // wifi_scan_get_ap_records(networkNum, networks); -// // } - -// // for(int i = 0; i < networkNum; i++) -// // { -// // print_scan_result(&networks[i]); -// // } -// // uint32_t channel = 6; -// // uint8_t pscan_config = PSCAN_ENABLE | PSCAN_FAST_SURVEY; -// // int ret = wifi_set_pscan_chan((uint8_t *)&channel, &pscan_config, 1); -// // if (ret < 0) -// // { -// // while (1) -// // { -// // printf(")"); -// // } - -// // } - -// // int ret = rpc_wifi_connect(&b_ssid, &b_password, RTW_SECURITY_WPA2_AES_PSK, -1, NULL); -// // if(ret == RTW_ERROR) -// // { -// // printf("Error!!\n\r"); -// // }else -// // { -// // tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_STA); -// // } - -// // if (wifi_on(RTW_MODE_AP) < 0){ -// // printf("\n\rERROR: Wifi on AP failed!"); -// // } -// // tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP); -// // tcpip_adapter_ip_info_t info; -// // info.ip.addr = 16885952; -// // info.gw.addr = 16885952; -// // info.netmask.addr = 16777215; -// // tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &info); -// // rpc_wifi_start_ap(&b_ssid, &b_password, RTW_SECURITY_WPA2_AES_PSK, 11); - -// // tcpip_adapter_dhcps_start(TCPIP_ADAPTER_IF_AP); -// erpc_system_init(); -// } - -// int client_number; -// struct -// { -// int count; -// rtw_mac_t mac_list[3]; -// } client_info; -// void loop() -// { -// delay(2000); -// printf("."); -// //vTaskDelete(NULL); -// // static wlan_fast_reconnect_profile_t wifi_info = {0}; -// // if(wifi_get_reconnect_data(&wifi_info)!=0) -// // { -// // printf("SSID: %s\n\r", wifi_info.psk_essid); -// // printf("PASSWORD: %s\n\r", wifi_info.psk_passphrase); -// // } -// // client_info.count = 3; -// // wifi_get_associated_client_list(&client_info, sizeof(client_info)); -// // printf("\n\rAssociated Client List:"); -// // printf("\n\r=============================="); - -// // if (client_info.count == 0) -// // printf("\n\rClient Num: 0\n\r"); -// // else -// // { -// // printf("\n\rClient Num: %d", client_info.count); -// // for (client_number = 0; client_number < client_info.count; client_number++) -// // { -// // printf("\n\rClient [%d]:", client_number); -// // printf("\n\r\tMAC => " MAC_FMT "", -// // MAC_ARG(client_info.mac_list[client_number].octet)); -// // } -// // printf("\n\r"); -// // } -// // rpc_wifi_connect(&b_ssid, &b_password, RTW_SECURITY_WPA2_AES_PSK, 0, NULL); -// // vTaskDelay(30000); -// // printf("I am here\n\r"); -// // rpc_wifi_disconnect(); -// // vTaskDelay(5000); -// } -extern void erpc_ble_init(); - -uint8_t conn_id = 0xff; -#if DEBUG_LOCAL -/** @brief GAP - scan response data (max size = 31 bytes) */ -static const uint8_t scan_rsp_data[] = - { - 0x03, /* length */ - GAP_ADTYPE_APPEARANCE, /* type="Appearance" */ - LO_WORD(GAP_GATT_APPEARANCE_UNKNOWN), - HI_WORD(GAP_GATT_APPEARANCE_UNKNOWN), -}; - -/** @brief GAP - Advertisement data (max size = 31 bytes, best kept short to conserve power) */ -static const uint8_t adv_data[] = - { - /* Flags */ - 0x02, /* length */ - GAP_ADTYPE_FLAGS, /* type="Flags" */ - GAP_ADTYPE_FLAGS_LIMITED | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED, - /* Service */ - 0x03, /* length */ - GAP_ADTYPE_16BIT_COMPLETE, - LO_WORD(0x180F), - HI_WORD(0x180F), - /* Local name */ - 0x0F, /* length */ - GAP_ADTYPE_LOCAL_NAME_COMPLETE, - 'B', - 'L', - 'E', - '_', - 'P', - 'E', - 'R', - 'I', - 'P', - 'H', - 'E', - 'R', - 'A', - 'L', -}; - -char v1_user_descr[] = "V1 read characteristic"; -uint8_t srcv_app_id = 0; -uint8_t srcv_handle = 0; -uint8_t char_handle = 0; -uint8_t desc_handle1 = 0; -uint8_t desc_handle2 = 0; -#endif - void setup() { - //wifi_init(); + wifi_init(); app_elog_init(); #if DEBUG_LOCAL ble_init(); @@ -343,6 +138,5 @@ void setup() void loop() { - delay(2000); - printf("."); + delay(10000); } \ No newline at end of file diff --git a/src/easylogger/inc/elog_cfg.h b/src/easylogger/inc/elog_cfg.h index 91df4b5..4663feb 100644 --- a/src/easylogger/inc/elog_cfg.h +++ b/src/easylogger/inc/elog_cfg.h @@ -30,7 +30,7 @@ #define _ELOG_CFG_H_ /*---------------------------------------------------------------------------*/ /* enable log output. */ -#define ELOG_OUTPUT_ENABLE +//#define ELOG_OUTPUT_ENABLE /* setting static output log level. range: from ELOG_LVL_ASSERT to ELOG_LVL_VERBOSE */ #define ELOG_OUTPUT_LVL ELOG_LVL_VERBOSE /* enable assert check */ diff --git a/src/erpc_setup.cpp b/src/erpc_setup.cpp index 12c97ec..295aa78 100644 --- a/src/erpc_setup.cpp +++ b/src/erpc_setup.cpp @@ -78,7 +78,7 @@ class MyMessageBufferFactory : public MessageBufferFactory char * rpc_system_version(void) { - return "0.1.0"; + return "2.0.0"; } uint8_t rpc_system_ack(uint8_t c)