Ti spiego il mio problema,praticamente stò cercando di implementare una libreria per il protocollo mqtt,esiste già una versione per ethernet, io stò cercando di modificare questa per utilizzarla con il modulo gsm, quello che devo fare inviare alcuni dati al server per farmi accettare la connessione tramite questo tipo di protocollo,quindi stò utilizzando il SimpleWrite per mandare questi dati ti posto il codice di un metodo che ho scritto:
boolean PubSubClientGSM::connect(char *id, char* willTopic, uint8_t willQos, uint8_t willRetain, char* willMessage) {
if (!connected()) {
int result = 0;
if (domain != NULL) {
result = _client.connectTCP(this->domain, this->port);
} else {
result = _client.connectTCP(this->domain, this->port);
}
if (result) {
nextMsgId = 1;
uint8_t d[9] = {0x00,0x06,'M','Q','I','s','d','p',MQTTPROTOCOLVERSION};
uint8_t length = 0;
unsigned int j;
for (j = 0;j<9;j++) {
buffer[length++] = d[j];
}
if (willTopic) {
buffer[length++] = 0x06|(willQos<<3)|(willRetain<<5);
} else {
buffer[length++] = 0x02;
}
buffer[length++] = ((MQTT_KEEPALIVE) >> 8);
buffer[length++] = ((MQTT_KEEPALIVE) & 0xff);
length = writeString(id,buffer,length);
if (willTopic) {
length = writeString(willTopic,buffer,length);
length = writeString(willMessage,buffer,length);
}
gsm.WriteMQTT(MQTTCONNECT,buffer,length);
lastOutActivity = millis();
lastInActivity = millis();
unsigned long t= millis();
if (t-lastInActivity > MQTT_KEEPALIVE*1000) {
_client.disconnectTCP();
return false;
}
uint16_t len = readPacket();
if (len == 4 && buffer[3] == 0) {
lastInActivity = millis();
pingOutstanding = false;
return true;
}
}
_client.disconnectTCP();
}
return false;
}
ho scritto anche un metodo
void SIMCOM900::WriteMQTT(int mqttcn, uint8_t* buff, int len)
{
SimpleWrite(mqttcn);
delay(500);
SimpleWrite(buff);
delay(500);
SimpleWrite(len);
}
il problema sorge sull'invio di quel buffer che,come puoi vedere dal codice dovrebbe essere un uint8_t*,da qui il mio problema.
Scusa la mia dilungazione ma ho pensato che avendo tutto il problema ben chiaro ti possa essere più facile suggerirmi una soluzione.