USBによる通信内容確認モードのソースプログラムの修正
以下のコードに「SSID」「パスワード」「パソコンIPアドレス」「ポート」を設定します。
MAIN_RETURN main(void)
{
ADCON1 = 0b00001111;
TRISA = 0b00000000;
TRISB = 0b00000000;
TRISC = 0b00110000; //D-,D+
TRISD = 0b00000000;
TRISE = 0b11000011; //SW1,2=INPUT LED=OUTPUT
LATA = 0b00000000;
LATB = 0b00000000;
LATC = 0b00000000;
LATD = 0b00000000;
LATE = 0b00000000;
SYSTEM_Initialize(SYSTEM_STATE_USB_START);
USBDeviceInit();
USBDeviceAttach();
UART_Init(115200);
RCIF = 0; //reset RX pin flag
RCIP = 1; //high priority
RCIE = 1; //Enable RX interrupt
PEIE = 1; //Enable pheripheral interrupt (serial port is a pheripheral)
INTCONbits.GIE = 1;
int i;
LED=0;
while(SW1==1)
{
UARTreadTEXT_1();
USB_TASK();
}
UART_Write_Text("AT+CWMODE=1\r\n");
MyWait(100);
UARTreadTEXT_1();
UART_Write_Text("AT+CWJAP=\"SSID\",\"password\"\r\n");
MyWait(800);
UARTreadTEXT_1();
//UART_Write_Text("AT+CIFSR\r\n");
UART_Write_Text("AT+CIPSTART=\"TCP\",\"パソコンIPアドレス\",ポート\r\n");
MyWait(200);
UARTreadTEXT_1();
UART_Write_Text("AT+CIPMODE=1\r\n");
MyWait(200);
UARTreadTEXT_1();
UART_Write_Text("AT+CIPSEND\r\n");
MyWait(200);
UARTreadTEXT_1();
UART_Write_Text(">OK\r\n");
gN=0;
__delay_ms(15);
while(1)
{
LED=1;
UARTreadTEXT_2();
USB_TASK();
}//end while
}//end main