Skip to content

Commit 59e0989

Browse files
committed
Added static ipaddress example
1 parent 3170435 commit 59e0989

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* @file StaticIPAddress.ino
3+
* @author Lewis He ([email protected])
4+
* @license MIT
5+
* @copyright Copyright (c) 2023 Shenzhen Xin Yuan Electronic Technology Co., Ltd
6+
* @date 2023-02-17
7+
*
8+
*/
9+
10+
#include "config.h"
11+
#include <WiFi.h>
12+
#include <WiFiClientSecure.h>
13+
#include <SPIFFS.h>
14+
#include <FS.h>
15+
#include <HTTPClient.h>
16+
17+
TTGOClass *ttgo = nullptr;
18+
19+
const char *ssid = "yourNetworkName";
20+
const char *password = "yourNetworkPass";
21+
22+
//IPAddress
23+
IPAddress staticIP(192, 168, 0, 113);
24+
IPAddress gateway(192, 168, 0, 1);
25+
IPAddress subnet(255, 255, 255, 0);
26+
IPAddress dns(192, 168, 0, 1);
27+
28+
void setup()
29+
{
30+
Serial.begin(115200);
31+
32+
// Get Watch Instance
33+
ttgo = TTGOClass::getWatch();
34+
35+
// Initialize watch
36+
ttgo->begin();
37+
38+
// Register lvgl
39+
ttgo->lvgl_begin();
40+
41+
// Turn on the backlight
42+
ttgo->openBL();
43+
44+
// Register wifi events
45+
WiFi.mode(WIFI_STA);
46+
47+
WiFi.begin(ssid, password);
48+
49+
if (WiFi.config(staticIP, gateway, subnet, dns, dns) == false) {
50+
Serial.println("Configuration failed.");
51+
}
52+
53+
while (WiFi.status() != WL_CONNECTED) {
54+
Serial.print("."); delay(50);
55+
}
56+
57+
Serial.println();
58+
Serial.println("WiFi connected");
59+
Serial.println("IP address: ");
60+
Serial.println(WiFi.localIP());
61+
62+
Serial.print("Local IP: ");
63+
Serial.println(WiFi.localIP());
64+
Serial.print("Subnet Mask: ");
65+
Serial.println(WiFi.subnetMask());
66+
Serial.print("Gateway IP: ");
67+
Serial.println(WiFi.gatewayIP());
68+
Serial.print("DNS 1: ");
69+
Serial.println(WiFi.dnsIP(0));
70+
Serial.print("DNS 2: ");
71+
Serial.println(WiFi.dnsIP(1));
72+
73+
}
74+
75+
76+
void loop()
77+
{
78+
79+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// => Hardware select
2+
// #define LILYGO_WATCH_2019_WITH_TOUCH // To use T-Watch2019 with touchscreen, please uncomment this line
3+
// #define LILYGO_WATCH_2019_NO_TOUCH // To use T-Watch2019 Not touchscreen , please uncomment this line
4+
#define LILYGO_WATCH_2020_V1 // To use T-Watch2020 V1, please uncomment this line
5+
// #define LILYGO_WATCH_2020_V2 // To use T-Watch2020 V2, please uncomment this line
6+
// #define LILYGO_WATCH_2020_V3 // To use T-Watch2020 V3, please uncomment this line
7+
8+
// #define LILYGO_LILYPI_V1 //LILYPI / TBLOCK requires an external display module
9+
// #define LILYGO_WATCH_BLOCK //LILYPI / TBLOCK requires an external display module
10+
11+
12+
13+
#if defined(LILYGO_LILYPI_V1) || defined(LILYGO_WATCH_BLOCK)
14+
// #define LILYGO_BLOCK_ST7796S_MODULE //Use ST7796S
15+
// #define LILYGO_BLOCK_ILI9481_MODULE //Use ILI9841
16+
// #define LILYGO_GC9A01A_MODULE //Use GC9A01A
17+
#endif
18+
#define LILYGO_WATCH_LVGL //To use LVGL, you need to enable the macro LVGL
19+
#define LILYGO_WATCH_LVGL_FS
20+
#define LILYGO_WATCH_LVGL_DECODER //Need to use PNG decoding, to define this macro
21+
22+
23+
#if defined(LILYGO_WATCH_2019_WITH_TOUCH)
24+
#define LILYGO_WATCH_LVGL_FS_SPIFFS
25+
#endif
26+
// #define LILYGO_WATCH_HAS_SDCARD
27+
28+
#include <LilyGoWatch.h>
29+

0 commit comments

Comments
 (0)