Skip to content

FujiNet Commodore Programming

Thomas Cherryhomes edited this page Mar 11, 2023 · 13 revisions

THIS PAGE IS PRELIMINARY - Items will be moved into separate pages, over time.

Get Adapter Config

  • Payload: "ADAPTERCONFIG"
  • Response: 8 text lines containing SSID, Hostname, IP, Netmask, Gateway, DNS, MAC, BSSID, and Version.

Example BASIC Program

10 OPEN 1,15,15,"ADAPTERCONFIG"
20 INPUT#1,S$:INPUT#1,H$:INPUT#1,I$:INPUT#1,N$:INPUT#1,G$:INPUT#1,D$:INPUT#1,M$
21 INPUT#1,B$:INPUT#1,V$
22 CLOSE1
30 PRINT "    SSID: ";S$
31 PRINT "HOSTNAME: ";H$
32 PRINT "      IP: ";I$
33 PRINT " NETMASK: ";N$
34 PRINT " GATEWAY: ";G$
35 PRINT "     DNS: ";D$
36 PRINT "     MAC: ";M$
37 PRINT "   BSSID: ";B$
38 PRINT "     VER: ";V$
40 END

Raw variant

For other languages that can handle structured binary data, an alternate payload can be used:

  • Payload: "ADAPTERCONFIG:RAW
  • Response: The adapter configuration as a binary structure specified below.
struct
{
    char ssid[33];
    char hostname[64];
    unsigned char localIP[4];
    unsigned char gateway[4];
    unsigned char netmask[4];
    unsigned char dnsIP[4];
    unsigned char macAddress[6];
    unsigned char bssid[6];
    char fn_version[15];
} cfg;

Example C program

#include <cx16.h>
#include <cbm.h>
#include <stdio.h>

/**
 * The current network adapter configuration
 */
typedef struct
{
  char ssid[33];
  char hostname[64];
  unsigned char localIP[4];
  unsigned char gateway[4];
  unsigned char netmask[4];
  unsigned char dnsIP[4];
  unsigned char macAddress[6];
  unsigned char bssid[6];
  char fn_version[15];
} AdapterConfig;

AdapterConfig ac;

void main(void)
{ 
  cbm_open(15,15,15,"adapterconfig:raw"); 
  cbm_read(15,&ac,sizeof(AdapterConfig));
  cbm_close(15);
  
  printf("%11s %s\n","SSID:",ac.ssid);
  printf("%11s %s\n","HOSTNAME:",ac.hostname);
  printf("%11s %u.%u.%u.%u\n","IP:",ac.localIP[0],ac.localIP[1],ac.localIP[2],ac.localIP[3]);
  printf("%11s %u.%u.%u.%u\n","NETMASK:",ac.netmask[0],ac.netmask[1],ac.netmask[2],ac.netmask[3]);
  printf("%11s %u.%u.%u.%u\n","GATEWAY:",ac.gateway[0],ac.gateway[1],ac.gateway[2],ac.gateway[3]);
  printf("%11s %u.%u.%u.%u\n","DNS:",ac.dnsIP[0],ac.dnsIP[1],ac.dnsIP[2],ac.dnsIP[3]);
  printf("%11s %02X:%02X:%02X:%02X:%02X:%02X\n","MAC:",ac.macAddress[0],ac.macAddress[1],ac.macAddress[2],ac.macAddress[3],ac.macAddress[4],ac.macAddress[5]);
  printf("%11s %02X:%02X:%02X:%02X:%02X:%02X\n","BSSID:",ac.bssid[0],ac.bssid[1],ac.bssid[2],ac.bssid[3],ac.bssid[4],ac.bssid[5]);
  printf("%11s %s\n\n","FNVER:",ac.fn_version);
}

Set SSID

  • Payload: "SETSSID:,"

(note: SSID is case sensitive, be aware when converting PETSCII to ASCII characters)

Example from BASIC

OPEN 1,15,15,"SETSSID:MyNetwork,mypassword":CLOSE1

RAW variant

An alternative payload, "SETSSID:RAW:" can be used to send the SSID and password as a fixed block of 97 characters, to allow for handling special characters, as seen in the structure below:

struct
{
    char ssid[33];
    char password[64];
} cfg;

The contents of this structure are immediately appended after SETSSID:RAW: and must be 97 characters exactly. Both ssid and password are expected to be NULL padded.


Get SSID

Payload: "GETSSID" Response: A single line of text containing the currently configured SSID

Example BASIC Program

10 OPEN 1,15,15,"GETSSID"
20 INPUT#1,S$
21 CLOSE1
30 ? "SSID: ";S$
40 END

Scan for networks

Payload: "SCAN" Response: A single number indicating number of discovered networks.

Example BASIC program

10 OPEN 1,15,15,"SCAN"
20 INPUT#1,N
30 CLOSE1
40 PRINT "# OF NETWORKS FOUND: ";N
50 END

Get Scan result from a SCAN

Payload: "SCANRESULT:[:RAW]" Response: "SSID",RSSI

  • num is the result # of recent scan, must be less than the total # of entries returned.
  • RAW specifies to send back the data using the following data structure:
struct
{
    char ssid[32]; // Null terminated and padded
    unsigned char rssi;
} result;

Example BASIC program

60 OPEN 1,15,15,"SCANRESULT:1"
70 INPUT#1,S$,R:REM GET SSID and RSSI
71 CLOSE 1
80 ? "SSID: ";S$;" RSSI: ";R

Get WIFI status

Payload: "WIFISTATUS" Response: 3 = CONNECTED, 6 = DISCONNECTED

Example BASIC program

10 OPEN 1,15,15,"WIFISTATUS"
20 INPUT #1,S
30 CLOSE 1
40 PRINT "WIFI STATUS IS ";
50 IF S=3 THEN PRINT "CONNECTED"
60 IF S=6 THEN PRINT "DISCONNECTED"
70 END

Mount Host Slot

Mount the host entered at slot 0-7. Needs to be done before a device slot can use something from a host slot.

Payload: "MOUNTHOST:<0-7>"

Example BASIC program

OPEN 1,15,15,"MOUNTHOST:1":CLOSE1:REM MOUNT SECOND HOST SLOT

Clone this wiki locally