Skip to content

Commit

Permalink
ESP32 : Adding the Internet connenction Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaneam committed Mar 29, 2021
1 parent 900a921 commit f245117
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
16 changes: 8 additions & 8 deletions ESP32/lib/GoogleHome/GoogleHome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ bool GoogleHome::TryConnect(std::string deviceName)
googleHomeNotifier.getIPAddress().toString().c_str(),
googleHomeNotifier.getPort());

char buffer[200];
sprintf(buffer, "Hey there. Sensor is now connected to %s!\r\n", deviceName.c_str());
if (!googleHomeNotifier.notify(buffer))
{
if (isVerbose)
printf("Google Home notify error: %s\r\n", googleHomeNotifier.getLastError());
Connected = false;
}
// char buffer[200];
// sprintf(buffer, "Hey there. Sensor is now connected to %s!\r\n", deviceName.c_str());
// if (!googleHomeNotifier.notify(buffer))
// {
// if (isVerbose)
// printf("Google Home notify error: %s\r\n", googleHomeNotifier.getLastError());
// Connected = false;
// }
}

if (Connected)
Expand Down
6 changes: 6 additions & 0 deletions ESP32/lib/SSD1306/OLEDExtended.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ void OLEDDisplayExtended::drawIcon(OLEDDISPLAY_ICONS icon)
case OLEDDISPLAY_ICONS::NOTIFYING:
this->drawXbm(status_icon_pos[0] + offset, status_icon_pos[1], status_icon_pos[2], status_icon_pos[3], Notify_icon_img);
break;
case OLEDDISPLAY_ICONS::INTERNET:
this->drawXbm(status_icon_pos[0] + offset, status_icon_pos[1], status_icon_pos[2], status_icon_pos[3], Internet_icon_img);
break;
default:
break;
}
Expand Down Expand Up @@ -302,6 +305,7 @@ void OLEDDisplayExtended::ReferessStatusArea(
bool isWiFiconnected,
std::string ssid,
bool isCloudConencted,
bool isInternetConnected,
bool isNotifying)
{
this->clearArea(Status_Area[0], Status_Area[1], Status_Area[2], Status_Area[3]);
Expand All @@ -316,6 +320,8 @@ void OLEDDisplayExtended::ReferessStatusArea(
this->drawIcon(OLEDDISPLAY_ICONS::CLOUD);
if (isNotifying)
this->drawIcon(OLEDDISPLAY_ICONS::NOTIFYING);
if (isInternetConnected)
this->drawIcon(OLEDDISPLAY_ICONS::INTERNET);
if (isWiFiconnected)
{
this->drawIcon(OLEDDISPLAY_ICONS::WIFI_ICON);
Expand Down
10 changes: 9 additions & 1 deletion ESP32/lib/SSD1306/OLEDExtended.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const unsigned char Notify_icon_img[] PROGMEM = {
0xF8, 0x0F, 0x00, 0x07, 0x80, 0x03, 0x80, 0x01,
0xC0, 0x01, 0xC0, 0x00, 0x60, 0x00, 0x30, 0x00};

const unsigned char Internet_icon_img[] PROGMEM = {
0xE0, 0x07, 0xF8, 0x1F, 0xAC, 0x35, 0x96, 0x69,
0xFE, 0x7E, 0x93, 0xC9, 0x89, 0x91, 0xFF, 0xFF,
0xFF, 0xFF, 0x89, 0x91, 0x93, 0xC9, 0xFE, 0x7F,
0x96, 0x69, 0xAC, 0x35, 0xF8, 0x1F, 0xE0, 0x07};

const unsigned char BLE_advertising_icon_img[] PROGMEM = {
0x80, 0x01, 0x80, 0x03, 0x80, 0x07, 0x98, 0x0F,
0xB8, 0x0D, 0xF0, 0x0D, 0xE0, 0x07, 0xC0, 0x03,
Expand Down Expand Up @@ -136,7 +142,8 @@ enum OLEDDISPLAY_ICONS
GOOGLE_HOME = 3,
CLOUD = 4,
SSID_PLACEHOLDER = 5,
NOTIFYING = 6
NOTIFYING = 6,
INTERNET = 7
};

class OLEDDisplayExtended : public OLEDDisplay
Expand Down Expand Up @@ -172,6 +179,7 @@ class OLEDDisplayExtended : public OLEDDisplay
bool isHomeConencted,
bool isWiFiconnected,
std::string ssid,
bool isInternetConnected,
bool isCloudConencted,
bool isNotifying = false);

Expand Down
2 changes: 1 addition & 1 deletion ESP32/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define OLED_Address 0x3c

#define BLE_ADVERTISE_TIMEOUT_S 60 // BLE advertising timeout
#define BLE_ADVERTISE_ENABLE_PIN 15 //02 // 33 // 15
#define BLE_ADVERTISE_ENABLE_PIN 32 //02 // 33 // 15
#define BLE_ADVERTISE_LED_PIN 12
#define SENSOR_READ_INTERVAL 60

Expand Down
14 changes: 11 additions & 3 deletions ESP32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,21 @@ void loop()
char buffer[100] = "";
unsigned long t1, t2, t3, t4;
t1 = millis();
if (wireless.IsConnected())
isWiFiconnected = wireless.IsConnected();
if (isWiFiconnected)
{
if (wireless.IsOnline())
isInternetConnected = wireless.IsOnline();
if (isInternetConnected)
{
getTimeString(&buffer[0]);
}
}
else
{
isInternetConnected = false;
}

UpdateStatus(true, true);
if (Sensor.CheckStatus())
{

Expand Down Expand Up @@ -339,7 +347,7 @@ void ConfigureTime()
void UpdateStatus(bool BLE, bool OLED, bool isNotifying)
{
if (OLED)
Oled.ReferessStatusArea(isBLEadvertising, isBLEconnected, isHomeConnected, isWiFiconnected, ssid, isCloudconnected, isNotifying);
Oled.ReferessStatusArea(isBLEadvertising, isBLEconnected, isHomeConnected, isWiFiconnected, ssid, isInternetConnected, isCloudconnected, isNotifying);
if (BLE)
BluetoothLE.UpdateConnectionStatus(isWiFiconnected, isHomeConnected, isCloudconnected);
}
Expand Down
1 change: 1 addition & 0 deletions ESP32/src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bool isHomeConnected = false;
bool isBLEadvertising = false;
bool isBLEconnected = false;
bool isWiFiconnected = false;
bool isInternetConnected = false;
bool isCloudconnected = false;

std::vector<CustomEvents> eventQueue;
Expand Down

0 comments on commit f245117

Please sign in to comment.