Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RUCHE2-CODES RUCHE2-CODES_correctionpoids RUCHE2-CODES
Diff: message.h
- Revision:
- 0:db9f881dd501
- Child:
- 1:2fdc567000f3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/message.h Fri Jan 18 14:15:55 2019 +0000
@@ -0,0 +1,58 @@
+#ifndef MESSAGE_H
+#define MESSAGE_H
+
+#include "mbed.h"
+
+#define PIN_RX PA_3
+#define PIN_TX PA_2
+class Message {
+ public:
+ //Methodes:
+
+ //constructeur
+ Message(int messageType):m_messageType(messageType), sigfox(PIN_TX, PIN_RX){};
+
+ virtual void send() = 0;
+
+ //Accesseurs
+ int getMessageType(){
+ return m_messageType;
+ };
+
+
+ protected:
+
+ int floatToHex(float a) const{
+ int q = *(int*)&a;
+ return q;
+ };
+
+ void writeInSendBuffer(int16_t var){
+ if(var > 0 && var < 4096) this->sigfox.printf("0%hx", var);
+ else this->sigfox.printf("%hx", var);
+ };
+
+ /*void writeInSendBuffer(float var){
+
+ if(var > 0 && var < 4096) this->sigfox.printf("0%x", var);
+ else this->sigfox.printf("%x", var);
+ };*/
+
+ int16_t parseToUint16_t(int var){
+ int16_t temp = var * 100;
+ return temp;
+ };
+
+ int16_t parseToUint16_t(float var){
+ int16_t temp = var * 100;
+ return temp;
+ };
+
+ int m_messageType;
+ Serial sigfox;
+
+
+};
+
+
+#endif