Skip to content
This repository has been archived by the owner on Feb 21, 2025. It is now read-only.

Commit

Permalink
Make it work con 32bit CPUs (SAMD21).
Browse files Browse the repository at this point in the history
  • Loading branch information
manchoz committed Dec 12, 2017
1 parent 7baff3d commit 061873c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/mqttsn-messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,13 @@ void MQTTSN::dispatch() {
}

waiting_for_response = false;
memset(response_message, 0, MAX_BUFFER_SIZE);
}

void MQTTSN::send_message() {
message_header* hdr = reinterpret_cast<message_header*>(message_buffer);

#ifdef USE_RF12
#ifdef USE_RF12
while (!rf12_canSend()) {
rf12_recvDone();
Sleepy::loseSomeTime(32);
Expand Down
40 changes: 20 additions & 20 deletions src/mqttsn.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,70 +98,70 @@ struct message_header {
uint8_t type;
};

struct msg_advertise : public message_header {
struct __attribute__ ((packed)) msg_advertise : public message_header {
uint8_t gw_id;
uint16_t duration;
};

struct msg_searchgw : public message_header {
struct __attribute__ ((packed)) msg_searchgw : public message_header {
uint8_t radius;
};

struct msg_gwinfo : public message_header {
struct __attribute__ ((packed)) msg_gwinfo : public message_header {
uint8_t gw_id;
char gw_add[0];
};

struct msg_connect : public message_header {
struct __attribute__ ((packed)) msg_connect : public message_header {
uint8_t flags;
uint8_t protocol_id;
uint16_t duration;
char client_id[0];
};

struct msg_connack : public message_header {
struct __attribute__ ((packed)) msg_connack : public message_header {
return_code_t return_code;
};

struct msg_willtopic : public message_header {
struct __attribute__ ((packed)) msg_willtopic : public message_header {
uint8_t flags;
char will_topic[0];
};

struct msg_willmsg : public message_header {
struct __attribute__ ((packed)) msg_willmsg : public message_header {
char willmsg[0];
};

struct msg_register : public message_header {
struct __attribute__ ((packed)) msg_register : public message_header {
uint16_t topic_id;
uint16_t message_id;
char topic_name[0];
};

struct msg_regack : public message_header {
struct __attribute__ ((packed)) msg_regack : public message_header {
uint16_t topic_id;
uint16_t message_id;
uint8_t return_code;
};

struct msg_publish : public message_header {
struct __attribute__ ((packed)) msg_publish : public message_header {
uint8_t flags;
uint16_t topic_id;
uint16_t message_id;
char data[0];
};

struct msg_puback : public message_header {
struct __attribute__ ((packed)) msg_puback : public message_header {
uint16_t topic_id;
uint16_t message_id;
uint8_t return_code;
};

struct msg_pubqos2 : public message_header {
struct __attribute__ ((packed)) msg_pubqos2 : public message_header {
uint16_t message_id;
};

struct msg_subscribe : public message_header {
struct __attribute__ ((packed)) msg_subscribe : public message_header {
uint8_t flags;
uint16_t message_id;
union {
Expand All @@ -170,14 +170,14 @@ struct msg_subscribe : public message_header {
};
};

struct msg_suback : public message_header {
struct __attribute__ ((packed)) msg_suback : public message_header {
uint8_t flags;
uint16_t topic_id;
uint16_t message_id;
uint8_t return_code;
};

struct msg_unsubscribe : public message_header {
struct __attribute__ ((packed)) msg_unsubscribe : public message_header {
uint8_t flags;
uint16_t message_id;
union {
Expand All @@ -186,23 +186,23 @@ struct msg_unsubscribe : public message_header {
};
};

struct msg_unsuback : public message_header {
struct __attribute__ ((packed)) msg_unsuback : public message_header {
uint16_t message_id;
};

struct msg_pingreq : public message_header {
struct __attribute__ ((packed)) msg_pingreq : public message_header {
char client_id[0];
};

struct msg_disconnect : public message_header {
struct __attribute__ ((packed)) msg_disconnect : public message_header {
uint16_t duration;
};

struct msg_willtopicresp : public message_header {
struct __attribute__ ((packed)) msg_willtopicresp : public message_header {
uint8_t return_code;
};

struct msg_willmsgresp : public message_header {
struct __attribute__ ((packed)) msg_willmsgresp : public message_header {
uint8_t return_code;
};

Expand Down

0 comments on commit 061873c

Please sign in to comment.