Commit initial du projet
This commit is contained in:
commit
a8ed96cb5f
23 files changed
+3037
No files matched your search
@@ -0,0 +1,87 @@
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
#include "SimpleWiNo.h"
|
||||
#include <M5Stack.h>
|
||||
|
||||
//Objet Wino
|
||||
SimpleWiNo wino;
|
||||
|
||||
//Constantes de configuration des noeuds
|
||||
#define ADRESSE_CLUSTER 0x4A89
|
||||
#define ADRESSE_NOEUD 0x0001
|
||||
#define CANAL 7
|
||||
|
||||
//Variables pour le paquet
|
||||
uint8_t txbuf[40];
|
||||
uint8_t packetLen;
|
||||
|
||||
//Constantes de indices de champs du paquet
|
||||
#define ADRESSE_MULTICAST 0x7878
|
||||
#define NB_PAYLOAD 10
|
||||
|
||||
//Procédure de formatage
|
||||
void formaterPaquet(uint8_t* longueur, uint8_t donnees[]){
|
||||
|
||||
*longueur=0;
|
||||
|
||||
//Ajout En-tete
|
||||
wino.encodeUi16(ADRESSE_MULTICAST, &donnees[*longueur]);
|
||||
*longueur +=2;
|
||||
|
||||
//Ajout de la payload
|
||||
for(int i=0; i<NB_PAYLOAD; i++){
|
||||
donnees[*longueur]=random(0,256);
|
||||
*longueur+=1;
|
||||
}
|
||||
}
|
||||
|
||||
void afficherPaquet(uint8_t longueur, uint8_t donnees[]){
|
||||
|
||||
for(int i=0; i<longueur; i++){
|
||||
M5.Lcd.printf("|%02X", donnees[i]);
|
||||
Serial.printf("|%02X", donnees[i]);
|
||||
}
|
||||
M5.Lcd.println("|");
|
||||
Serial.println("|");
|
||||
}
|
||||
|
||||
|
||||
|
||||
int test_envoi=0;
|
||||
|
||||
void setup() {
|
||||
|
||||
//Démarage M5
|
||||
M5.begin();
|
||||
M5.Power.begin();
|
||||
Serial.println("====Emetteur sprint 1====");
|
||||
M5.Lcd.println("====Emetteur sprint 1====");
|
||||
|
||||
delay(3000);
|
||||
|
||||
//Demarage wino
|
||||
wino.init();
|
||||
|
||||
//Adresse cluster
|
||||
wino.set(NODE_PANID, ADRESSE_CLUSTER);
|
||||
//Adresse noeud
|
||||
wino.set(NODE_SHORT_ADDRESS, ADRESSE_NOEUD);
|
||||
//Fréquence de travail
|
||||
wino.set(NODE_CHANNEL, CANAL);
|
||||
|
||||
//Générateur de payload aléatoire
|
||||
randomSeed(analogRead(30));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
wino.process();
|
||||
|
||||
if(test_envoi==0){
|
||||
M5.Lcd.println("====Envoi Paquet====");
|
||||
Serial.println("====Envoi Paquet====");
|
||||
formaterPaquet(&packetLen, txbuf);
|
||||
afficherPaquet(packetLen, txbuf);
|
||||
wino.send(0xFFFF, txbuf, packetLen);
|
||||
test_envoi+=1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user