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: libmDot-mbed5 ISL29011
Revision 41:06fa773aaf8f, committed 2019-08-12
- Comitter:
- Frederick_H
- Date:
- Mon Aug 12 06:25:52 2019 +0000
- Parent:
- 40:c3bb2f5eac95
- Commit message:
- Change to AS923 channel plan and add LED demo code
Changed in this revision
--- a/examples/example_config.h Mon Jul 08 11:34:11 2019 +0000 +++ b/examples/example_config.h Mon Aug 12 06:25:52 2019 +0000 @@ -25,7 +25,7 @@ // CP_AS923_JAPAN // CP_IN865 #if !defined(CHANNEL_PLAN) -#define CHANNEL_PLAN CP_US915 +#define CHANNEL_PLAN CP_AS923 #endif #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/inc/LD100_util.h Mon Aug 12 06:25:52 2019 +0000 @@ -0,0 +1,40 @@ +#ifndef __LD100_UTIL_H__ +#define __LD100_UTIL_H__ + +#include "mbed.h" +#include "mDot.h" + +/** + * Turn On/Off D4 LED on LD100 board + * + * @param OnOff true to turn on, false to turn off + * + */ +void LED_D4(bool OnOff); + +/** + * Turn On/Off D5 LED on LD100 board + * + * @param OnOff true to turn on, false to turn off + * + */ +void LED_D5(bool OnOff); + +/** + * Turn On/Off D6 LED on LD100 board + * + * @param OnOff true to turn on, false to turn off + * + */ +void LED_D6(bool OnOff); + +/** + * Initialize on board TCA6424 + * + * @return 0 mean OK + * + */ +int TCA6424_init(); + + +#endif
--- a/examples/src/LD100_example.cpp Mon Jul 08 11:34:11 2019 +0000
+++ b/examples/src/LD100_example.cpp Mon Aug 12 06:25:52 2019 +0000
@@ -1,5 +1,6 @@
#include "dot_util.h"
#include "RadioEvent.h"
+#include "LD100_util.h"
#if ACTIVE_EXAMPLE == LD100_EXAMPLE
@@ -22,8 +23,8 @@
// * either the network name and passphrase can be used or //
// the network ID (8 bytes) and KEY (16 bytes) //
/////////////////////////////////////////////////////////////
-static std::string network_name = "MultiTech";
-static std::string network_passphrase = "MultiTech";
+static std::string network_name = "MTCDT-18446018";
+static std::string network_passphrase = "jointech_passphrase";
static uint8_t network_id[] = { 0x57, 0xD7, 0x64, 0xA4, 0x0C, 0xFE, 0xB1, 0xDF };
static uint8_t network_key[] = { 0x63, 0x81, 0x87, 0x8D, 0x11, 0x45, 0x88, 0x13, 0x30, 0xCF, 0xCF, 0xBC, 0x1D, 0x48, 0xA8, 0xEC };
static uint8_t frequency_sub_band = 2;
@@ -299,17 +300,26 @@
dot->restoreNetworkSession();
}
+ dot->setLogLevel(mts::MTSLog::DEBUG_LEVEL);
+ TCA6424_init();
+
while (true) {
+ LED_D6(true);
+
+ LED_D5(true);
// join network if not joined
if (!dot->getNetworkJoinStatus()) {
join_network();
}
+ LED_D5(false);
+ LED_D4(true);
// Read Sensor Data and Upload it to gateway
// mts::MTSLog::setLogLevel(mts::MTSLog::DEBUG_LEVEL); // enable debug log
// ReadBatteryLevelAndSend();
ReadRS485SensorAndSend();
+ LED_D4(false);
// if going into deepsleep mode, save the session so we don't need to join again after waking up
// not necessary if going into sleep mode since RAM is retained
@@ -317,6 +327,8 @@
logInfo("saving network session to NVM");
dot->saveNetworkSession();
}
+
+ LED_D6(false);
// ONLY ONE of the three functions below should be uncommented depending on the desired wakeup method
//sleep_wake_rtc_only(deep_sleep);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/src/LD100_util.cpp Mon Aug 12 06:25:52 2019 +0000
@@ -0,0 +1,80 @@
+#include "LD100_util.h"
+
+void LED_D6(bool OnOff)
+{
+ DigitalOut LED6(D2);
+ if (OnOff)
+ LED6 = 1;
+ else
+ LED6 = 0;
+}
+
+DigitalOut resetPin(PA_4);
+
+int TCA6424_init(I2C& i2c_port)
+{
+ char cmd[4];
+ const int saddr = 0x22 << 1;
+ resetPin = 1;
+ wait_ms(1);
+ resetPin = 0;
+ wait_ms(1);
+ resetPin = 1;
+ wait_ms(1);
+
+ cmd[0]= 0x05; //Output port 1
+ cmd[1]&= 0x9F; //10011111, set P15, P16 to output low
+ i2c_port.write(saddr, cmd, 2);
+
+ cmd[0]= 0x0D; //Configuration port 1
+ cmd[1]= 0x9F; //10011111, turn P15, P16 to output pin
+ i2c_port.write(saddr, cmd, 2);
+ return 0;
+}
+
+
+int TCA6424_init()
+{
+ I2C i2c_port(I2C_SDA, I2C_SCL);
+ return TCA6424_init(i2c_port);
+}
+
+void LED_D4(bool OnOff)
+{
+ char cmd[4];
+ const int saddr = 0x22 << 1;
+ I2C i2c_port(I2C_SDA, I2C_SCL);
+
+ cmd[0]= 0x05; //Output port 1
+ i2c_port.write(saddr, cmd, 1);
+ i2c_port.read(saddr, cmd + 1, 1); //read recent state
+
+ cmd[0]= 0x05; //Output port 1
+ if (OnOff)
+ cmd[1]|= 0x40; //01000000, set P16 to output High
+ else
+ cmd[1]&= 0xBF; //10111111, set P16 to output low
+ i2c_port.write(saddr, cmd, 2);
+}
+
+void LED_D5(bool OnOff)
+{
+ char cmd[4];
+ const int saddr = 0x22 << 1;
+ I2C i2c_port(I2C_SDA, I2C_SCL);
+
+ cmd[0]= 0x05; //Output port 1
+ i2c_port.write(saddr, cmd, 1);
+ i2c_port.read(saddr, cmd + 1, 1); //read recent state
+
+ cmd[0]= 0x05; //Output port 1
+ if (OnOff)
+ cmd[1]|= 0x20; //00100000, set P15 to output High
+ else
+ cmd[1]&= 0xDF; //11011111, set P15 to output low
+ i2c_port.write(saddr, cmd, 2);
+}
+
+
+//#define Pin_Charging IOExpander,ugt::TCA6424_IOPin::P15
+//#define Pin_ChargeDone IOExpander,ugt::TCA6424_IOPin::P16