-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 088d31d
Showing
43 changed files
with
1,979 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
void init_server(){ | ||
String ip_address = WiFi.localIP().toString(); | ||
String concat_info = "ip=" +ip_address+ "&" +node_id ; | ||
char msg[30]; | ||
concat_info.toCharArray(msg, 30); | ||
int statusCode = client.post("/api/init/", msg, &response); | ||
} | ||
|
||
void onpress_side(){ | ||
Serial.println("Button has been pressed!"); | ||
print_screen("Updating the server!"); | ||
|
||
//NEED TO ADD CALL ID ALONG WITH NURSE ID | ||
String str = node_id+"&"+call_id; | ||
char msg[30]; | ||
str.toCharArray(msg, 30); | ||
int statusCode = client.post("/api/nurse/", msg, &response); | ||
//Serial.println(response); | ||
|
||
buzz(); | ||
print_screen("Update done!"); | ||
|
||
|
||
// lcd.clear(); | ||
// lcd_i2c("Received",0,0); | ||
// delay(1000); | ||
// lcd.clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//void lcd_init(){ | ||
// Wire.begin(LCD_P1,LCD_P2); | ||
// lcd.begin(); | ||
// lcd_print(); | ||
//} | ||
// | ||
//void lcd_print(){ | ||
// lcd_i2c("Hello To",0,0); | ||
// lcd_i2c("NCS",0,1); | ||
//} | ||
// | ||
//void lcd_i2c(String msg,int start_pos,int col){ | ||
// lcd.setCursor(start_pos, col); | ||
// lcd.print(msg); | ||
//} | ||
// | ||
//void lcd_buzz(){ | ||
// | ||
// lcd.clear(); | ||
// | ||
// String msg = "Calling"; | ||
// lcd_i2c(msg,0,0); | ||
// | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include <SPI.h> | ||
#include <Wire.h> | ||
#include <Adafruit_GFX.h> | ||
#include <Adafruit_SSD1306.h> //OLED | ||
|
||
#include <RestClient.h> | ||
#include <EasyButton.h> | ||
#include <ESP8266WebServer.h> | ||
//#include <LiquidCrystal_I2C.h> | ||
//#include <Wire.h> | ||
|
||
#define OLED_RESET LED_BUILTIN //4 SDA > D2 , SCL D1 OLED STUFF | ||
Adafruit_SSD1306 display(OLED_RESET); | ||
|
||
#if (SSD1306_LCDHEIGHT != 64) | ||
#error("Height incorrect, please fix Adafruit_SSD1306.h!"); | ||
#endif | ||
|
||
|
||
//LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address | ||
// to 0x27 for a 16 chars | ||
// and 2 line display | ||
|
||
const int port = 8080; | ||
const char* host = "192.168.1.177"; | ||
|
||
const char* ssid = "scarX"; | ||
const char* password = "1234567i"; | ||
|
||
String node_id = "id=3"; | ||
String response = ""; | ||
String call_id = ""; | ||
bool call_status = false; | ||
|
||
RestClient client = RestClient(host,port); | ||
ESP8266WebServer server(80); | ||
|
||
#define BUTTON_PIN D6 // DD6 | ||
#define BUZZER_PIN D7 // D7 | ||
//#define LCD_P1 14 // D5 LCD | ||
//#define LCD_P2 12 // D6 | ||
|
||
EasyButton button(BUTTON_PIN); | ||
bool toggle = true; | ||
|
||
void onPressed() { | ||
if(call_status) | ||
{ | ||
onpress_side(); | ||
call_status = false; | ||
} | ||
else | ||
{ | ||
clear_screen(); | ||
} | ||
|
||
|
||
Serial.println("Button has been pressed!"); | ||
} | ||
|
||
|
||
void setup() { | ||
Serial.begin(115200); | ||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); | ||
button.begin(); | ||
button.onPressed(onPressed); | ||
pinMode(BUZZER_PIN, OUTPUT); | ||
|
||
//lcd_init(); | ||
connection(); | ||
route_server(); | ||
} | ||
|
||
void loop() { | ||
server.handleClient(); | ||
connection(); | ||
button.read(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
void print_screen(String str){ | ||
display.clearDisplay(); | ||
display.display(); | ||
|
||
display.setTextSize(2); | ||
display.setTextColor(WHITE); | ||
display.setCursor(0,0); | ||
display.println(str); | ||
display.display(); | ||
} | ||
|
||
void clear_screen(){ | ||
display.clearDisplay(); | ||
display.display(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
void route_server(){ | ||
server.on("/",HTTP_POST, incoming); | ||
server.on("/alert",HTTP_POST, alert); | ||
server.begin(); | ||
} | ||
|
||
void incoming() { | ||
Serial.println("Got One Incoming"); | ||
|
||
String security_code = "123456789"; | ||
if (security_code == server.arg("sc")) | ||
{ | ||
Serial.println("CALLING..."); | ||
print_screen("CALLING..."); | ||
buzz(); | ||
String bed_id = server.arg("bed_id"); | ||
call_id = "call_id=" + server.arg("call_id"); | ||
Serial.println("Bed: "+bed_id); | ||
server.send(200, "text/plain", "success"); | ||
call_status = true; | ||
return; | ||
} | ||
server.send(200, "text/plain", "404"); | ||
} | ||
|
||
|
||
void alert() { | ||
Serial.println("Got One Alert!"); | ||
|
||
String security_code = "123456789"; | ||
if (security_code == server.arg("sc")) | ||
{ | ||
buzz(); | ||
String msg = server.arg("msg"); | ||
print_screen(msg); | ||
server.send(200, "text/plain", "success"); | ||
return; | ||
} | ||
server.send(200, "text/plain", "404"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
void connection(){ | ||
if(WiFi.status() != WL_CONNECTED){ | ||
print_screen("Connecting..."); | ||
int a = client.begin(ssid,password); | ||
|
||
|
||
if(WiFi.status() == WL_CONNECTED){ | ||
init_server(); | ||
Serial.println("Initialization Done"); | ||
print_screen("Initialization Done"); | ||
} | ||
} | ||
} | ||
|
||
void buzz(){ | ||
digitalWrite(BUZZER_PIN, true); | ||
delay(300); | ||
digitalWrite(BUZZER_PIN, false); | ||
} |
47 changes: 47 additions & 0 deletions
47
Codes and More/Hardware Code /rest_post_init_call/rest_post_init_call.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include <RestClient.h> | ||
#include <EasyButton.h> | ||
#include <SPI.h> | ||
#include <MFRC522.h> | ||
|
||
#define SS_PIN D4 | ||
#define RST_PIN D3 | ||
|
||
//const char* ssid = "Research Lab"; | ||
//const char* password = "research12"; | ||
const char* ssid = "scarX"; | ||
const char* password = "1234567i"; | ||
|
||
const char* host = "192.168.1.81"; | ||
const int port = 8080; | ||
|
||
MFRC522 mfrc522(SS_PIN, RST_PIN); | ||
RestClient client = RestClient(host, port); | ||
EasyButton button(D1); | ||
String node_id = "id=1"; | ||
|
||
|
||
// Callback function to be called when the button is pressed. | ||
void onPressed() { | ||
patient_call(client,node_id); | ||
Serial.println("button pressed"); | ||
} | ||
|
||
void setup() { | ||
|
||
Serial.begin(115200); | ||
int a = client.begin(ssid, password); | ||
init_server(client, node_id); | ||
|
||
button.begin(); | ||
button.onPressed(onPressed); | ||
pinMode(D2, OUTPUT); | ||
|
||
SPI.begin(); // Init SPI bus | ||
mfrc522.PCD_Init(); // Init MFRC522 | ||
Serial.println("RFID reading UID"); | ||
} | ||
|
||
void loop() { | ||
button.read(); | ||
read_card(mfrc522); | ||
} |
29 changes: 29 additions & 0 deletions
29
Codes and More/Hardware Code /rest_post_init_call/rfid.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
void read_card(MFRC522 mfrc522){ | ||
|
||
// String readID = ""; | ||
|
||
if ( mfrc522.PICC_IsNewCardPresent()) | ||
{ | ||
if ( mfrc522.PICC_ReadCardSerial()) | ||
{ | ||
Serial.print("Tag UID:"); | ||
// for (byte i = 0; i < mfrc522.uid.size; i++) { | ||
// Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); | ||
// Serial.print(mfrc522.uid.uidByte[i], HEX); | ||
// readID += mfrc522.uid.uidByte[i]; | ||
// } | ||
unsigned long UID_unsigned; | ||
UID_unsigned = mfrc522.uid.uidByte[0] << 24; | ||
UID_unsigned += mfrc522.uid.uidByte[1] << 16; | ||
UID_unsigned += mfrc522.uid.uidByte[2] << 8; | ||
UID_unsigned += mfrc522.uid.uidByte[3]; | ||
|
||
String UID_string = (String)UID_unsigned; | ||
Serial.println(UID_string); | ||
Serial.println(); | ||
mfrc522.PICC_HaltA(); | ||
} | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
Codes and More/Hardware Code /rest_post_init_call/server_part.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
void post_request(RestClient client, String route_p, String concat_msg, int len){ | ||
|
||
String response = ""; | ||
char msg[len]; | ||
concat_msg.toCharArray(msg, len); | ||
|
||
char route[20]; | ||
route_p.toCharArray(route,20); | ||
int statusCode = client.post(route, msg, &response); | ||
} | ||
|
||
|
||
|
||
void init_server(RestClient client, String node_id){ | ||
|
||
//Server Initializaion code, it will send | ||
String ip_address = WiFi.localIP().toString(); | ||
String concat_msg = "ip=" +ip_address+ "&" +node_id ; | ||
|
||
post_request(client, "/api/init/", concat_msg, 30); | ||
} | ||
|
||
|
||
void patient_call(RestClient client,String node_id){ | ||
buzzer_sound(); | ||
post_request(client, "/api/bed/", node_id, 10); | ||
} |
18 changes: 18 additions & 0 deletions
18
Codes and More/Hardware Code /rest_post_init_call/utils.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
//#define BUTTON_PIN 0 //D3 | ||
//#define PRESS_PIN 4 //D2 | ||
|
||
//const char* ssid = "Research Lab"; | ||
//const char* password = "research12"; | ||
|
||
void buzzer_sound(){ | ||
|
||
bool toggle = true; | ||
|
||
Serial.println(toggle); | ||
digitalWrite(D2, toggle); | ||
delay(200); | ||
toggle=!toggle; | ||
digitalWrite(D2, toggle); | ||
Serial.println("Button has been pressed!"); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.