Module sigfox pour le projet toiture

Dependents:   projet_embarque1 projet_embarque1

Committer:
3874313
Date:
Tue Oct 15 12:27:21 2019 +0000
Revision:
2:fd9cadc78239
Parent:
1:11f6ddd8fdbe
Child:
3:835369a16129
lux marche pas

Who changed what in which revision?

UserRevisionLine numberNew contents of line
3874313 0:8172b6cb4020 1 #include "Sigfox.h"
3874313 0:8172b6cb4020 2
3874313 1:11f6ddd8fdbe 3 Sigfox::Sigfox(PinName tx, PinName rx): Serial(tx, rx) {
3874313 1:11f6ddd8fdbe 4
3874313 0:8172b6cb4020 5 }
3874313 0:8172b6cb4020 6
3874313 0:8172b6cb4020 7 /**
3874313 0:8172b6cb4020 8 * @brief Tester si le module sigfox est pret
3874313 0:8172b6cb4020 9 * @param
3874313 0:8172b6cb4020 10 * @retval 1 si OK, 0 sinon
3874313 0:8172b6cb4020 11 */
3874313 0:8172b6cb4020 12 bool Sigfox::ready() {
3874313 1:11f6ddd8fdbe 13 printf("AT");
3874313 1:11f6ddd8fdbe 14 char c = getc();
3874313 0:8172b6cb4020 15 if(c == 'O')
3874313 0:8172b6cb4020 16 return 1;
3874313 0:8172b6cb4020 17 else
3874313 0:8172b6cb4020 18 return 0;
3874313 0:8172b6cb4020 19 }
3874313 0:8172b6cb4020 20
3874313 0:8172b6cb4020 21 /**
3874313 0:8172b6cb4020 22 * @brief Envoyer les parametres recuperees par les capteurs
3874313 0:8172b6cb4020 23 * @param Les valeurs detectees par les capteurs
3874313 0:8172b6cb4020 24 * @retval
3874313 0:8172b6cb4020 25 */
3874313 0:8172b6cb4020 26 void Sigfox::send(s16 temp_air, u16 hum_air, s16 temp_sol, u16 hum_sol, u8 lum, u8 val_r, u8 val_g, u8 val_b) {
3874313 1:11f6ddd8fdbe 27 printf("AT$SF=%04x%04x%04x%04x%02x%02x%02x%02x\r", temp_air, hum_air, temp_sol, hum_sol, lum, val_r, val_g, val_b);
3874313 2:fd9cadc78239 28 }
3874313 2:fd9cadc78239 29
3874313 2:fd9cadc78239 30 void Sigfox::sleep() {
3874313 2:fd9cadc78239 31 printf("AT$P=1\r");
3874313 2:fd9cadc78239 32 }
3874313 2:fd9cadc78239 33
3874313 2:fd9cadc78239 34 void Sigfox::wake() {
3874313 2:fd9cadc78239 35 printf("AT$P=0\r");
3874313 0:8172b6cb4020 36 }