while(1){
osDelay(1000);
- printf( "noise read ...\n" );
+ //printf( "noise read ...\n" );
if( user_noise_sensor_read( &noise ) == 0 ){
err = 0;
noise_state = 1;
user_noise_info_update( noise, noise_state );
- printf( "noise db:%.1f ...\n", noise );
+ //printf( "noise db:%.1f ...\n", noise );
}else{
if( noise_state >= 0 ){
if( err++ > 10 ){
struct tcp_pcb *tcp_server_pcb;
static struct tcp_pcb *tcp_connected_pcb = NULL;
-static uint16_t tx_sn = 0;
+static uint16_t tx_pkt_sn = 0;
+static uint16_t rx_pkt_sn;
void Tcp_Server_Init(void)
{
{
uint8_t buf[256];
uint16_t n;
- tx_sn++;
- n = wrap_pkt( buf, tx_sn, cmd, data, data_sz );
+ tx_pkt_sn++;
+ n = wrap_pkt( buf, tx_pkt_sn, cmd, data, data_sz );
return user_tcp_write_data( buf, n );
}
/* ÅäÖýÓÊջص÷º¯Êý */
tcp_recv(pcb, tcp_server_recv);
-
+ printf( "tcp accept, pcb:%p\n", pcb );
return ERR_OK;
}
3002: Laki Rx
*/
-static uint16_t rx_pkt_sn;
+
int32_t wrap_pkt( uint8_t *buf, uint16_t sn, uint16_t cmd, uint8_t *data, uint32_t data_sz )
{
uint8_t *p = buf;
sensor_info_t sensor;
-// uint16_t noise;
-// uint16_t sound_freq;
-// uint16_t sound_amplitude;
+
+ if( tcp_connected_pcb == 0 ){
+ rx_pkt_sn = 0;
+ tx_pkt_sn = 0;
+ }
resp_sz = 0;
if( len >= 10 && p[0]==0x55 && p[1]==0xAA ){
//struct pbuf *tcp_send_pbuf;
struct name *name = (struct name *)arg;
uint8_t *rx_data;
-
+ printf( "tcp recv, pcb:%p\n", pcb );
if (tcp_recv_pbuf != NULL)
{
/* À©´óÊÕ·¢Êý¾ÝµÄ´°¿Ú */
{
/* ÊÍ·ÅÄÚ´æ */
mem_free(name);
+ printf( "tcp_close: pcb:%p\n", tcp_connected_pcb );
+ tcp_connected_pcb = 0;
return tcp_close(pcb);
}