// Initialize network with the given mac address and http port byte OpenSprinkler::start_network() { lcd_print_line_clear_pgm(PSTR("Connecting..."), 1); network_lasttime = now(); dhcpnew_lasttime = network_lasttime; mymac[5] = options[OPTION_DEVICE_ID].value; if(!ether.begin(ETHER_BUFFER_SIZE, mymac, PIN_ETHER_CS)) return 0; // calculate http port number ether.hisport = (int)(options[OPTION_HTTPPORT_1].value<<8) + (int)options[OPTION_HTTPPORT_0].value; if (options[OPTION_USE_DHCP].value) { // register with domain name "OpenSprinkler-xx" where xx is the last byte of the MAC address if (!ether.dhcpSetup()) return 0; } else { byte staticip[] = { options[OPTION_STATIC_IP1].value, options[OPTION_STATIC_IP2].value, options[OPTION_STATIC_IP3].value, options[OPTION_STATIC_IP4].value}; byte gateway[] = { options[OPTION_GATEWAY_IP1].value, options[OPTION_GATEWAY_IP2].value, options[OPTION_GATEWAY_IP3].value, options[OPTION_GATEWAY_IP4].value}; if (!ether.staticSetup(staticip, gateway, gateway)) return 0; } return 1; }
/** Initialize network with the given mac address and http port */ byte OpenSprinkler::start_network() { lcd_print_line_clear_pgm(PSTR("Connecting..."), 1); network_lasttime = now(); // new from 2.2: read hardware MAC if(!read_hardware_mac()) { // if no hardware MAC exists, use software MAC tmp_buffer[0] = 0x00; tmp_buffer[1] = 0x69; tmp_buffer[2] = 0x69; tmp_buffer[3] = 0x2D; tmp_buffer[4] = 0x31; tmp_buffer[5] = options[OPTION_DEVICE_ID].value; } else { // has hardware MAC chip status.has_hwmac = 1; } if(!ether.begin(ETHER_BUFFER_SIZE, (uint8_t*)tmp_buffer, PIN_ETHER_CS)) return 0; // calculate http port number ether.hisport = (unsigned int)(options[OPTION_HTTPPORT_1].value<<8) + (unsigned int)options[OPTION_HTTPPORT_0].value; if (options[OPTION_USE_DHCP].value) { // set up DHCP // register with domain name "OS-xx" where xx is the last byte of the MAC address if (!ether.dhcpSetup()) return 0; // once we have valid DHCP IP, we write these into static IP / gateway IP byte *ip = ether.myip; options[OPTION_STATIC_IP1].value = ip[0]; options[OPTION_STATIC_IP2].value = ip[1]; options[OPTION_STATIC_IP3].value = ip[2]; options[OPTION_STATIC_IP4].value = ip[3]; ip = ether.gwip; options[OPTION_GATEWAY_IP1].value = ip[0]; options[OPTION_GATEWAY_IP2].value = ip[1]; options[OPTION_GATEWAY_IP3].value = ip[2]; options[OPTION_GATEWAY_IP4].value = ip[3]; options_save(); } else { // set up static IP byte staticip[] = { options[OPTION_STATIC_IP1].value, options[OPTION_STATIC_IP2].value, options[OPTION_STATIC_IP3].value, options[OPTION_STATIC_IP4].value}; byte gateway[] = { options[OPTION_GATEWAY_IP1].value, options[OPTION_GATEWAY_IP2].value, options[OPTION_GATEWAY_IP3].value, options[OPTION_GATEWAY_IP4].value}; if (!ether.staticSetup(staticip, gateway, gateway)) return 0; } return 1; }
// Print station bits void OSLocalUI::lcd_print_station(byte line, char c) { lcd.setCursor(0, line); if (display_board == 0) { lcd_print_pgm(PSTR("MC:")); // Master controller is display as 'MC' } else { lcd_print_pgm(PSTR("E")); lcd.print((int)display_board); lcd_print_pgm(PSTR(":")); // extension boards are displayed as E1, E2... } if (!GetRunSchedules() && (ActiveZoneNum() == -1) ) { // "disabled" banner is displayed when schedules are disabled AND there are no currently running zones (to account for manual runs) lcd_print_line_clear_pgm(PSTR("-Disabled!-"), 1); } else { for (byte s=0; s<8; s++) { lcd.print(isZoneOn(1+s+display_board*8) ? (char)c : '_'); // note zone number correction - zones are numbered from 1. } } lcd_print_pgm(PSTR(" ")); lcd.setCursor(15, 1); lcd.write(nntpTimeServer.GetNetworkStatus()?0:1); }