57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /**
 | |
|  * Copyright (c) 2022 Andrew McDonnell
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-3-Clause
 | |
|  */
 | |
| 
 | |
| #include <string.h>
 | |
| #include <stdlib.h>
 | |
| #include <math.h>
 | |
| 
 | |
| #include "pico/cyw43_arch.h"
 | |
| 
 | |
| #include "pico/stdlib.h"
 | |
| #include "Teleplot.h"
 | |
| 
 | |
| #include "lwip/pbuf.h"
 | |
| #include "lwip/udp.h"
 | |
| 
 | |
| // Si le fichier n'existe pas, créez-le à partir du modèle "wifi_settings.h.default"
 | |
| #include "wifi_settings.h"
 | |
| 
 | |
| #define BEACON_INTERVAL_MS 25
 | |
| 
 | |
| 
 | |
| void teleplot_udp_send_string(char * message);
 | |
| 
 | |
| 
 | |
| void run_udp_beacon() {
 | |
|     static int counter = 0;
 | |
|     
 | |
|     while (true) {
 | |
|         char tampon[100];
 | |
| 
 | |
|         Teleplot_add_variable_float_2decimal("cos", cosf(counter/10.));
 | |
|         Teleplot_add_variable_float_2decimal("sin", sinf(counter/10.));
 | |
|         Teleplot_add_variable_int("counter", counter & 0x0FFF);
 | |
|         
 | |
|         counter++;
 | |
| 
 | |
|         sleep_ms(BEACON_INTERVAL_MS);
 | |
|     }
 | |
| }
 | |
| 
 | |
| int main() {
 | |
|     int erreur;
 | |
|     stdio_init_all();
 | |
| 
 | |
|     erreur = Teleplot_init();
 | |
|     if(!erreur){
 | |
|         run_udp_beacon();
 | |
|     }else{
 | |
|         printf("Initialisation du Wifi impossible\n");
 | |
|         sleep_ms(500);
 | |
|     }
 | |
|     cyw43_arch_deinit();
 | |
|     return 0;
 | |
| } |