ArduinoGeneral

(AT+NCTCP) and how to send data via tcp in wifi shield v2.2

userHead potato 2013-11-22 23:12:47 6918 Views19 Replies
hello, good evening

I'm doing Station Mode and Multi Sockets example 10.3.1 in the manual

[code]
AT
[OK]

ATE0
[OK]

at+XDUM=0
[OK]

at+bdata=1
[ok]

at+wd
[ok]

at+ndhcp=1
[ok]

at+wwpa = potatohead
[ok]

at+wa=randy

IP SUBNET Gateway
192.168.1.103 255.255.255.0 192.168.1.1
[ok]

at+nctcp=192.168.1.105,5000
[ERROR]
[/code]

I already tried many different last digit in the IP, but all i got was the [error] response

how can I use at+nctcp ? where did I goes wrong?

thank you
2013-12-07 03:45:38 the library is still in my pc jose, still under development.

but, soon, it will finish.

i'll surely share when i finish working on it :)
userHeadPic potato
2013-12-07 03:45:38 the library is still in my pc jose, still under development.

but, soon, it will finish.

i'll surely share when i finish working on it :)
userHeadPic potato
2013-12-07 02:27:09 Potato,

this is looking great! any idea where to find this library so I can give it a go ?
userHeadPic Jose
2013-12-07 02:27:09 Potato,

this is looking great! any idea where to find this library so I can give it a go ?
userHeadPic Jose
2013-12-07 02:01:43 I already can send data bro,

[code]#include <SoftwareSerial.h>
#include <WizFiRandy.h>

byte *payload;


byte connFlagWillRetain;
byte connFlagCleanSession;
byte pubDupFlag;
byte pubRetain;
unsigned int pubMsgId;
unsigned int mqttPacketLength;
unsigned int mgttResponseLength;
char modemImei[16];
char ip[16];



void setup() {
  // put your setup code here, to run once:
  connFlagWillRetain = 0;
  connFlagCleanSession = 1;
  pubDupFlag = 0;
  pubRetain = 0;
  pubMsgId = 10;

  Serial.begin(115200);
 
  Serial.println("+++");
  Serial.flush();
  delay(500);
  checkwizfistatus(mainBuffer, 5000);
  delay(500);
  wizfiate0(mainBuffer, 5000);
  delay(500);
  wizfixdum(mainBuffer, 5000);
  delay(500);
  wizfibdata(mainBuffer, 5000);
  delay(500);
  wizfindhcp(mainBuffer, 5000);
  delay(500);
  wizfisetstatic(mainBuffer, 5000);
  delay(10000);
  wizfiwwpa(mainBuffer, 5000);
  delay(500);
  wizfisetup(mainBuffer, 5000);
  delay(15000);
  wizficonnectserversetup(mainBuffer, 5000); //this is at+nctcp=ip,port
  Serial.flush();
  delay(100);

}

void loop() {
  // put your main code here, to run repeatedly:
  mqttPacketLength = buildMqttConnectPacket(mainBuffer, connFlagWillRetain, MQTTQOS0, connFlagCleanSession);
  Serial.print("\x1B" "S0"); //header for sending data
  Serial.println(mqttPacketLength);
  Serial.print("\x1B" "E"); //header for sending data
 
  mqttPacketLength = generatePayload(modemImei, "3ph");


  payload = (byte*)malloc(mqttPacketLength+1);
  memset(payload, 0, mqttPacketLength+1);
  strcpy((char*)payload, (char*)mainBuffer);             
                 
  mqttPacketLength = buildMqttPublishPacket(mainBuffer, pubDupFlag, MQTTQOS0, pubRetain, pubMsgId, payload, strlen((char*)payload));
  Serial.print("\x1B" "S0"); //header for sending data
Serial.println(mqttPacketLength);
Serial.print("\x1B" "E"); //header for sending data
free(payload);
        }
 
[/code]

so, for the conclusion is, i just need to add \x1BS0 for beginning of the message and add \x1BE for the end of the message

soon, this module can support mqtt protocol with my library

Thx for your support bro ^^
userHeadPic potato
2013-12-07 02:01:43 I already can send data bro,

[code]#include <SoftwareSerial.h>
#include <WizFiRandy.h>

byte *payload;


byte connFlagWillRetain;
byte connFlagCleanSession;
byte pubDupFlag;
byte pubRetain;
unsigned int pubMsgId;
unsigned int mqttPacketLength;
unsigned int mgttResponseLength;
char modemImei[16];
char ip[16];



void setup() {
  // put your setup code here, to run once:
  connFlagWillRetain = 0;
  connFlagCleanSession = 1;
  pubDupFlag = 0;
  pubRetain = 0;
  pubMsgId = 10;

  Serial.begin(115200);
 
  Serial.println("+++");
  Serial.flush();
  delay(500);
  checkwizfistatus(mainBuffer, 5000);
  delay(500);
  wizfiate0(mainBuffer, 5000);
  delay(500);
  wizfixdum(mainBuffer, 5000);
  delay(500);
  wizfibdata(mainBuffer, 5000);
  delay(500);
  wizfindhcp(mainBuffer, 5000);
  delay(500);
  wizfisetstatic(mainBuffer, 5000);
  delay(10000);
  wizfiwwpa(mainBuffer, 5000);
  delay(500);
  wizfisetup(mainBuffer, 5000);
  delay(15000);
  wizficonnectserversetup(mainBuffer, 5000); //this is at+nctcp=ip,port
  Serial.flush();
  delay(100);

}

