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: projet_embarque1 projet_embarque1
Sigfox.cpp@3:835369a16129, 2019-10-15 (annotated)
- Committer:
- 3874313
- Date:
- Tue Oct 15 15:02:13 2019 +0000
- Revision:
- 3:835369a16129
- Parent:
- 2:fd9cadc78239
final;
Who changed what in which revision?
| User | Revision | Line number | New 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 | 3:835369a16129 | 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, u8 bat) { | 
| 3874313 | 3:835369a16129 | 27 | uint16_t temp1, temp2; | 
| 3874313 | 3:835369a16129 | 28 | uint32_t tmp; | 
| 3874313 | 3:835369a16129 | 29 | temp1 = temp_air + 200; | 
| 3874313 | 3:835369a16129 | 30 | temp2 = temp_sol + 200; | 
| 3874313 | 3:835369a16129 | 31 | tmp = temp1 | (temp2<<10) | (hum_air<<20); | 
| 3874313 | 3:835369a16129 | 32 | printf("AT$SF=%08x%04x%02x%02x%02x%02x%02x\r", tmp, hum_sol, lum, val_r, val_g, val_b, bat); | 
| 3874313 | 2:fd9cadc78239 | 33 | } | 
| 3874313 | 2:fd9cadc78239 | 34 | |
| 3874313 | 2:fd9cadc78239 | 35 | void Sigfox::sleep() { | 
| 3874313 | 2:fd9cadc78239 | 36 | printf("AT$P=1\r"); | 
| 3874313 | 2:fd9cadc78239 | 37 | } | 
| 3874313 | 2:fd9cadc78239 | 38 | |
| 3874313 | 2:fd9cadc78239 | 39 | void Sigfox::wake() { | 
| 3874313 | 2:fd9cadc78239 | 40 | printf("AT$P=0\r"); | 
| 3874313 | 0:8172b6cb4020 | 41 | } |