Skip to content

Commit

Permalink
i
Browse files Browse the repository at this point in the history
  • Loading branch information
mandresuri committed Apr 17, 2018
1 parent 3f667cb commit 00295f8
Show file tree
Hide file tree
Showing 12 changed files with 422 additions and 61 deletions.
4 changes: 3 additions & 1 deletion ATOME/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^1.1.16" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<engine name="android" spec="7.0.0" />
<plugin name="cordova-plugin-bluetooth-serial" spec="^0.4.7" />
<engine name="android" spec="~7.0.0" />
<allow-navigation href="http://192.168.0.6:8100" />
</widget>
5 changes: 4 additions & 1 deletion ATOME/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
"@angular/http": "5.2.9",
"@angular/platform-browser": "5.2.9",
"@angular/platform-browser-dynamic": "5.2.9",
"@ionic-native/bluetooth-serial": "^4.7.0",
"@ionic-native/core": "4.6.0",
"@ionic-native/splash-screen": "4.6.0",
"@ionic-native/status-bar": "4.6.0",
"@ionic/pro": "1.0.20",
"@ionic/storage": "2.1.3",
"angularfire2": "^5.0.0-rc.6.0",
"cordova-android": "7.0.0",
"cordova-plugin-bluetooth-serial": "^0.4.7",
"cordova-plugin-device": "^2.0.1",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.2.0",
Expand All @@ -52,7 +54,8 @@
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {}
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-bluetooth-serial": {}
},
"platforms": [
"android"
Expand Down
25 changes: 8 additions & 17 deletions ATOME/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,12 @@ import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { AuthProvider } from '../providers/auth/auth';
import { BluetoothArduinoService } from '../services/bluetoothArduino/bluetoothArduino.service';
import { BluetoothSerial } from '@ionic-native/bluetooth-serial';

export const firebaseConfig = {
apiKey: "AIzaSyDNRoAfBGD15BUvZyw2bIWhrD57naFCoxI",
authDomain: "atome-77ef6.firebaseapp.com",
databaseURL: "https://atome-77ef6.firebaseio.com",
projectId: "atome-77ef6",
storageBucket: "",
messagingSenderId: "825006961025"
import { FIREBASE_CONFIG } from './firebase.credentials';
import { EstacionesListService } from '../services/estaciones-list/estaciones-list.service';

};

export const config = {
apiKey: "AIzaSyDUz7IJOCgsz5Zk9HBoU0cwF9z2Q229LtI",
authDomain: "tiendq-3d47a.firebaseapp.com",
databaseURL: "https://tiendq-3d47a.firebaseio.com",
storageBucket: "tiendq-3d47a.appspot.com",
messagingSenderId: "12950516640"
};


@NgModule({
Expand All @@ -40,7 +28,7 @@ export const config = {
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(firebaseConfig),
AngularFireModule.initializeApp(FIREBASE_CONFIG),
AngularFireDatabaseModule,
AngularFireAuthModule
],
Expand All @@ -52,6 +40,9 @@ export const config = {
providers: [
StatusBar,
SplashScreen,
BluetoothArduinoService,
BluetoothSerial,
EstacionesListService,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AuthProvider,
]
Expand Down
17 changes: 17 additions & 0 deletions ATOME/src/app/firebase.credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const FIREBASE_CONFIG = {
apiKey: "AIzaSyDNRoAfBGD15BUvZyw2bIWhrD57naFCoxI",
authDomain: "atome-77ef6.firebaseapp.com",
databaseURL: "https://atome-77ef6.firebaseio.com",
projectId: "atome-77ef6",
storageBucket: "",
messagingSenderId: "825006961025"
}

// export const FIREBASE_CONFIG = {
// apiKey: "AIzaSyDUz7IJOCgsz5Zk9HBoU0cwF9z2Q229LtI",
// authDomain: "tiendq-3d47a.firebaseapp.com",
// databaseURL: "https://tiendq-3d47a.firebaseio.com",
// projectId: "tiendq-3d47a",
// storageBucket: "tiendq-3d47a.appspot.com",
// messagingSenderId: "12950516640"
// }
6 changes: 5 additions & 1 deletion ATOME/src/app/models/estacion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export interface Estacion {
key?: string;
nombre: string;
descripcion: string
descripcion: string;
id: string;
mac: string;
clase: string;
}
27 changes: 20 additions & 7 deletions ATOME/src/pages/crear-bitacora/crear-bitacora.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@
<ion-content padding>

<ion-item>
<ion-label>Estacion de Trabajo:<br></ion-label>
<ion-select [(ngModel)]="selectedvalue" (change)="onChange()" >
<ion-option *ngFor="let item of items | async" >
<h2> {{item.nombre}}</h2>
</ion-option>
</ion-select>
<ion-label>Estacion de Trabajo: {{device.name}}<br></ion-label>
</ion-item>
<ion-row>
<button ion-button><ion-icon name="bluetooth"></ion-icon></button>
<button ion-button (click)="conectar(device)"><ion-icon name="bluetooth"></ion-icon></button>
<button ion-button (click)="desconectar()"><ion-icon name="bluetooth"></ion-icon></button>
<button ion-button (click)="pedirAltura()"></button>
<ion-item>
<ion-label>{{estadoConexion}}</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label>{{recibido}}</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label>{{altura}}</ion-label>
<ion-input></ion-input>
</ion-item>
<ion-item>
<ion-label>{{tiempo}}</ion-label>
<ion-input></ion-input>
</ion-item>
</ion-row>

<ion-fab right bottom>
Expand Down
125 changes: 122 additions & 3 deletions ATOME/src/pages/crear-bitacora/crear-bitacora.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, MenuController } from 'ionic-angular';
import { IonicPage, NavController, NavParams, MenuController, Platform, AlertController } from 'ionic-angular';
import { AngularFireObject , AngularFireList } from 'angularfire2/database';
import { AngularFireDatabase } from 'angularfire2/database';
import { Observable } from 'rxjs/Observable';
import { BluetoothArduinoService } from '../../services/bluetoothArduino/bluetoothArduino.service';

/**
* Generated class for the CrearBitacoraPage page.
Expand All @@ -17,18 +18,39 @@ import { Observable } from 'rxjs/Observable';
templateUrl: 'crear-bitacora.html',
})
export class CrearBitacoraPage {
tiempo: any;
altura: any;
recibido: string = "";
mensaje: string = "";
device: any;
items: Observable<any[]>;
estadoConexion:string;

public selectedvalue;
constructor(public navCtrl: NavController, public navParams: NavParams,
constructor(public navCtrl: NavController,
public navParams: NavParams,
private database: AngularFireDatabase,
public menu: MenuController,
private bluetooth: BluetoothArduinoService,
private platform: Platform,
private alertCtrl: AlertController
) {
this.device = this.navParams.get('deviceConectado');
console.log('carga estaciones');
this.items = database.list('estacion').valueChanges();
console.log('selecciona');
console.log(this.selectedvalue);
}
ionViewDidEnter() {
this.device = this.navParams.get('deviceConectado');
this.estadoConexion = "No Conectado"

//this.recibido = this.bluetooth.recibido;
//this.bluetooth.revisar_conexion(this.device);
//this.bluetooth.conectar(this.device.id).then(()=>{
// this.pedirParametros();
//});
}
menu1Active() {
this.menu.enable(true, 'menu1');
}
Expand All @@ -37,9 +59,106 @@ export class CrearBitacoraPage {
console.log(this.selectedvalue);
}

conectar(seleccion){

this.bluetooth.bluetoothSerial.isConnected().then(
isConnected => {
let alert = this.alertCtrl.create({
title: 'Reconectar',
message: '¿Desea reconectar a este dispositivo?',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: 'Aceptar',
handler: () => {
this.bluetooth.desconectar();
this.bluetooth.conectar(seleccion.id).then(success => {
this.bluetooth.presentToast(success);
}, fail => {
this.bluetooth.presentToast(fail);
});
}
}
]
});
alert.present();
}, notConnected => {
let alert = this.alertCtrl.create({
title: 'Conectar',
message: '¿Desea conectar el dispositivo?',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: 'Aceptar',
handler: () => {
this.bluetooth.conectar(seleccion.id).then(success => {
this.bluetooth.presentToast(success);
this.estadoConexion = "conectada";
this.bluetooth.mensaje = "2";
this.enviarMensajes();

}, fail => {
this.bluetooth.presentToast(fail);
});
}
}
]
});
alert.present();
});
}

enviarMensajes() {
this.bluetooth.conexionMensajes = this.bluetooth.dataInOut(this.mensaje).subscribe(data => {
let entrada = data.substr(0, data.length - 1);
if (entrada != ">") {
if (entrada != "") {
this.recibido = entrada;
if(entrada.substr(0,2)==="a:"){
this.altura = entrada.substr(2,entrada.length - 1);
//this.altura = entrada.length;
}else if(entrada.substr(0,2)==="t:"){
this.tiempo = entrada.substr(2,entrada.length - 1);
}else if(entrada==="PRACTICA NO LISTA"){
//HAZ LO TUYO;
}

console.log(`Entrada: ${entrada}`);
this.bluetooth.presentToast(entrada);
}
} else {
this.bluetooth.conexionMensajes.unsubscribe();
}
this.mensaje = "";
//this.recibido = "";
});
}

desconectar(){
this.bluetooth.desconectar();

}

iniciarPractica(){
console.log('inicia la practica');

this.mensaje = "1"
this.enviarMensajes();
}
pedirAltura(){
this.mensaje = "2"
this.enviarMensajes();
}

ionViewDidLoad() {
Expand Down
44 changes: 21 additions & 23 deletions ATOME/src/pages/estaciones/estaciones.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,30 @@
<ion-card ion-item >
<!-- *ngFor="let bitacora of bitacoras let i = index" -->
<div class="borde">
<ion-item>
<ion-card-content>

<ion-card-title>
Pendulo Simple
</ion-card-title>
<p class="desc">
descripcion
</p>

<ion-row class="opciones">

<ion-col>
<div class="izq">
<button class="opcion puntos"(click)="openPageHija('CrearBitacoraPage')" ><ion-icon name="checkmark"></ion-icon><br>Seleccionar</button>
</div>
</ion-col>
</ion-row>

</ion-card-content>

</ion-item>
<ion-refresher *ngIf="mostrarSpiner === false" (ionRefresh)="refresh_bluetooth($event)">
<ion-refresher-content refreshingText="Buscando dispositivos bluetooth"></ion-refresher-content>
</ion-refresher>
<ion-segment [hidden]="mostrarSpiner === false" align="center">
<ion-spinner></ion-spinner>
Buscando dispositivos bluetooth
</ion-segment>
<ion-item-group>
<ion-item-sliding *ngFor="let device of devices">
<button (click)="openPageHija('CrearBitacoraPage',device)" ion-item>
<h3>Nombre: {{device.name}}</h3>
<p>Id: {{device.id}}</p>
<p>Dirección <span [hidden]="device.address == undefined">mac</span><span [hidden]="device.uuid == undefined">uuid</span>: {{device.address}}{{device.uuid}}</p>
<p><span [hidden]="device.class == undefined">Clase</span><span [hidden]="device.rssi == undefined">Rssi</span>: {{device.class}}{{device.rssi}}</p>
</button>
</ion-item-sliding>
</ion-item-group>

</div>
</ion-card>

</ion-list>

<div [hidden]="li_devices.length > 0 || mostrarSpiner == true" align="center">
<p>No se han encontrado dispositivos desliza hacia abajo para volver a buscar</p>
</div>

</ion-content>
Loading

0 comments on commit 00295f8

Please sign in to comment.