Other Parts Discussed in Thread: CC3100, CC2530, TM4C123GH6PM, EK-TM4C1294XL
#ifndef __CC3200R1M1RGC__
#include <SPI.h>
#endif
#include <WiFi.h>
#include "PubNub.h"
#include <aJSON.h>
#include <Wire.h>
#include <WiFiClient.h>
#include <Temboo.h>
#include "TembooAccount.h"
#include <RF430CL.h>
#include <NDEF.h>
#include <NDEF_URI.h>
#include <NDEF_TXT.h>
#define APP_NAME "TFG-2017_MOHAMED RAHALI"
#define RF430CL330H_BOOSTERPACK_RESET_PIN 8
#define RF430CL330H_BOOSTERPACK_IRQ_PIN 12
RF430 nfc(RF430CL330H_BOOSTERPACK_RESET_PIN, RF430CL330H_BOOSTERPACK_IRQ_PIN);
//****************************************************************************************************************//
// RFID/NFC FUNCTION //
//****************************************************************************************************************//
void RF430CL (void){
Serial.println("Initializing I2C-");
Wire.begin();
Serial.println("Initializing NFC Tag-");
nfc.begin();
Serial.println("Declaring URL object-");
NDEF_URI tiweb("https://freeboard.io/board/yMSkFJ");
Serial.println("Declaring text description for the URL-");
NDEF_TXT tidesc("es", "TFG_2017 REALIZADO POR MOHAMED RAHALI");
Serial.println("Writing URL object to NFC transceiver-");
int ndef_size;
// RECORD 0
ndef_size = tiweb.sendTo(nfc, true, false); // This message should set MB, but not ME.
Serial.println("Writing Text object to NFC transceiver-");
// RECORD 1
ndef_size += tidesc.sendTo(nfc, false, true); // This message should leave MB cleared, but set ME.
Serial.println("Activating NFC transceiver-");
nfc.enable();
//
// Serial.println("Printing URL to Serial port-");
// tiweb.printURI(Serial); // Test the NDEF_URI printURI() feature
// Serial.println();
//
// Serial.println("Printing text description to Serial port-");
// Serial.println(tidesc.getText());
}
//------------------------------------- VARIABLES -------------------------------------//
double randomDouble(double min, double max, int numCasas){
long _min = min * pow(10, numCasas) + 0.1;
long _max = max * pow(10, numCasas) + 0.1;
return (double) random(_min, _max) / pow(10, numCasas) ;
}
double Freq = randomDouble(10.71, 10.79, 2)+1839755.00;
double voltage_1 = randomDouble(0.82, 0.88, 2);
double temperature = randomDouble(18.30, 20.00, 2);
double vol = randomDouble(3.10, 3.29, 2);
unsigned long lastConnectionTime = 0; // Last time you connected to the server, in milliseconds
boolean lastConnected = false; // State of the connection last time through the main loop
const unsigned long postingInterval = 0.001*1000; // Delay between updates to ThingSpeak.com
int failedCounter = 0;
char buffer[25]; //buffer for float to string
// Network Settings
char ssid[] = "TP-LINK_4B41C0"; // Network name (SSID)
char password[] = "L@F@mili@R@h@li/10"; // Network password
int keyIndex = 0; // Network key Index number (needed only for WEP)
WiFiServer server(80);
WiFiClient client_1;
WiFiClient *client; // WiFiClient client;
//------------------------------------- floatToString Method -------------------------------------//
String floatToString(float x, byte precision = 4) {
char tmp[50];
dtostrf(x, 0, precision, tmp);
return String(tmp);
}
//****************************************************************************************************************
// PubNub Credencial & send function
//****************************************************************************************************************
const static char pubkey[] = "pub-c-f00e3441-95d8-4d27-a4fb-d03fb4def8ae";
const static char subkey[] = "sub-c-9d695234-13ad-11e7-894d-0619f8945a4f";
const static char channel[] = "Channel-mohamed";
int sn = 0;
aJsonObject *createMessage()
{
aJsonObject *msg = aJson.createObject();
aJsonObject *sender = aJson.createObject();
double Freq = randomDouble(10.71, 10.79, 2)+1839755.00;
double voltage_1 = randomDouble(0.82, 0.88, 2);
double temperature = randomDouble(18.30, 20.00, 2);
double vol = randomDouble(3.10, 3.29, 2);
aJson.addStringToObject(sender, "name", "CC3100");
aJson.addItemToObject(msg, "sender", sender);
aJson.addNumberToObject(msg, "sn", sn);
aJson.addNumberToObject(msg, "FreqTiva", Freq);
aJson.addNumberToObject(msg, "VolTiva", voltage_1);
aJson.addNumberToObject(msg, "TempNodos", temperature);
aJson.addNumberToObject(msg, "voltNodos", vol);
sn++;
if (sn == 9999) {
sn = 0;
}
return msg;
}
void dumpMessage(Stream &s, aJsonObject *msg)
{
int msg_count = aJson.getArraySize(msg);
for (int j = 0; j < msg_count; j++) {
aJsonObject *item, *sender, *value;
s.print("Msg #");
s.println(j, DEC);
item = aJson.getArrayItem(msg, j);
if (!item) {
s.println("item not acquired");
delay(100);
return;
}
/* Below, we parse and dump messages from fellow Arduinos. */
sender = aJson.getObjectItem(item, "sender");
if (!sender) {
s.println("sender not acquired");
delay(100);
return;
}
s.println();
}
}
//*****************************************************************************
// WiFiConfig
// Configure Wifi settings, connect to the net and create a web server
//*****************************************************************************
void WifiSettings(void){
Serial.print("Attempting to connect to Network named: "); // attempt to connect to Wifi network
Serial.println(ssid); // print the network name (SSID)
WiFi.begin(ssid, password); // Connect to WPA/WPA2 network. Change this line if using open or WEP network
while ( WiFi.status() != WL_CONNECTED) {
Serial.print("."); // Print dots while waiting for connection
delay(300);
}
Serial.println("\nYou're connected to the network");
Serial.println("Waiting for an ip address");
while (WiFi.localIP() == INADDR_NONE) {
Serial.print("."); // Print dots while we wait for an ip addresss
delay(300);
}
Serial.println("\nIP Address obtained");
printWifiStatus();
}
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/* CALL-PHONE FUNCTION */
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
void callphone(void) {
TembooChoreo ConfirmTextToSpeechPromptChoreo(client_1);
// Set Temboo account credentials
ConfirmTextToSpeechPromptChoreo.setAccountName(TEMBOO_ACCOUNT);
ConfirmTextToSpeechPromptChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
ConfirmTextToSpeechPromptChoreo.setAppKey(TEMBOO_APP_KEY);
// Set Choreo inputs
String CallbackURLValue = "http://192.168.0.105/";
ConfirmTextToSpeechPromptChoreo.addInput("CallbackURL", CallbackURLValue);
String APIKeyValue = "7ed8a7a3";
//String APIKeyValue = "9f187a57";
ConfirmTextToSpeechPromptChoreo.addInput("APIKey", APIKeyValue);
String LanguageValue = "es-mx";
ConfirmTextToSpeechPromptChoreo.addInput("Language", LanguageValue);
String ByeTextValue = "El valor actual de frecuencia_tiva es de ";
ByeTextValue = ByeTextValue + (Freq/1000000) + " MHz. El voltaje_tiva detectado es de " + voltage_1;
ByeTextValue = ByeTextValue + ", la temperatura_Nodo1 es" + temperature + ", el voltaje_Nodo1 es" + vol;
ByeTextValue = ByeTextValue + ", la temperatura_Nodo2 es" + temperature + ", el voltaje_Nodo2 es" + vol + ". El informe de estado del equipo ha terminado. Hasta pronto.";
ConfirmTextToSpeechPromptChoreo.addInput("ByeText", ByeTextValue);
String TextValue = "CC3100 Remotes Updates. Niveles dentro de rango de seguridad.";
TextValue = TextValue + ", . Pulse uno para conocer los valores actuales de los parámetros de medida.";
ConfirmTextToSpeechPromptChoreo.addInput("Text", TextValue);
String FromValue = "Mohamed Rahali";
ConfirmTextToSpeechPromptChoreo.addInput("From", FromValue);
String ToValue = "34631113994";
//String ToValue = "34659962980";
ConfirmTextToSpeechPromptChoreo.addInput("To", ToValue);
String FailedTextValue = "Por favor. Pulse uno para conocer valores medios de las últimas 24 horas";
ConfirmTextToSpeechPromptChoreo.addInput("FailedText", FailedTextValue);
String MaxDigitsValue = "1";
ConfirmTextToSpeechPromptChoreo.addInput("MaxDigits", MaxDigitsValue);
String PinCodeValue = "1";
ConfirmTextToSpeechPromptChoreo.addInput("PinCode", PinCodeValue);
String APISecretValue = "aef89c1b5c48e7e1";
//String APISecretValue = "ba44ab82a0996581";
ConfirmTextToSpeechPromptChoreo.addInput("APISecret", APISecretValue);
// Identify the Choreo to run
ConfirmTextToSpeechPromptChoreo.setChoreo("/Library/Nexmo/Voice/ConfirmTextToSpeechPrompt");
// Run the Choreo
unsigned int returnCode = ConfirmTextToSpeechPromptChoreo.run();
// A return code of zero means everything worked
if (returnCode == 0) {
while (ConfirmTextToSpeechPromptChoreo.available()) {
String name = ConfirmTextToSpeechPromptChoreo.readStringUntil('\x1F');
name.trim();
ConfirmTextToSpeechPromptChoreo.find("\x1E");
}
}
ConfirmTextToSpeechPromptChoreo.close();
}
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/* SMS FUNCTION */
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
void SendSMSChoreo (void) {
TembooChoreo SendSMSChoreo(client_1);
// Invoke the Temboo client
SendSMSChoreo.begin();
// Set Temboo account credentials
SendSMSChoreo.setAccountName(TEMBOO_ACCOUNT);
SendSMSChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
SendSMSChoreo.setAppKey(TEMBOO_APP_KEY);
// Set profile to use for execution
SendSMSChoreo.setProfile("SMStwilio");
// Set Choreo inputs
String TimeoutValue = "1";
SendSMSChoreo.addInput("Timeout", TimeoutValue);
String CallbackIDValue = "192.168.0.105";
SendSMSChoreo.addInput("CallbackID", CallbackIDValue);
String BodyValue = "CC3100 REMOTE UPDATES. Niveles dentro de rango de seguridad. la frecuencia_Tiva detectada es de";
BodyValue = BodyValue + (Freq/1000000) + "MHz. El Voltaje_Tiva detectado es de" +voltage_1;
BodyValue = BodyValue + "V, la temperatura_Nodo1 es" + temperature + "°C, el voltaje_Nodo1 es" + vol;
BodyValue = BodyValue + "V, la temperatura_Nodo2 es" + temperature + "°C, el voltaje_Nodo2 es" + vol + "V. El informe de estado ha terminado. Hasta pronto.";
SendSMSChoreo.addInput("Body", BodyValue);
// Identify the Choreo to run
SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS");
// Run the Choreo; when results are available, print them to serial
// 901 time to wait for a Choreo response. Can be edited as needed
// USE_SSL input to tell library to use HTTPS
SendSMSChoreo.run(901, USE_SSL);
while(SendSMSChoreo.available()) {
char c = SendSMSChoreo.read();
Serial.print(c);
}
SendSMSChoreo.close();
}
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/* GMAIL FUNCTION */
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
void SendEmail (void){
TembooChoreo SendEmailChoreo(client_1);
// Invoke the Temboo client
SendEmailChoreo.begin();
// Set Temboo account credentials
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);
// Set Choreo inputs
String FromAddressValue = "cc3100updates@gmail.com";
SendEmailChoreo.addInput("FromAddress", FromAddressValue);
String UsernameValue = "CC3100Updates";
SendEmailChoreo.addInput("Username", UsernameValue);
String ToAddressValue = "medsimorahali@gmail.com";
SendEmailChoreo.addInput("ToAddress", ToAddressValue);
String SubjectValue = "CC3100 TFG";
SendEmailChoreo.addInput("Subject", SubjectValue);
String MessageBodyValue = "CC3100 REMOTE UPDATES. Niveles dentro de rango de seguridad. la frecuencia_Tiva detectada es de";
MessageBodyValue = MessageBodyValue + (Freq/1000000) + "MHz. El Voltaje_Tiva detectado es de" +voltage_1;
MessageBodyValue = MessageBodyValue + "V, la temperatura_Nodo1 es" + temperature + "°C, el voltaje_Nodo1 es" + vol;
MessageBodyValue = MessageBodyValue + "V, la temperatura_Nodo2 es" + temperature + "°C, el voltaje_Nodo2 es" + vol + "V. El informe de estado ha terminado. Hasta pronto.";
SendEmailChoreo.addInput("MessageBody", MessageBodyValue);
String PasswordValue = "jnezwawwhisucjqr";
SendEmailChoreo.addInput("Password", PasswordValue);
// Identify the Choreo to run
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");
// Run the Choreo; when results are available, print them to serial
// 901 time to wait for a Choreo response. Can be edited as needed
// USE_SSL input to tell library to use HTTPS
SendEmailChoreo.run();
while(SendEmailChoreo.available()) {
char c = SendEmailChoreo.read();
Serial.print(c);
}
SendEmailChoreo.close();
}
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/* Twitter FUNCTION */
/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
void Sendtweets (void){
TembooChoreo StatusesUpdateChoreo(client_1);
// Invoke the Temboo client
StatusesUpdateChoreo.begin();
// Set Temboo account credentials
StatusesUpdateChoreo.setAccountName(TEMBOO_ACCOUNT);
StatusesUpdateChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
StatusesUpdateChoreo.setAppKey(TEMBOO_APP_KEY);
// Set Choreo inputs
String StatusUpdateValue ="CC3100 REMOTE UPDATES. F-Tiva= ";
StatusUpdateValue = StatusUpdateValue + (Freq/1000000)+ " MHz. V-Tiva= " + voltage_1;
StatusUpdateValue = StatusUpdateValue + "V, V_Nodo1= " +vol+ "V, t_Nodo1= " +temperature;
StatusUpdateValue = StatusUpdateValue + "°C, V_Nodo2= " +vol+ "V, t_Nodo2= " +temperature+ "°C . Hasta pronto.";
StatusesUpdateChoreo.addInput("StatusUpdate", StatusUpdateValue);
String ConsumerKeyValue = "qCEqTnJi3LRIFDXc5RIPa79Ep";
StatusesUpdateChoreo.addInput("ConsumerKey", ConsumerKeyValue);
String AccessTokenValue = "849004987527163904-OZK4Q1ffHQaYXNxVfjcTKuFsXQ6rUav";
StatusesUpdateChoreo.addInput("AccessToken", AccessTokenValue);
String ConsumerSecretValue = "n4ALjkC2QW5yAHbhKviInza5FrHgGl6Mw8WiuClK0w0s2oYMgD";
StatusesUpdateChoreo.addInput("ConsumerSecret", ConsumerSecretValue);
String AccessTokenSecretValue = "GSLjzTbY3EfHqrl58bCfbKxOKTNSrvQxotyMbI0XjWRzG";
StatusesUpdateChoreo.addInput("AccessTokenSecret", AccessTokenSecretValue);
// Identify the Choreo to run
StatusesUpdateChoreo.setChoreo("/Library/Twitter/Tweets/StatusesUpdate");
// Run the Choreo; when results are available, print them to serial
// 901 time to wait for a Choreo response. Can be edited as needed
// USE_SSL input to tell library to use HTTPS
StatusesUpdateChoreo.run(901, USE_SSL);
while(StatusesUpdateChoreo.available()) {
char c = StatusesUpdateChoreo.read();
Serial.print(c);
}
StatusesUpdateChoreo.close();
}
void setup() {
Serial.begin(115200); // initialize serial communication
WifiSettings();
Serial.println("Starting webserver on port 80");
server.begin(); // start the web server on port 80
Serial.println("Webserver started!");
PubNub.begin(pubkey, subkey);
Serial.println("PubNub set up");
RF430CL();
}
void loop() {
// WiFiClient *client;
/* Publish */
// Serial.print("publishing a message: ");
aJsonObject *msg = createMessage();
char *msgStr = aJson.print(msg);
aJson.deleteItem(msg);
client = PubNub.publish(channel, msgStr);
free(msgStr);
// if (!client) {
// return;
// }
int i = 0;
WiFiClient client_1 = server.available(); // listen for incoming clients to the Web Server
if (client_1) { // if you get a client,
Serial.println("new client"); // print a message out the serial port
char buffer[150] = {
0 }; // make a buffer to hold incoming data // make a buffer to hold incoming data (GREE_LED)
while (client_1.connected()) { // loop while the client's connected
if (client_1.available()) { // if there's bytes to read from the client,
char c = client_1.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
if (c == '\n') { // if the byte is a newline character
if (strlen(buffer) == 0 ) {
client_1.println("HTTP/1.1 200 OK");
client_1.println("Content-Type: text/html");
client_1.println("Connection: close"); // se cierra la conexión una vez se ha respondido a la peticion
client_1.println("\n Refresh: 5"); // se refresca la página automáticamente cada 5 segundos
client_1.println();
client_1.println("<p>PROYECTO REALIZADO EN LAS INSTALACIONES DE LA UCLM POR ");
client_1.println("\n\n");
client_1.println("<span> <strong> MOHAMED RAHALI </strong> </span><\p>");
client_1.println("\n\n");
client_1.println();
client_1.println("<!DOCTYPE HTML>");
client_1.println("<html lang='es'><head><meta charset='UTF-8'><title>"); //client_1.println("<html lang='es'>"); client_1.println("<head>"); client_1.println("<meta charset='UTF-8'>"); //client_1.println("<title>");
client_1.println("SERVICIOS MULTIMEDIA PARA EL CONTROL DE ALERTAS");
client_1.println("<hr>");
client_1.println("</title><link href='http://fonts.googleapis.com/css?family=Roboto:300|Playfair+Display:400'");
client_1.println("rel='stylesheet' type='text/css'/><link rel='stylesheet'");
client_1.println("href='http://static.tumblr.com/pjglohe/2qinf00ga/estilos.min.css'>");
client_1.println("</head><body><div class='page-wrap'><header class='header'>");
client_1.println("<h1><FONT COLOR=FBB233> SERVICIOS MULTIMEDIA PARA EL CONTROL DE ALERTAS </FONT> </h1>");
client_1.println("<hr>");
// mm cuidado h1
client_1.println("<span></H1><FONT COLOR=BLUE><strong><big><big> IoT Web SERVER </big></big></strong></FONT></H1> </span><div class='UCLM'>");
client_1.println("</br>");
client_1.println("<span>Un producto de </span>");
// cuidado aqui es diferente
client_1.println("<a href='http://www3.uclm.es/etsii-cr/' target='_blank'>E.T.S.I.I-CR</a></div>");
client_1.println("<div class='Freeboard'><span>Go to </span>");
client_1.println();
// cuidado aqui es diferente
client_1.println("<a href='https://freeboard.io/board/yMSkFJ' target='_blank'>Freeboard.io</a></div>"); //client_1.println("<a href='ttp://www.uclm.es/' target='_blank'>"); client_1.println("www.educachip.com"); client_1.println("</a>"); client_1.println("</div>");
client_1.println("\n\n");
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// body Multimedia (SMS, Phone call)
client_1.println("</header><section class='content-wrap'><div class='device'>"); //client_1.println("</header>"); client_1.println("<section class='content-wrap'>"); client_1.println("<div class='device'>");
client_1.println("<div class='device-name'><h2>SERVICIO MÓVILES</h2></div><div class='forms'>"); //client_1.println("<div class='device'>"); client_1.println("<div class='device-name'>"); client_1.println("<h2>"); client_1.println("LED VERDE"); client_1.println("</h2>"); client_1.println("</div>"); client_1.println("<div class='forms'>");
client_1.println("<form onClick=location.href='./Multimedia=1\' class='transition button on'>"); //client_1.println("<form class='transition button on'>");
client_1.println("<input type='button' value='SMS'/>");
client_1.println("</form></div><div class='forms'>"); //client_1.println("</form>"); client_1.println("</div>"); client_1.println("<div class='forms'>");
client_1.println("<form onClick=location.href='./Multimedia=0\' class='transition button on'>"); //client_1.println("<form class='transition button off'>");
client_1.println("<input type='button' value='LLAMADA'/>");
client_1.println("</form></div></div>");
client_1.println();
// body Email
client_1.println("</header><section class='content-wrap'><div class='device'>"); //client_1.println("</header>"); client_1.println("<section class='content-wrap'>"); client_1.println("<div class='device'>");
client_1.println("<div class='device-name'><h2>MAIL</h2><div class='forms'>"); //client_1.println("<div class='device'>"); client_1.println("<div class='device-name'>"); client_1.println("<h2>"); client_1.println("LED VERDE"); client_1.println("</h2>"); client_1.println("</div>"); client_1.println("<div class='forms'>");
//aqui solo una de las dos, no todo
client_1.println("<form onClick=location.href='./Mail=1\' class='transition button on'>"); //client_1.println("<form class='transition button on'>");
client_1.println("<input type='button' value='Gmail'/>");
client_1.println("</form></div><div class='forms'>"); //client_1.println("</form>"); client_1.println("</div>"); client_1.println("<div class='forms'>");
client_1.println("<form onClick=location.href='https://mail.google.com/mail/#inbox' class='transition button off'>"); //client_1.println("<form class='transition button off'>");
client_1.println("<input type='button' value='Go to Gmail'/>");
client_1.println("</form></div></div>");
client_1.println();
client_1.println("</form></div>");
// Social Media
client_1.println("</header><section class='content-wrap'><div class='device'>"); //client_1.println("</header>"); client_1.println("<section class='content-wrap'>"); client_1.println("<div class='device'>");
client_1.println("<div class='device-name'><h2>Social Media</h2><div class='forms'>"); //client_1.println("<div class='device'>"); client_1.println("<div class='device-name'>"); client_1.println("<h2>"); client_1.println("LED VERDE"); client_1.println("</h2>"); client_1.println("</div>"); client_1.println("<div class='forms'>");
client_1.println("<form onClick=location.href='./Social=1\' class='transition button on'>"); //client_1.println("<form class='transition button on'>");
client_1.println("<input type='button' value='Twitter'/>");
client_1.println("</form></div><div class='forms'>"); //client_1.println("</form>"); client_1.println("</div>"); client_1.println("<div class='forms'>");
client_1.println("<form onClick=location.href='https://twitter.com/' class='transition button off'>"); //client_1.println("<form class='transition button off'>");
//client_1.println("<a href=https://twitter.com/CC3200_Posts></a>"); //client_1.println("<form class='transition button off'>");
//client_1.println("<a class="w3-btn" href=http://www.w3schools.com>Link Button</a>");
client_1.println("<input type='button' value='Go to Twitter'/>");
//client_1.println("<href=https://twitter.com/CC3200_Posts>");
client_1.println("</form></div></div>"); //client_1.println("</form>"); client_1.println("</div>"); client_1.println("<div class='forms'>");
client_1.println("</form></div>");
client_1.println("</form></div>");
client_1.println("</form></div>");
client_1.println("</form></div>");
client_1.println("</form></div>");
client_1.println();
client_1.println("</div>");
client_1.println("</form>");
client_1.println("</div>");
client_1.println("</div>");
client_1.println("</section>");
client_1.println("</div>");
client_1.println("</body>");
client_1.println("</html>");
// The HTTP response ends with another blank line:
client_1.println();
// break out of the while loop:
break;
}
else { // if you got a newline, then clear the buffer:
memset(buffer, 0, 150);
// memset(buffer2, 0, 150);
i = 0;
}
}
else if (c != '\r') { // if you got anything else but a carriage return character,
buffer[i++] = c; // add it to the end of the currentLine
//buffer2[i++] = c;
}
// Check to see if the client request was "GET /H" or "GET /L":
if (endsWith(buffer, "GET /Multimedia=1" )) {
SendSMSChoreo();
Serial.println("\nSMS was sent\n");
}
if (endsWith(buffer, "GET /Multimedia=0")) {
callphone();
Serial.println("\nPhone call was made");
}
if (endsWith(buffer, "GET /Mail=1")) {
SendEmail();
Serial.println("\nEmail was sent");
}
// if (endsWith(buffer, "GET /Mail=0")) {
//
// }
if (endsWith(buffer, "GET /Social=1")) {
Sendtweets();
Serial.println("\nTwitter was updated");
//
}
// if (endsWith(buffer, "GET /Social=0")) {
//
// }
}
}
client_1.stop(); // close the connection:
Serial.println("client disonnected");
}
//------------------------------------- DLP-RF430CL LOOP -------------------------------------//
if (nfc.loop()) {
if (nfc.wasRead()) {
Serial.println("NDEF tag was read!");
}
nfc.enable();
}
}
//
//a way to check if one array ends with another array
//
boolean endsWith(char* inString, char* compString) {
int compLength = strlen(compString);
int strLength = strlen(inString);
//compare the last "compLength" values of the inString
int i;
for (i = 0; i < compLength; i++) {
char a = inString[(strLength - 1) - i];
char b = compString[(compLength - 1) - i];
if (a != b) {
return false;
}
}
return true;
}
//------------------------------------- printWifiStatus FUNCTION -------------------------------------//
void printWifiStatus() {
Serial.print("SSID: "); // print the SSID of the network you're attached to:
Serial.println(WiFi.SSID());
IPAddress ip = WiFi.localIP(); // print your WiFi IP address:
Serial.print("IP Address: ");
Serial.println(ip);
long rssi = WiFi.RSSI(); // print the received signal strength:
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
Serial.print("To see this page in action, open a browser to http://"); // print where to go in a browser:
Serial.println(ip);
}
Hi all, I have a small problem, and it's the following, I'm working on an application of communication protocols, and I have TIVA hardware, CC2530 AIR MODULE, CC3100 for WIFI, I also work with a DLP-RF430CL330H.
Individually work great, but when I put them together, in a code and I mount all the boosterpack (one on top of another), it does not do anything to me, I do not even see the serial port enabled. And nothing works. And that I just copy and paste the fragments into a single code.
Could someone tell me what the problem might be? Is it some incompatibility of the plates? Or is it something of the software (power) I use?
Could I be activating things I should not have with the code?
How could I solve it? I need information or some help, it's urgent.
Thanks in advance.
I use ENEGRIA IDE. V17 . my code is:
