well, sorta works. need to add udp back
This commit is contained in:
parent
4b46c35128
commit
898c054feb
3 changed files with 18 additions and 10 deletions
21
main/espd.c
21
main/espd.c
|
|
@ -100,6 +100,20 @@ static void initdacs( void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int audiostate;
|
||||||
|
|
||||||
|
void sys_set_audio_state(int onoff)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if (onoff && !audiostate)
|
||||||
|
i2s_start(I2S_NUM_0);
|
||||||
|
else if (!onoff && audiostate)
|
||||||
|
i2s_stop(I2S_NUM_0);
|
||||||
|
audiostate = onoff;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* queue from host. Need to make this a proper RTOS queue */
|
/* queue from host. Need to make this a proper RTOS queue */
|
||||||
void *getbytes(size_t nbytes);
|
void *getbytes(size_t nbytes);
|
||||||
void freebytes(void *x, size_t nbytes);
|
void freebytes(void *x, size_t nbytes);
|
||||||
|
|
@ -122,7 +136,6 @@ void pd_fromhost(char *data, size_t size)
|
||||||
memcpy(pd_bt_buf + pd_bt_size, data, size);
|
memcpy(pd_bt_buf + pd_bt_size, data, size);
|
||||||
pd_bt_size += size;
|
pd_bt_size += size;
|
||||||
xSemaphoreGive(pd_bt_mutex);
|
xSemaphoreGive(pd_bt_mutex);
|
||||||
ESP_LOGI(TAG, "fromhost %d", size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dispatch messages enqueued above */
|
/* dispatch messages enqueued above */
|
||||||
|
|
@ -138,13 +151,10 @@ void pd_pollhost( void)
|
||||||
lastchar = pd_bt_size-1;
|
lastchar = pd_bt_size-1;
|
||||||
while (lastchar >= 0 && isspace((int)(pd_bt_buf[lastchar])))
|
while (lastchar >= 0 && isspace((int)(pd_bt_buf[lastchar])))
|
||||||
lastchar--;
|
lastchar--;
|
||||||
if (lastchar > 2)
|
|
||||||
ESP_LOGI(TAG, "last %d %c", lastchar, pd_bt_buf[lastchar]);
|
|
||||||
|
|
||||||
if (lastchar >= 3 && pd_bt_buf[lastchar] == ';' &&
|
if (lastchar >= 3 && pd_bt_buf[lastchar] == ';' &&
|
||||||
pd_bt_buf[lastchar-1] != '\\')
|
pd_bt_buf[lastchar-1] != '\\')
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "send it");
|
|
||||||
pd_sendmsg(pd_bt_buf, pd_bt_size);
|
pd_sendmsg(pd_bt_buf, pd_bt_size);
|
||||||
pd_bt_buf = (char *)resizebytes(pd_bt_buf, pd_bt_size, 0);
|
pd_bt_buf = (char *)resizebytes(pd_bt_buf, pd_bt_size, 0);
|
||||||
pd_bt_size = 0;
|
pd_bt_size = 0;
|
||||||
|
|
@ -158,12 +168,11 @@ void pdmain_print( const char *s)
|
||||||
strncpy(y, s, 79);
|
strncpy(y, s, 79);
|
||||||
y[79]=0;
|
y[79]=0;
|
||||||
strcat(y, ";");
|
strcat(y, ";");
|
||||||
ESP_LOGI(TAG, "post %d: %s", strlen(y), y);
|
|
||||||
#ifdef PD_USE_BLUETOOTH
|
#ifdef PD_USE_BLUETOOTH
|
||||||
if (strlen(y) > 0)
|
if (strlen(y) > 0)
|
||||||
pd_bt_writeback((unsigned char *)y, strlen(y));
|
pd_bt_writeback((unsigned char *)y, strlen(y));
|
||||||
#endif
|
#endif
|
||||||
#ifdef PD_USE_WIFI
|
#if 0 /* this doesn't work all that well since posts are split into atoms */
|
||||||
net_sendudp(y, strlen(y), CONFIG_ESP_WIFI_SENDPORT);
|
net_sendudp(y, strlen(y), CONFIG_ESP_WIFI_SENDPORT);
|
||||||
net_sendtcp(y, strlen(y));
|
net_sendtcp(y, strlen(y));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,6 @@ void sys_lock(void) {}
|
||||||
void sys_unlock(void) {}
|
void sys_unlock(void) {}
|
||||||
void pd_globallock(void) {}
|
void pd_globallock(void) {}
|
||||||
void pd_globalunlock(void) {}
|
void pd_globalunlock(void) {}
|
||||||
void sys_set_audio_state(int onoff) {}
|
|
||||||
int sys_defaultfont = 1;
|
int sys_defaultfont = 1;
|
||||||
int sys_nearestfontsize(int fontsize) {return (1);}
|
int sys_nearestfontsize(int fontsize) {return (1);}
|
||||||
int sys_noautopatch = 1;
|
int sys_noautopatch = 1;
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
static const char *TAG = "ESPD";
|
static const char *TAG = "ESPD";
|
||||||
int tcp_socket;
|
int tcp_socket;
|
||||||
|
|
||||||
void udpreceivertask(void *z)
|
void tcpreceivertask(void *z)
|
||||||
{
|
{
|
||||||
char rx_buffer[4000];
|
char rx_buffer[4000];
|
||||||
int ip_protocol = 0, err, newsocket;
|
int ip_protocol = 0, err, newsocket;
|
||||||
struct sockaddr_in dest_addr;
|
struct sockaddr_in dest_addr;
|
||||||
|
|
||||||
ESP_LOGI(TAG, "udpreceivertask starting...");
|
ESP_LOGI(TAG, "tcpreceivertask starting...");
|
||||||
ESP_LOGE(TAG, "(ignore this - testing error printout)");
|
ESP_LOGE(TAG, "(ignore this - testing error printout)");
|
||||||
dest_addr.sin_addr.s_addr = inet_addr(CONFIG_ESP_WIFI_SENDADDR);
|
dest_addr.sin_addr.s_addr = inet_addr(CONFIG_ESP_WIFI_SENDADDR);
|
||||||
dest_addr.sin_family = AF_INET;
|
dest_addr.sin_family = AF_INET;
|
||||||
|
|
@ -85,7 +85,7 @@ void net_init( void)
|
||||||
/* this will get overridden later: */
|
/* this will get overridden later: */
|
||||||
udp_out_addr.sin_port = htons(CONFIG_ESP_WIFI_SENDPORT);
|
udp_out_addr.sin_port = htons(CONFIG_ESP_WIFI_SENDPORT);
|
||||||
|
|
||||||
xTaskCreate(udpreceivertask, "udprcv", 6000, NULL, PRIORITY_WIFI, NULL);
|
xTaskCreate(tcpreceivertask, "udprcv", 6000, NULL, PRIORITY_WIFI, NULL);
|
||||||
while (!tcp_socket)
|
while (!tcp_socket)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "sendtcp: waiting for socket");
|
ESP_LOGE(TAG, "sendtcp: waiting for socket");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue