Skip to content

Commit 47bcabf

Browse files
committed
Merge branch 'main' of https://github.com/DanielSRS/mcute into main
2 parents b454dfb + 7f0581d commit 47bcabf

File tree

4 files changed

+420
-332
lines changed

4 files changed

+420
-332
lines changed

IHM_Remote/src/App.tsx

+82-41
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface history {
2424
values: number[];
2525
}
2626

27-
const client = new Paho.Client('192.168.1.2', 9001, '', Date.now().toString());
27+
const client = new Paho.Client('10.0.0.101', 9001, '', Date.now().toString());
2828

2929
const App = () => {
3030
const [latestData, setLatestData] = useState([{ value: 0 }]);
@@ -139,6 +139,26 @@ const App = () => {
139139

140140
const unusableArea = 35 + 40 + 36;
141141

142+
const turnOnLed = () => {
143+
const buffer = new ArrayBuffer(3);
144+
const charArray = new Uint8Array(buffer);
145+
//charArray.set(0, 0x2);
146+
charArray[0] = 0x06;
147+
charArray[1] = 0x06;
148+
charArray[2] = 0x06;
149+
client.publish('comand', charArray, 2, false);
150+
};
151+
152+
const turnOfLed = () => {
153+
const buffer = new ArrayBuffer(3);
154+
const charArray = new Uint8Array(buffer);
155+
//charArray.set(0, 0x2);
156+
charArray[0] = 0x09;
157+
charArray[1] = 0x09;
158+
charArray[2] = 0x09;
159+
client.publish('comand', charArray, 2, false);
160+
};
161+
142162
return (
143163
<ScrollView style={[styles.container, { backgroundColor: color }]}>
144164
<View style={{ padding: 20, backgroundColor: 'red' }}>
@@ -475,46 +495,54 @@ const App = () => {
475495
adjustToWidth={true}
476496
/>
477497
</View>
478-
<TouchableOpacity
479-
style={styles.button}
480-
disabled={client.isConnected()}
481-
onPress={() => {
482-
if (client.isConnected()) {
483-
Alert.alert('Ja tá conectado');
484-
return;
485-
}
486-
client.connect({
487-
userName: 'aluno',
488-
password: '@luno*123',
489-
onFailure: f => console.log('Failure', f),
490-
onSuccess: () => {
491-
console.log('Sucesso');
492-
client.subscribe('analogic/history', {
493-
onSuccess: d => {
494-
console.log('incrito em analogic/history');
495-
},
496-
});
497-
client.subscribe('5/history', {
498-
onSuccess: d => {
499-
console.log('incrito em 5/history');
500-
},
501-
});
502-
client.subscribe('16/history', {
503-
onSuccess: d => {
504-
console.log('incrito em 16/history');
505-
},
506-
});
507-
client.subscribe('update_interval', {
508-
onSuccess: d => {
509-
console.log('incrito em update_interval');
510-
},
511-
});
512-
},
513-
reconnect: true,
514-
});
515-
}}>
516-
<Text>{client.isConnected() ? 'Conectado ✅' : 'Conectar 📡'}</Text>
517-
</TouchableOpacity>
498+
<View style={{ flexDirection: 'row' }}>
499+
<TouchableOpacity
500+
style={styles.block}
501+
disabled={client.isConnected()}
502+
onPress={() => {
503+
if (client.isConnected()) {
504+
Alert.alert('Ja tá conectado');
505+
return;
506+
}
507+
client.connect({
508+
userName: 'aluno',
509+
password: '@luno*123',
510+
onFailure: f => console.log('Failure', f),
511+
onSuccess: () => {
512+
console.log('Sucesso');
513+
client.subscribe('analogic/history', {
514+
onSuccess: () => {
515+
console.log('incrito em analogic/history');
516+
},
517+
});
518+
client.subscribe('5/history', {
519+
onSuccess: () => {
520+
console.log('incrito em 5/history');
521+
},
522+
});
523+
client.subscribe('16/history', {
524+
onSuccess: () => {
525+
console.log('incrito em 16/history');
526+
},
527+
});
528+
client.subscribe('update_interval', {
529+
onSuccess: () => {
530+
console.log('incrito em update_interval');
531+
},
532+
});
533+
},
534+
reconnect: true,
535+
});
536+
}}>
537+
<Text>{client.isConnected() ? 'Conectado ✅' : 'Conectar 📡'}</Text>
538+
</TouchableOpacity>
539+
<TouchableOpacity onPress={turnOnLed} style={styles.block}>
540+
<Text>Ligar o led</Text>
541+
</TouchableOpacity>
542+
<TouchableOpacity onPress={turnOfLed} style={styles.block}>
543+
<Text>Desligar o led</Text>
544+
</TouchableOpacity>
545+
</View>
518546
{/*}
519547
<TouchableOpacity
520548
disabled={!client.isConnected()}
@@ -546,6 +574,19 @@ const styles = StyleSheet.create({
546574
title: {
547575
fontSize: 40,
548576
},
577+
block: {
578+
height: 150,
579+
width: 150,
580+
borderRadius: 10,
581+
borderWidth: 1,
582+
borderColor: 'rgba(0, 0, 0, 0.05)',
583+
justifyContent: 'center',
584+
alignContent: 'center',
585+
display: 'flex',
586+
backgroundColor: '#FFFFFF3F',
587+
padding: 10,
588+
marginHorizontal: 5,
589+
},
549590
});
550591

551592
export default App;

NodeMCU.ino

-172
This file was deleted.

0 commit comments

Comments
 (0)