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.
Dependencies: lib_gps lib_mpl3115a2 lmic_MOTE_L152RC mbed
Fork of lmic_NAmote_GPS_tjm by
Revision 8:1069ed1d4464, committed 2016-02-09
- Comitter:
- tmulrooney
- Date:
- Tue Feb 09 00:39:29 2016 +0000
- Parent:
- 7:7de55330772d
- Child:
- 9:f4d52e9625f7
- Commit message:
- hello world
Changed in this revision
| lmic_MOTE_L152RC.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/lmic_MOTE_L152RC.lib Fri Jan 15 18:24:10 2016 +0000 +++ b/lmic_MOTE_L152RC.lib Tue Feb 09 00:39:29 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/Semtech/code/lmic_MOTE_L152RC/#0faa1bb768b5 +https://developer.mbed.org/users/tmulrooney/code/lmic_MOTE_L152RC/#671d85a0f15b
--- a/main.cpp Fri Jan 15 18:24:10 2016 +0000
+++ b/main.cpp Tue Feb 09 00:39:29 2016 +0000
@@ -28,8 +28,8 @@
} mote_version_e;
mote_version_e mote_version = MOTE_NONE;
-DigitalOut pc_7(PC_7);
-DigitalIn pc_1(PC_1);
+//DigitalOut pc_7(PTC1); /* *** TODO *** */
+//DigitalIn pc_1(PTC1); /* *** TODO *** */
/* ****************************************** */
@@ -48,18 +48,18 @@
/* ***************************************** */
-#define LED_RED PB_1
-#define LED_YEL PB_10
+#define LED_RED PTA1
+#define LED_YEL PTA2
static DigitalOut led1(LED_RED);
static DigitalOut led2(LED_YEL);
/* gps(tx, rx, en); */
-GPS gps(PB_6, PB_7, PB_11);
+//GPS gps(PTC1, PTC1, PTC1); /* *** TODO *** */
-I2C i2c(I2C_SDA, I2C_SCL);
-DigitalIn i2c_int_pin(PB_4);
-MPL3115A2 mpl3115a2(i2c, i2c_int_pin);
+I2C i2c(PTB3,PTB2);
+//DigitalIn i2c_int_pin(PTC1);
+//MPL3115A2 mpl3115a2(i2c, i2c_int_pin); /* *** TODO *** */
AnalogIn *bat;
#define LOW_BAT_THRESHOLD 3.45
@@ -117,20 +117,36 @@
//////////////////////////////////////////////////
// provide application router ID (8 bytes, LSBF)
-void os_getArtEui (u1_t* buf) {
+void os_getArtEui (u1_t* buf)
+{
+ debug("os_getArtEui Enter\r\n");
+ for(int i=0; i < 8; i++)
+ debug("%02X ",reverse_APPEUI[i]);
+ debug("\r\n");
//memcpy(buf, APPEUI, 8);
LMIC_reverse_memcpy(buf, reverse_APPEUI, 8);
}
// provide device ID (8 bytes, LSBF)
void os_getDevEui (u1_t* buf) {
+ debug("os_getDevEui Enter\r\n");
+ for(int i=0; i < 8; i++)
+ debug("%02X ",reverse_DEVEUI[i]);
+ debug("\r\n");
//memcpy(buf, DEVEUI, 8);
LMIC_reverse_memcpy(buf, reverse_DEVEUI, 8);
}
// provide device key (16 bytes)
void os_getDevKey (u1_t* buf) {
- memcpy(buf, DEVKEY, 16);
+ debug("os_getDevKey Enter\r\n");
+ for(int i=0; i < 16; i++)
+ debug("%02X ",DEVKEY[i]);
+ debug("\r\n");
+ for(int i=0; i < 16; i++)
+ debug("%c ",DEVKEY[i]);
+ debug("\r\n");
+ memcpy(buf, DEVKEY, 16);
}
//////////////////////////////////////////////////
@@ -138,22 +154,23 @@
//////////////////////////////////////////////////
void get_mote_version()
{
- char first;
+// char first;
- pc_7 = 1;
- first = pc_1;
- pc_7 = 0;
- if (first && !pc_1) {
- mote_version = MOTE_V2;
- printf("v2\r\n");
- bat = new AnalogIn(PA_0);
- } else {
- mote_version = MOTE_V3;
- printf("v3\r\n");
- bat = new AnalogIn(PA_1);
- }
+// pc_7 = 1;
+// first = pc_1;
+// pc_7 = 0;
+// if (first && !pc_1) {
+// mote_version = MOTE_V2;
+// printf("v2\r\n");
+// bat = new AnalogIn(PA_0);
+// } else {
+// mote_version = MOTE_V3;
+// printf("v3\r\n");
+// bat = new AnalogIn(PA_1);
+// }
}
+#if 0
// initial job
static void initfunc (osjob_t* j) {
debug_str("B: INITFUNC\n");
@@ -167,29 +184,48 @@
LMIC_setSession( 0, *serial_id, NwkSKey, ArtSKey );
debug_val("SN = ", *serial_id);
#endif
- // init done - onEvent() callback will be invoked...
+ //init done - onEvent() callback will be invoked...
//DEBUG_STR("E: INITFUNC");
get_mote_version();
- if (mote_version == MOTE_V3)
- gps.en_invert = false;
- else
- gps.en_invert = true;
+// if (mote_version == MOTE_V3)
+// gps.en_invert = false;
+// else
+// gps.en_invert = true;
- gps.init();
- gps.enable(1);
+// gps.init();
+// gps.enable(1);
//gps.verbose = 1;
- mpl3115a2.init();
+// mpl3115a2.init();
}
+#endif
+
+#if 1
+// counter static
+int cnt = 0;
+// log text to USART and toggle LED
+static void initfunc (osjob_t* job)
+{
+ // say hello
+ debug_str("Hello World!\r\n");
+ // log counter
+ debug_val("cnt = ", cnt);
+ // toggle LED
+ debug_led(++cnt & 1);
+ // reschedule job every second
+ os_setTimedCallback(job, os_getTime()+sec2osticks(1), initfunc);
+}
+#endif
+
int main(void)
{
osjob_t initjob;
-
+
// initialize runtime env
+ debug_init();
os_init();
- debug_init();
// setup initial job
os_setCallback(&initjob, initfunc);
// execute scheduled jobs and events
@@ -217,16 +253,16 @@
static void
restore_hsi()
{
- RCC_OscInitTypeDef osc_init;
+// RCC_OscInitTypeDef osc_init;
/* if HSI was shut off in deep sleep (needed for AnalogIn) */
- HAL_RCC_GetOscConfig(&osc_init);
- if (osc_init.HSIState != RCC_HSI_ON) {
- // Enable the HSI (to clock the ADC)
- osc_init.OscillatorType = RCC_OSCILLATORTYPE_HSI;
- osc_init.HSIState = RCC_HSI_ON;
- osc_init.PLL.PLLState = RCC_PLL_NONE;
- HAL_RCC_OscConfig(&osc_init);
- }
+// HAL_RCC_GetOscConfig(&osc_init);
+// if (osc_init.HSIState != RCC_HSI_ON) {
+// // Enable the HSI (to clock the ADC)
+// osc_init.OscillatorType = RCC_OSCILLATORTYPE_HSI;
+// osc_init.HSIState = RCC_HSI_ON;
+// osc_init.PLL.PLLState = RCC_PLL_NONE;
+// HAL_RCC_OscConfig(&osc_init);
+// }
}
static bool AppLedStateOn = false;
@@ -239,24 +275,24 @@
restore_hsi();
- gps.service();
+// gps.service();
//printf("lat:%f long:%f\r\n", gps.Latitude, gps.Longitude);
- mpl3115a2.ReadTemperature();
+// mpl3115a2.ReadTemperature();
// immediately prepare next transmission
//LMIC.frame[0] = LMIC.rxq.snr;
LMIC.frame[0] = AppLedStateOn; // (bit 0 == 1) => LED on
- LMIC.frame[1] = (int)mpl3115a2.Temperature; // Signed degrees Celcius in half degree units. So, +/-63 C
+// LMIC.frame[1] = (int)mpl3115a2.Temperature; // Signed degrees Celcius in half degree units. So, +/-63 C
LMIC.frame[2] = (bat->read_u16() >> 8) + (bat->read_u16() >> 9) ; // per LoRaMAC spec; 0=Charging; 1...254 = level, 255 = N/A
- LMIC.frame[3] = ( gps.LatitudeBinary >> 16 ) & 0xFF;
- LMIC.frame[4] = ( gps.LatitudeBinary >> 8 ) & 0xFF;
- LMIC.frame[5] = gps.LatitudeBinary & 0xFF;
- LMIC.frame[6] = ( gps.LongitudeBinary >> 16 ) & 0xFF;
- LMIC.frame[7] = ( gps.LongitudeBinary >> 8 ) & 0xFF;
- LMIC.frame[8] = gps.LongitudeBinary & 0xFF;
+// LMIC.frame[3] = ( gps.LatitudeBinary >> 16 ) & 0xFF;
+// LMIC.frame[4] = ( gps.LatitudeBinary >> 8 ) & 0xFF;
+// LMIC.frame[5] = gps.LatitudeBinary & 0xFF;
+// LMIC.frame[6] = ( gps.LongitudeBinary >> 16 ) & 0xFF;
+// LMIC.frame[7] = ( gps.LongitudeBinary >> 8 ) & 0xFF;
+// LMIC.frame[8] = gps.LongitudeBinary & 0xFF;
- altitudeGps = atoi(gps.NmeaGpsData.NmeaAltitude);
+// altitudeGps = atoi(gps.NmeaGpsData.NmeaAltitude);
//printf("alt:%d\r\n", altitudeGps);
LMIC.frame[9] = ( altitudeGps >> 8 ) & 0xFF;
LMIC.frame[10] = altitudeGps & 0xFF;
@@ -288,7 +324,7 @@
debug_event(ev);
- gps.service();
+// gps.service();
switch(ev)
{
