try to improve net... might not have failed

This commit is contained in:
msp 2022-10-25 17:07:50 -04:00
parent 1f640f0874
commit 108f7c32e5
4 changed files with 20 additions and 10 deletions

View file

@ -126,14 +126,19 @@ void pd_pollhost( void)
void pdmain_print( const char *s)
{
char y[80];
char y[81];
strncpy(y, s, 79);
y[79]=0;
strcat(y, ";");
ESP_LOGI(TAG, "post %d: %s", strlen(y), y);
#ifdef PD_USE_BLUETOOTH
if (strlen(y) > 0)
pd_bt_writeback((unsigned char *)y, strlen(y));
#endif
#ifdef PD_USE_WIFI
net_sendudp(y, strlen(y), CONFIG_ESP_WIFI_SENDPORT);
net_sendtcp(y, strlen(y));
#endif
}
void trymem(int foo);
@ -178,6 +183,11 @@ void app_main(void)
bt_init();
#endif
sd_init();
#ifdef PD_USE_WIFI
ESP_LOGI(TAG, "[ 1a ] start network");
wifi_init();
net_init();
#endif
ESP_LOGI(TAG, "[ 2 ] now write some shit");
@ -209,10 +219,5 @@ void sd_init( void)
// Initialize SD Card peripheral
audio_board_sdcard_init(set, SD_MODE_1_LINE);
#ifdef PD_USE_WIFI
ESP_LOGI(TAG, "[ 1a ] start network");
wifi_init();
net_init();
#endif
ESP_LOGI(TAG, "[ 1b ] done starting network");
}

View file

@ -26,4 +26,5 @@ void wifi_init(void); /* wifi.c - manage 802.11 connection */
void net_init( void); /* init */
void net_alive( void); /* send keep-alive packet if needed */
void net_sendudp(void *msg, int len, int port); /* send whatev */
void net_sendtcp(void *msg, int len);
#endif

View file

@ -15,7 +15,6 @@
void pd_init(void);
void glob_open(t_pd *ignore, t_symbol *name, t_symbol *dir, t_floatarg f);
extern t_printhook sys_printhook;
void pdmain_print( const char *s);

View file

@ -86,6 +86,11 @@ void net_init( void)
udp_out_addr.sin_port = htons(CONFIG_ESP_WIFI_SENDPORT);
xTaskCreate(udpreceivertask, "udprcv", 6000, NULL, PRIORITY_WIFI, NULL);
while (!tcp_socket)
{
ESP_LOGE(TAG, "sendtcp: waiting for socket");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
static int64_t whensent;
@ -111,10 +116,10 @@ void net_sendudp(void *msg, int len, int port)
void net_sendtcp(void *msg, int len)
{
int err;
while (!tcp_socket)
if (!tcp_socket)
{
ESP_LOGE(TAG, "sendtcp: waiting for socket");
vTaskDelay(1000 / portTICK_PERIOD_MS);
ESP_LOGE(TAG, "sendtcp: no socket yet");
return;
}
err = send(tcp_socket, msg, len, 0);
if (err < 0)