Skip to content

Commit

Permalink
release v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnL4 committed Nov 5, 2020
1 parent b1959a5 commit 1a94812
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 211 deletions.
212 changes: 3 additions & 209 deletions seeed-ambd-firmware.ino
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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();
Expand Down Expand Up @@ -343,6 +138,5 @@ void setup()

void loop()
{
delay(2000);
printf(".");
delay(10000);
}
2 changes: 1 addition & 1 deletion src/easylogger/inc/elog_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/erpc_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1a94812

Please sign in to comment.