void loop() {
  // put your main code here, to run repeatedly:
  mqttPacketLength = buildMqttConnectPacket(mainBuffer, connFlagWillRetain, MQTTQOS0, connFlagCleanSession);
  Serial.print("\x1B" "S0"); //header for sending data
  Serial.println(mqttPacketLength);
  Serial.print("\x1B" "E"); //header for sending data
 
  mqttPacketLength = generatePayload(modemImei, "3ph");


  payload = (byte*)malloc(mqttPacketLength+1);
  memset(payload, 0, mqttPacketLength+1);
  strcpy((char*)payload, (char*)mainBuffer);             
                 
  mqttPacketLength = buildMqttPublishPacket(mainBuffer, pubDupFlag, MQTTQOS0, pubRetain, pubMsgId, payload, strlen((char*)payload));
  Serial.print("\x1B" "S0"); //header for sending data
Serial.println(mqttPacketLength);
Serial.print("\x1B" "E"); //header for sending data
free(payload);
        }
 
[/code]

so, for the conclusion is, i just need to add \x1BS0 for beginning of the message and add \x1BE for the end of the message

soon, this module can support mqtt protocol with my library

Thx for your support bro ^^
userHeadPic potato
2013-12-07 01:18:16 I think after you do at+nctcp=x,x you want to go back to serial mode to let Arduino try to send data. Then trigger back with escape sequence to get AT commands and close the connection when done.

Take a look at this post for instance,
[url=https://www.dfrobot.com/forum/index.php?topic=494.msg2252#msg2252]https://www.dfrobot.com/forum/index.php?topic=494.msg2252#msg2252[/url]

If ATO is giving you some trouble, try ata. however, I am not sure if ata would close the nctcp connection since it probably restarts or reconnects the wireless.

I'm still stuck with my board trying to get the +++ and any of all the escape sequences options working. I did not have much time to test it but i'll try a bit more later. I've got a little mess on my board with firmware upgrade tests and so on...

Let me know how it goes so I can try it
userHeadPic Jose
2013-12-07 01:18:16 I think after you do at+nctcp=x,x you want to go back to serial mode to let Arduino try to send data. Then trigger back with escape sequence to get AT commands and close the connection when done.

Take a look at this post for instance,
[url=https://www.dfrobot.com/forum/index.php?topic=494.msg2252#msg2252]https://www.dfrobot.com/forum/index.php?topic=494.msg2252#msg2252[/url]

If ATO is giving you some trouble, try ata. however, I am not sure if ata would close the nctcp connection since it probably restarts or reconnects the wireless.

I'm still stuck with my board trying to get the +++ and any of all the escape sequences options working. I did not have much time to test it but i'll try a bit more later. I've got a little mess on my board with firmware upgrade tests and so on...

Let me know how it goes so I can try it
userHeadPic Jose
2013-12-05 01:51:27 actually, all i did is just write at+nctcp= ip address, port 1883.

and I got [connect 0] response,

if i try to send data with or without escape sequence, all i got is [error invalid input] response.

so, how do you think about this jose?
userHeadPic potato
2013-12-05 01:51:27 actually, all i did is just write at+nctcp= ip address, port 1883.

and I got [connect 0] response,

if i try to send data with or without escape sequence, all i got is [error invalid input] response.

so, how do you think about this jose?
userHeadPic potato
2013-12-04 23:45:16 Hey Potato,

I'm trying with an old wifi shield v2.1 at+nctcp without much luck. Did you enable the escape sequence manually? or just left it as defaulted? GPIO trigger and software escape sequence on mine is not behaving well.

Anyway, my guess is just as you said. With the Wifi bee I did it with escape sequence as well. I suppose you just open the connection with nctcp and start outputting arduino's data.
userHeadPic Jose
2013-12-04 23:45:16 Hey Potato,

I'm trying with an old wifi shield v2.1 at+nctcp without much luck. Did you enable the escape sequence manually? or just left it as defaulted? GPIO trigger and software escape sequence on mine is not behaving well.

Anyway, my guess is just as you said. With the Wifi bee I did it with escape sequence as well. I suppose you just open the connection with nctcp and start outputting arduino's data.
userHeadPic Jose
2013-12-04 04:06:11 Ok, so I already can do at+nctcp,

the next problem is, how can I send data via tcp?
is it using escape sequence? if so, please tell me how, I already tried the manual but didn't work.
userHeadPic potato
2013-12-04 04:06:11 Ok, so I already can do at+nctcp,

the next problem is, how can I send data via tcp?
is it using escape sequence? if so, please tell me how, I already tried the manual but didn't work.
userHeadPic potato
2013-11-23 01:23:36 i input at+nctcp before at+wwpa&at+wa

and
[DISASSOCIATED]

is the respond i got
userHeadPic potato
2013-11-23 01:23:36 i input at+nctcp before at+wwpa&at+wa

and
[DISASSOCIATED]

is the respond i got
userHeadPic potato
2013-11-23 00:12:30 Hello potato!

I'm still looking into the other thing, but try
at+nctcp
Before doing
at+wa
userHeadPic Jose
2013-11-23 00:12:30 Hello potato!

I'm still looking into the other thing, but try
at+nctcp
Before doing
at+wa
userHeadPic Jose
2013-11-22 23:12:47 hello, good evening

I'm doing Station Mode and Multi Sockets example 10.3.1 in the manual

[code]
AT
[OK]

ATE0
[OK]

at+XDUM=0
[OK]

at+bdata=1
[ok]

at+wd
[ok]

at+ndhcp=1
[ok]

at+wwpa = potatohead
[ok]

at+wa=randy

IP                        SUBNET            Gateway
192.168.1.103  255.255.255.0    192.168.1.1
[ok]

at+nctcp=192.168.1.105,5000
[ERROR]
[/code]

I already tried many different last digit in the IP, but all i got was the [error] response

how can I use at+nctcp ? where did I goes wrong?

thank you
userHeadPic potato