Skip to content

Commit

Permalink
[coco] net scan
Browse files Browse the repository at this point in the history
  • Loading branch information
tschak909 committed Dec 15, 2023
1 parent d4c85d4 commit c2f480f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
61 changes: 34 additions & 27 deletions lib/device/drivewire/fuji.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,24 @@ void drivewireFuji::net_scan_networks()
{
Debug_println("Fuji cmd: SCAN NETWORKS");

char ret[4] = {0};

_countScannedSSIDs = fnWiFi.scan_networks();

ret[0] = _countScannedSSIDs;
if (!wifiScanStarted)
{
wifiScanStarted=true;
_countScannedSSIDs = fnWiFi.scan_networks();
}

fnUartBUS.write((uint8_t *)ret, 4);
fnUartBUS.write(_countScannedSSIDs);
}

// Return scanned network entry
void drivewireFuji::net_scan_result()
{
Debug_println("Fuji cmd: GET SCAN RESULT");

uint8_t n = fnUartBUS.read();

wifiScanStarted=false;

// Response to FUJICMD_GET_SCAN_RESULT
struct
{
Expand All @@ -148,8 +152,8 @@ void drivewireFuji::net_scan_result()
} detail;

bool err = false;
if (cmdFrame.aux1 < _countScannedSSIDs)
fnWiFi.get_scan_result(cmdFrame.aux1, detail.ssid, &detail.rssi);
if (n < _countScannedSSIDs)
fnWiFi.get_scan_result(n, detail.ssid, &detail.rssi);
else
{
memset(&detail, 0, sizeof(detail));
Expand Down Expand Up @@ -1087,31 +1091,31 @@ void drivewireFuji::close_directory()
// Get network adapter configuration
void drivewireFuji::get_adapter_config()
{
// Debug_println("Fuji cmd: GET ADAPTER CONFIG");
Debug_println("Fuji cmd: GET ADAPTER CONFIG");

// // Response to FUJICMD_GET_ADAPTERCONFIG
// AdapterConfig cfg;
// Response to FUJICMD_GET_ADAPTERCONFIG
AdapterConfig cfg;

// memset(&cfg, 0, sizeof(cfg));
memset(&cfg, 0, sizeof(cfg));

// strlcpy(cfg.fn_verdrivewiren, fnSystem.get_fujinet_verdrivewiren(true), sizeof(cfg.fn_verdrivewiren));
strlcpy(cfg.fn_version, fnSystem.get_fujinet_version(true), sizeof(cfg.fn_version));

// if (!fnWiFi.connected())
// {
// strlcpy(cfg.ssid, "NOT CONNECTED", sizeof(cfg.ssid));
// }
// else
// {
// strlcpy(cfg.hostname, fnSystem.Net.get_hostname().c_str(), sizeof(cfg.hostname));
// strlcpy(cfg.ssid, fnWiFi.get_current_ssid().c_str(), sizeof(cfg.ssid));
// fnWiFi.get_current_bssid(cfg.bssid);
// fnSystem.Net.get_ip4_info(cfg.localIP, cfg.netmask, cfg.gateway);
// fnSystem.Net.get_ip4_dns_info(cfg.dnsIP);
// }
if (!fnWiFi.connected())
{
strlcpy(cfg.ssid, "NOT CONNECTED", sizeof(cfg.ssid));
}
else
{
strlcpy(cfg.hostname, fnSystem.Net.get_hostname().c_str(), sizeof(cfg.hostname));
strlcpy(cfg.ssid, fnWiFi.get_current_ssid().c_str(), sizeof(cfg.ssid));
fnWiFi.get_current_bssid(cfg.bssid);
fnSystem.Net.get_ip4_info(cfg.localIP, cfg.netmask, cfg.gateway);
fnSystem.Net.get_ip4_dns_info(cfg.dnsIP);
}

// fnWiFi.get_mac(cfg.macAddress);
fnWiFi.get_mac(cfg.macAddress);

// bus_to_computer((uint8_t *)&cfg, sizeof(cfg), false);
fnUartBUS.write((uint8_t *)&cfg,sizeof(cfg));
}

// Make new disk and shove into device slot
Expand Down Expand Up @@ -1637,6 +1641,9 @@ void drivewireFuji::process()

switch (c)
{
case FUJICMD_GET_ADAPTERCONFIG:
get_adapter_config();
break;
case FUJICMD_GET_SCAN_RESULT:
net_scan_result();
break;
Expand Down
2 changes: 2 additions & 0 deletions lib/device/drivewire/fuji.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class drivewireFuji : public virtualDevice
private:
systemBus *_drivewire_bus = nullptr;

bool wifiScanStarted = false;

fujiHost _fnHosts[MAX_HOSTS];

fujiDisk _fnDisks[MAX_DISK_DEVICES];
Expand Down

0 comments on commit c2f480f

Please sign in to comment.