diff --git a/examples/BasicUnit/StaticIPAddress/StaticIPAddress.ino b/examples/BasicUnit/StaticIPAddress/StaticIPAddress.ino new file mode 100644 index 0000000..12b8c6b --- /dev/null +++ b/examples/BasicUnit/StaticIPAddress/StaticIPAddress.ino @@ -0,0 +1,79 @@ +/** + * @file StaticIPAddress.ino + * @author Lewis He (lewishe@outlook.com) + * @license MIT + * @copyright Copyright (c) 2023 Shenzhen Xin Yuan Electronic Technology Co., Ltd + * @date 2023-02-17 + * + */ + +#include "config.h" +#include +#include +#include +#include +#include + +TTGOClass *ttgo = nullptr; + +const char *ssid = "yourNetworkName"; +const char *password = "yourNetworkPass"; + +//IPAddress +IPAddress staticIP(192, 168, 0, 113); +IPAddress gateway(192, 168, 0, 1); +IPAddress subnet(255, 255, 255, 0); +IPAddress dns(192, 168, 0, 1); + +void setup() +{ + Serial.begin(115200); + + // Get Watch Instance + ttgo = TTGOClass::getWatch(); + + // Initialize watch + ttgo->begin(); + + // Register lvgl + ttgo->lvgl_begin(); + + // Turn on the backlight + ttgo->openBL(); + + // Register wifi events + WiFi.mode(WIFI_STA); + + WiFi.begin(ssid, password); + + if (WiFi.config(staticIP, gateway, subnet, dns, dns) == false) { + Serial.println("Configuration failed."); + } + + while (WiFi.status() != WL_CONNECTED) { + Serial.print("."); delay(50); + } + + Serial.println(); + Serial.println("WiFi connected"); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); + + Serial.print("Local IP: "); + Serial.println(WiFi.localIP()); + Serial.print("Subnet Mask: "); + Serial.println(WiFi.subnetMask()); + Serial.print("Gateway IP: "); + Serial.println(WiFi.gatewayIP()); + Serial.print("DNS 1: "); + Serial.println(WiFi.dnsIP(0)); + Serial.print("DNS 2: "); + Serial.println(WiFi.dnsIP(1)); + +} + + +void loop() +{ + +} diff --git a/examples/BasicUnit/StaticIPAddress/config.h b/examples/BasicUnit/StaticIPAddress/config.h new file mode 100644 index 0000000..ed9bb83 --- /dev/null +++ b/examples/BasicUnit/StaticIPAddress/config.h @@ -0,0 +1,29 @@ +// => Hardware select +// #define LILYGO_WATCH_2019_WITH_TOUCH // To use T-Watch2019 with touchscreen, please uncomment this line +// #define LILYGO_WATCH_2019_NO_TOUCH // To use T-Watch2019 Not touchscreen , please uncomment this line +#define LILYGO_WATCH_2020_V1 // To use T-Watch2020 V1, please uncomment this line +// #define LILYGO_WATCH_2020_V2 // To use T-Watch2020 V2, please uncomment this line +// #define LILYGO_WATCH_2020_V3 // To use T-Watch2020 V3, please uncomment this line + +// #define LILYGO_LILYPI_V1 //LILYPI / TBLOCK requires an external display module +// #define LILYGO_WATCH_BLOCK //LILYPI / TBLOCK requires an external display module + + + +#if defined(LILYGO_LILYPI_V1) || defined(LILYGO_WATCH_BLOCK) +// #define LILYGO_BLOCK_ST7796S_MODULE //Use ST7796S +// #define LILYGO_BLOCK_ILI9481_MODULE //Use ILI9841 +// #define LILYGO_GC9A01A_MODULE //Use GC9A01A +#endif +#define LILYGO_WATCH_LVGL //To use LVGL, you need to enable the macro LVGL +#define LILYGO_WATCH_LVGL_FS +#define LILYGO_WATCH_LVGL_DECODER //Need to use PNG decoding, to define this macro + + +#if defined(LILYGO_WATCH_2019_WITH_TOUCH) +#define LILYGO_WATCH_LVGL_FS_SPIFFS +#endif +// #define LILYGO_WATCH_HAS_SDCARD + +#include +