Permière communication du PAMI en WiFi
This commit is contained in:
parent
b0e750106d
commit
9f4a0b7523
4
.vscode/c_cpp_properties.json
vendored
4
.vscode/c_cpp_properties.json
vendored
@ -7,7 +7,9 @@
|
|||||||
"${env:PICO_SDK_PATH}/src/common/pico_base/include",
|
"${env:PICO_SDK_PATH}/src/common/pico_base/include",
|
||||||
"${env:PICO_SDK_PATH}/build/generated/pico_base",
|
"${env:PICO_SDK_PATH}/build/generated/pico_base",
|
||||||
"${env:PICO_SDK_PATH}/src/common/pico_base/include/pico",
|
"${env:PICO_SDK_PATH}/src/common/pico_base/include/pico",
|
||||||
"${env:PICO_SDK_PATH}/src/common/pico_stdlib/include"
|
"${env:PICO_SDK_PATH}/src/common/pico_stdlib/include",
|
||||||
|
"${env:PICO_SDK_PATH}/lib/cyw43-driver/src/",
|
||||||
|
"${env:PICO_SDK_PATH}/lib/**/include"
|
||||||
],
|
],
|
||||||
"myCompilerPath": "/usr/bin/arm-none-eabi-gcc"
|
"myCompilerPath": "/usr/bin/arm-none-eabi-gcc"
|
||||||
},
|
},
|
||||||
|
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
@ -2,7 +2,7 @@
|
|||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cd build; cmake ../; make",
|
"command": "cd build; cmake ../ -DPICO_BOARD=pico_w; make",
|
||||||
"label": "CMake in build/",
|
"label": "CMake in build/",
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"group": {
|
"group": {
|
||||||
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cd build; cmake ../; make Flash",
|
"command": "cd build; cmake ../ -DPICO_BOARD=pico_w; make Flash",
|
||||||
"label": "CMake & Make & Flash",
|
"label": "CMake & Make & Flash",
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"group": {
|
"group": {
|
||||||
|
@ -20,6 +20,7 @@ add_executable(Mon_Projet
|
|||||||
Localisation.c
|
Localisation.c
|
||||||
main.c
|
main.c
|
||||||
QEI.c
|
QEI.c
|
||||||
|
Teleplot.c
|
||||||
Temps.c
|
Temps.c
|
||||||
Trajectoire_bezier.c
|
Trajectoire_bezier.c
|
||||||
Trajectoire_circulaire.c
|
Trajectoire_circulaire.c
|
||||||
@ -36,7 +37,7 @@ add_executable(Mon_Projet
|
|||||||
|
|
||||||
pico_generate_pio_header(Mon_Projet ${CMAKE_CURRENT_LIST_DIR}/quadrature_encoder.pio)
|
pico_generate_pio_header(Mon_Projet ${CMAKE_CURRENT_LIST_DIR}/quadrature_encoder.pio)
|
||||||
|
|
||||||
target_include_directories(Mon_Projet PRIVATE VL53L8CX_ULD_API/inc/)
|
target_include_directories(Mon_Projet PRIVATE VL53L8CX_ULD_API/inc/ ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
target_link_libraries(Mon_Projet
|
target_link_libraries(Mon_Projet
|
||||||
hardware_adc
|
hardware_adc
|
||||||
@ -45,6 +46,7 @@ target_link_libraries(Mon_Projet
|
|||||||
hardware_pio
|
hardware_pio
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
pico_multicore
|
pico_multicore
|
||||||
|
pico_cyw43_arch_lwip_poll
|
||||||
)
|
)
|
||||||
|
|
||||||
pico_enable_stdio_usb(Mon_Projet 1)
|
pico_enable_stdio_usb(Mon_Projet 1)
|
||||||
|
92
Teleplot.c
Normal file
92
Teleplot.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#include "pico/cyw43_arch.h"
|
||||||
|
#include "Teleplot.h"
|
||||||
|
|
||||||
|
// Si le fichier n'existe pas, créez-le à partir du modèle "wifi_settings.h.default"
|
||||||
|
#include "wifi_settings.h"
|
||||||
|
|
||||||
|
#define BEACON_MSG_LEN_MAX 500
|
||||||
|
|
||||||
|
char teleplot_tampon[BEACON_MSG_LEN_MAX]="";
|
||||||
|
|
||||||
|
struct udp_pcb* pcb;
|
||||||
|
ip_addr_t addr;
|
||||||
|
|
||||||
|
int Teleplot_init(void){
|
||||||
|
if (cyw43_arch_init()) {
|
||||||
|
printf("failed to initialise\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
cyw43_arch_enable_sta_mode();
|
||||||
|
|
||||||
|
printf("Connecting to Wi-Fi...\n");
|
||||||
|
if (cyw43_arch_wifi_connect_timeout_ms(MY_WIFI_SSID, MY_WIFI_PASSWORD, CYW43_AUTH_WPA2_AES_PSK, 30000)) {
|
||||||
|
printf("failed to connect.\n");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
printf("Connected.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
pcb = udp_new();
|
||||||
|
ipaddr_aton(BEACON_TARGET, &addr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void teleplot_udp_send_string(char * message){
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, BEACON_MSG_LEN_MAX+1, PBUF_RAM);
|
||||||
|
char *req = (char *)p->payload;
|
||||||
|
memset(req, 0, BEACON_MSG_LEN_MAX+1);
|
||||||
|
|
||||||
|
snprintf(req, BEACON_MSG_LEN_MAX, "%s", message);
|
||||||
|
|
||||||
|
err_t er = udp_sendto(pcb, p, &addr, UDP_PORT);
|
||||||
|
|
||||||
|
pbuf_free(p);
|
||||||
|
if (er != ERR_OK) {
|
||||||
|
printf("Failed to send UDP packet! error=%d", er);
|
||||||
|
} else {
|
||||||
|
printf("Sent packet %d\n", counter);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note in practice for this simple UDP transmitter,
|
||||||
|
// the end result for both background and poll is the same
|
||||||
|
|
||||||
|
#if PICO_CYW43_ARCH_POLL
|
||||||
|
// if you are using pico_cyw43_arch_poll, then you must poll periodically from your
|
||||||
|
// main loop (not from a timer) to check for Wi-Fi driver or lwIP work that needs to be done.
|
||||||
|
cyw43_arch_poll();
|
||||||
|
#else
|
||||||
|
// if you are not using pico_cyw43_arch_poll, then WiFI driver and lwIP work
|
||||||
|
// is done via interrupt in the background. This sleep is just an example of some (blocking)
|
||||||
|
// work you might be doing.
|
||||||
|
// sleep_ms(BEACON_INTERVAL_MS);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Teleplot_ajout_ou_envoie_tampon(char * message){
|
||||||
|
// Si le tampon ne peut pas accueillir le prochain message
|
||||||
|
// On envoie et on vide le tampon
|
||||||
|
if(strlen(message) + strlen(teleplot_tampon) > BEACON_MSG_LEN_MAX){
|
||||||
|
teleplot_udp_send_string(teleplot_tampon);
|
||||||
|
teleplot_tampon[0]='\0'; // On "vide" le tampon
|
||||||
|
}
|
||||||
|
// On ajoute le message au tampon
|
||||||
|
strcat(teleplot_tampon, message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Teleplot_add_variable_float_2decimal(char * nom_variable, float valeur){
|
||||||
|
char tampon[100];
|
||||||
|
sprintf(tampon, "%s:%lu:%.2f\n", nom_variable, (long)time_us_64()/1000, valeur);
|
||||||
|
Teleplot_ajout_ou_envoie_tampon(tampon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Teleplot_add_variable_int(char * nom_variable, int valeur){
|
||||||
|
char tampon[100];
|
||||||
|
sprintf(tampon, "%s:%lu:%d\n", nom_variable, (long)time_us_64()/1000, valeur);
|
||||||
|
Teleplot_ajout_ou_envoie_tampon(tampon);
|
||||||
|
}
|
5
Teleplot.h
Normal file
5
Teleplot.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
int Teleplot_init(void);
|
||||||
|
void teleplot_udp_send_string(char * message);
|
||||||
|
void Teleplot_add_variable_float_2decimal(char * nom_variable, float valeur);
|
||||||
|
void Teleplot_add_variable_int(char * nom_variable, int valeur);
|
||||||
|
|
@ -145,8 +145,8 @@ void VL53L8_lecture(VL53L8CX_Configuration * Dev, VL53L8CX_ResultsData * Results
|
|||||||
printf("%d,", Results->distance_mm[col+ 8*row]);
|
printf("%d,", Results->distance_mm[col+ 8*row]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VL53L8_min_distance(VL53L8CX_ResultsData Results, float *distance){
|
int VL53L8_min_distance(VL53L8CX_ResultsData Results, float *distance){
|
||||||
|
10
lwipopts.h
Normal file
10
lwipopts.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef _LWIPOPTS_H
|
||||||
|
#define _LWIPOPTS_H
|
||||||
|
|
||||||
|
// Generally you would define your own explicit list of lwIP options
|
||||||
|
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
|
||||||
|
//
|
||||||
|
// This example uses a common include to avoid repetition
|
||||||
|
#include "lwipopts_examples_common.h"
|
||||||
|
|
||||||
|
#endif
|
90
lwipopts_examples_common.h
Normal file
90
lwipopts_examples_common.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#ifndef _LWIPOPTS_EXAMPLE_COMMONH_H
|
||||||
|
#define _LWIPOPTS_EXAMPLE_COMMONH_H
|
||||||
|
|
||||||
|
|
||||||
|
// Common settings used in most of the pico_w examples
|
||||||
|
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html for details)
|
||||||
|
|
||||||
|
// allow override in some examples
|
||||||
|
#ifndef NO_SYS
|
||||||
|
#define NO_SYS 1
|
||||||
|
#endif
|
||||||
|
// allow override in some examples
|
||||||
|
#ifndef LWIP_SOCKET
|
||||||
|
#define LWIP_SOCKET 0
|
||||||
|
#endif
|
||||||
|
#if PICO_CYW43_ARCH_POLL
|
||||||
|
#define MEM_LIBC_MALLOC 1
|
||||||
|
#else
|
||||||
|
// MEM_LIBC_MALLOC is incompatible with non polling versions
|
||||||
|
#define MEM_LIBC_MALLOC 0
|
||||||
|
#endif
|
||||||
|
#define MEM_ALIGNMENT 4
|
||||||
|
#define MEM_SIZE 4000
|
||||||
|
#define MEMP_NUM_TCP_SEG 32
|
||||||
|
#define MEMP_NUM_ARP_QUEUE 10
|
||||||
|
#define PBUF_POOL_SIZE 24
|
||||||
|
#define LWIP_ARP 1
|
||||||
|
#define LWIP_ETHERNET 1
|
||||||
|
#define LWIP_ICMP 1
|
||||||
|
#define LWIP_RAW 1
|
||||||
|
#define TCP_WND (8 * TCP_MSS)
|
||||||
|
#define TCP_MSS 1460
|
||||||
|
#define TCP_SND_BUF (8 * TCP_MSS)
|
||||||
|
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
|
||||||
|
#define LWIP_NETIF_STATUS_CALLBACK 1
|
||||||
|
#define LWIP_NETIF_LINK_CALLBACK 1
|
||||||
|
#define LWIP_NETIF_HOSTNAME 1
|
||||||
|
#define LWIP_NETCONN 0
|
||||||
|
#define MEM_STATS 0
|
||||||
|
#define SYS_STATS 0
|
||||||
|
#define MEMP_STATS 0
|
||||||
|
#define LINK_STATS 0
|
||||||
|
// #define ETH_PAD_SIZE 2
|
||||||
|
#define LWIP_CHKSUM_ALGORITHM 3
|
||||||
|
#define LWIP_DHCP 1
|
||||||
|
#define LWIP_IPV4 1
|
||||||
|
#define LWIP_TCP 1
|
||||||
|
#define LWIP_UDP 1
|
||||||
|
#define LWIP_DNS 1
|
||||||
|
#define LWIP_TCP_KEEPALIVE 1
|
||||||
|
#define LWIP_NETIF_TX_SINGLE_PBUF 1
|
||||||
|
#define DHCP_DOES_ARP_CHECK 0
|
||||||
|
#define LWIP_DHCP_DOES_ACD_CHECK 0
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
#define LWIP_DEBUG 1
|
||||||
|
#define LWIP_STATS 1
|
||||||
|
#define LWIP_STATS_DISPLAY 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ETHARP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define NETIF_DEBUG LWIP_DBG_OFF
|
||||||
|
#define PBUF_DEBUG LWIP_DBG_OFF
|
||||||
|
#define API_LIB_DEBUG LWIP_DBG_OFF
|
||||||
|
#define API_MSG_DEBUG LWIP_DBG_OFF
|
||||||
|
#define SOCKETS_DEBUG LWIP_DBG_OFF
|
||||||
|
#define ICMP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define INET_DEBUG LWIP_DBG_OFF
|
||||||
|
#define IP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define IP_REASS_DEBUG LWIP_DBG_OFF
|
||||||
|
#define RAW_DEBUG LWIP_DBG_OFF
|
||||||
|
#define MEM_DEBUG LWIP_DBG_OFF
|
||||||
|
#define MEMP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define SYS_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_RTO_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_CWND_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_WND_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_FR_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCP_RST_DEBUG LWIP_DBG_OFF
|
||||||
|
#define UDP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define TCPIP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define PPP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define SLIP_DEBUG LWIP_DBG_OFF
|
||||||
|
#define DHCP_DEBUG LWIP_DBG_OFF
|
||||||
|
|
||||||
|
#endif /* __LWIPOPTS_H__ */
|
5
main.c
5
main.c
@ -13,6 +13,7 @@
|
|||||||
#include "i2c_maitre.h"
|
#include "i2c_maitre.h"
|
||||||
#include "Localisation.h"
|
#include "Localisation.h"
|
||||||
#include "Moteurs.h"
|
#include "Moteurs.h"
|
||||||
|
#include "Teleplot.h"
|
||||||
#include "Temps.h"
|
#include "Temps.h"
|
||||||
#include "Trajectoire.h"
|
#include "Trajectoire.h"
|
||||||
#include "Trajet.h"
|
#include "Trajet.h"
|
||||||
@ -66,6 +67,7 @@ void main(void)
|
|||||||
identifiant_init();
|
identifiant_init();
|
||||||
Localisation_init(identifiant_lire());
|
Localisation_init(identifiant_lire());
|
||||||
Trajet_init(identifiant_lire());
|
Trajet_init(identifiant_lire());
|
||||||
|
Teleplot_init();
|
||||||
i2c_maitre_init();
|
i2c_maitre_init();
|
||||||
|
|
||||||
|
|
||||||
@ -83,6 +85,7 @@ void main(void)
|
|||||||
|
|
||||||
//multicore_launch_core1(gestion_affichage);
|
//multicore_launch_core1(gestion_affichage);
|
||||||
multicore_launch_core1(gestion_VL53L8CX);
|
multicore_launch_core1(gestion_VL53L8CX);
|
||||||
|
|
||||||
sleep_ms(5000);
|
sleep_ms(5000);
|
||||||
printf("Demarrage...\n");
|
printf("Demarrage...\n");
|
||||||
|
|
||||||
@ -170,8 +173,10 @@ void affichage(void){
|
|||||||
printf(">m1_c:%f\n>m2_c:%f\n", AsserMoteur_getConsigne_mm_s(MOTEUR_A), AsserMoteur_getConsigne_mm_s(MOTEUR_B) );*/
|
printf(">m1_c:%f\n>m2_c:%f\n", AsserMoteur_getConsigne_mm_s(MOTEUR_A), AsserMoteur_getConsigne_mm_s(MOTEUR_B) );*/
|
||||||
printf(">pos_x:%.1f\n>pos_y:%.1f\n>pos_angle:%.1f\n", Localisation_get().x_mm, Localisation_get().y_mm, Localisation_get().angle_radian);
|
printf(">pos_x:%.1f\n>pos_y:%.1f\n>pos_angle:%.1f\n", Localisation_get().x_mm, Localisation_get().y_mm, Localisation_get().angle_radian);
|
||||||
printf(">distance_obstacle:%f\n",Trajet_get_obstacle_mm());
|
printf(">distance_obstacle:%f\n",Trajet_get_obstacle_mm());
|
||||||
|
Teleplot_add_variable_float_2decimal("dist", Trajet_get_obstacle_mm());
|
||||||
|
|
||||||
printf(">abscisse:%f\n",abscisse);
|
printf(">abscisse:%f\n",abscisse);
|
||||||
|
Teleplot_add_variable_float_2decimal("abs", abscisse);
|
||||||
|
|
||||||
struct position_t position_actuelle;
|
struct position_t position_actuelle;
|
||||||
position_actuelle = Localisation_get();
|
position_actuelle = Localisation_get();
|
||||||
|
9
wifi_settings.h.default
Normal file
9
wifi_settings.h.default
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Copier ce fichier en "wifi_settings.h" et renseignez vos identifiants WiFi.
|
||||||
|
// Le port est le port par défaut de Teleplot
|
||||||
|
// BEACON_TARGET est l'IP ou l'adresse du serveur Teleplot
|
||||||
|
|
||||||
|
#define MY_WIFI_SSID "My_SSID"
|
||||||
|
#define MY_WIFI_PASSWORD "My_WiFi_Password"
|
||||||
|
|
||||||
|
#define UDP_PORT 47269
|
||||||
|
#define BEACON_TARGET "192.168.1.2"
|
Loading…
Reference in New Issue
Block a user