Skip to content

Commit

Permalink
Error if hostname is invalid in eeprom
Browse files Browse the repository at this point in the history
  • Loading branch information
Man-fred committed Jun 11, 2020
1 parent 86c2467 commit 286b8dc
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1,003 deletions.
51 changes: 46 additions & 5 deletions docs/commandref.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<h3>culfw<br>reference</h3>
</div>
<div id="right">
<h2>Work in progress</h2>
<p>The differences between CUL-programming and the Arduino-IDE are not decribed here. See the wiki on Github</p>

<h3>Contents</h3>
<ul>
Expand Down Expand Up @@ -69,6 +71,7 @@ <h3>Contents</h3>
<a href="#cmd_X">X</a>
<a href="#cmd_Y">Y</a>
<a href="#cmd_Z">Z</a>
<a href="#cmd_1">1</a>
</ul>
<a href="#protocol2">Protocol Part 2 (radio messages)</a><br>
<a href="#FHT_8v">FHT_8v</a><br>
Expand Down Expand Up @@ -140,6 +143,7 @@ <h3>Introduction</h3>
<li> HMS
<li> ESA
<li> ASKSIN (aka BidCos(R))
<li> MAX! with the moritz protocol
<li> basic OneWire Protocol through the DS4282 (CUNO only)
<li> UNIRoll
</ul>
Expand Down Expand Up @@ -412,7 +416,7 @@ <h3>Protocol Part 1 (culfw configuration)</h3>
<a name="cmd_E"></a>
E&lt;x&gt;
<ul>
(CUN only) eth debugging
(CUN only) eth debugging moved to command 1, E is used for RWE-devices
<ul>
<li> c<br>
Print out the currently configured IP & MAC address.
Expand Down Expand Up @@ -885,12 +889,18 @@ <h3>Protocol Part 1 (culfw configuration)</h3>
V
<ul>
Print the firmware version.
Example: V -&gt; V 1.30 CUL868
Example: V -&gt; V 1.67 CUL868
</ul>
VH
<ul>
Print the hardware version on CUL_V3 and CUL_V4
</ul><br><br>
Print the hardware version on CUL_V3, CUL_V4 and CUL_ESP
</ul>
VI
<ul>
Print the image version. The bin-file for over the air updates should look similar with a higher version number.
Example: VI -&gt; V01-67-00.culfw-esp8266.ino.d1_mini
</ul>
<br><br>

<a name="cmd_v"></a>
v&lt;func&gt;[&lt;hex&gt;]
Expand Down Expand Up @@ -949,7 +959,11 @@ <h3>Protocol Part 1 (culfw configuration)</h3>
<li>Win - IPV4 network mask
<li>Wip - tcplink port
<li>WiN - NTP sever
<li>Wio - GMT offset</li>
<li>Wio - GMT offset
<li>Wis - SSID (up to 20 character)</li>
<li>Wik - WPA-key (up to 20 character)</li>
<li>WiD - devicename (up to 20 character)</li>
<li>WiO - IPV4 Address of the OTA-server</li>
Notes:
<ul>
<li>Factory reset: use DHCP, port 2323, NTP-Server = Router, GMT offset:0
Expand Down Expand Up @@ -1097,6 +1111,33 @@ <h3>Protocol Part 1 (culfw configuration)</h3>
</ul>
</ul><br><br>

<a name="cmd_1"></a>
1&lt;x&gt;
<ul>
(CUN only) eth debugging moved from command E, wich is used for RWE-devices
<ul>
<li> c<br>
Print out the currently configured IP & MAC address.
The IP address may be different from what you configured with Wia
if DHCP is enabled. 0.0.0.0 is shown if no IP address is set, e.g.
when DHCP is enabled but the network cable is unplugged or CUN
could not get an IP address over LAN. Note that the IP address
that you configured with Wia is disregarded if DHCP is enabled.

<li> d<br>
increase the debug level. Meaning of the levels
1: application debugging, e.g. the NTP module will display the time
2: print ETH header (mac adress + ETH frametype)
3: dump whole ethernet packet.

<li> i<br>
Reinitialize the ethernet subsystem, restart DHCP & NTP

<li> n<br>
Request an NTP update
</ul>
</ul><br><br>


Unknown commands
<ul>
Expand Down
48 changes: 32 additions & 16 deletions libraries/ethernet/ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,45 @@ void EthernetClass::init(void)
#else
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
//#ifdef STANAME
WiFi.hostname(FNcol.ers(EE_NAME));
//#endif
Serial.print("Connecting ");
char sta_name[EE_STR_LEN];
uint8_t i = 0;
char test = 1;
for(i = 0; i < EE_STR_LEN && test > 0; i++) {
char test = FNcol.erb(EE_NAME + i);
if ((test >= '0' && test <= '9') || (test >= 'A' && test <= 'Z') || (test >= 'a' && test <= 'z') || test=='-' || test==0){
sta_name[i] = test;
} else {
i = 0;
break;
}
}
if (i > 0)
// hostname ok
WiFi.hostname(sta_name);
if(!FNcol.erb(EE_USE_DHCP)) {
set_eeprom_addr();
}
WiFi.begin(FNcol.ers(EE_WPA_SSID), FNcol.ers(EE_WPA_KEY));

//Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
i = 9;
while (i-- && WiFi.status() != WL_CONNECTED)
{
delay(500);
//Serial.print(".");
Serial.print(i);
}
//Serial.println();
tcplink_port = FNcol.erw(EE_IP4_TCPLINK_PORT);
eth_initialized = Udp.begin(tcplink_port);
server.begin(tcplink_port);
IPAddress localIP = WiFi.localIP();
uip_hostaddr[0] = localIP[1]<<8 | localIP[0];
uip_hostaddr[1] = localIP[3]<<8 | localIP[2];
WiFi.macAddress(uip_ethaddr.addr);
Serial.printf("\nUDP %d, TCP %d on %s:%d\n", eth_initialized, tcp_initialized, WiFi.localIP().toString().c_str(), tcplink_port);
if (i){
//Serial.println();
tcplink_port = FNcol.erw(EE_IP4_TCPLINK_PORT);
eth_initialized = Udp.begin(tcplink_port);
server.begin(tcplink_port);
IPAddress localIP = WiFi.localIP();
uip_hostaddr[0] = localIP[1]<<8 | localIP[0];
uip_hostaddr[1] = localIP[3]<<8 | localIP[2];
WiFi.macAddress(uip_ethaddr.addr);
Serial.printf("\nUDP %d, TCP %d on %s:%d\n", eth_initialized, tcp_initialized, WiFi.localIP().toString().c_str(), tcplink_port);
} else {
Serial.println('\nNo WLan');
}
#endif
}

Expand Down
83 changes: 0 additions & 83 deletions libraries/fastrf/fastrf.c

This file was deleted.

Loading

0 comments on commit 286b8dc

Please sign in to comment.