Skip to content

Commit fa0a124

Browse files
authored
Merge pull request #34 from devicehive/develop
v0.7
2 parents 18d0a37 + 24b8065 commit fa0a124

File tree

238 files changed

+10363
-5813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+10363
-5813
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ release/build
99
release/*.zip
1010
release/*.tar.gz
1111
firmware-src/pages/debug.log
12+
.DS_Store
13+

DeviceHiveESP8266.md

+89-62
Large diffs are not rendered by default.

README.md

+41-39
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,82 @@
11
# DeviceHive ESP8266 Firmware
2-
Special firmware for usage ESP8266 as local web server with RESTful API and as DeviceHive clouds client.
3-
This repo consist of few parts of this project which can be used with
2+
Special firmware to use ESP8266 as a local web server with RESTful API and as a client of DeviceHive cloud.
3+
This repo consists of a few parts which can be used with
44
other projects. Each project has dedicated readme file.
55

66
![](images/demo-device.jpg?raw=true)
77
Photo above is a real photo of the demo device contructed with esp8266. See
8-
http://youtu.be/hzi4djt-wdg
8+
[YouTube video](http://youtu.be/hzi4djt-wdg).
99

1010
# [DeviceHiveESP8266.md](DeviceHiveESP8266.md)
1111
This is the main documentation file for this firmware. Document contains
12-
commands specification, describes all features and firmware usage.
13-
[Click here to open it.](DeviceHiveESP8266.md)
12+
commands specification, describes all features and firmware usage.
13+
[Click here to open it](DeviceHiveESP8266.md).
1414

1515
# Demo videos
16-
Zero wireless configuring with Android http://youtu.be/2J98YDpbJKo
17-
DeviceHive clouds demos:
18-
BH1750 Ambient light http://youtu.be/AkSFdO0soyo
19-
DS18B20 + iButton + DHT11 http://youtu.be/IuvxwCPNZCc
20-
Muscle connected to the cloud http://youtu.be/8L96nBNHE14
21-
SSD1306 OLED display http://youtu.be/gKgU6RzaxFU
22-
Multple sensor connection http://youtu.be/hzi4djt-wdg
23-
Smart socket http://youtu.be/hCdzcCjYYMw
24-
Wireless Configuring with Mac and Linux http://youtu.be/sFD2TTZNNvo
25-
BMP180 Atmospheric pressure http://youtu.be/P2rxnVjRPyc
26-
MPU6050 Accelerometer + Gyroscope http://youtu.be/IRj4tOfLTAM
27-
MFRC522 RFID Reader http://youtu.be/VMT3v49d57g
28-
Simple relay http://youtu.be/ZLq2X2n_wR0
16+
- [Zero wireless configuring with Android](http://youtu.be/2J98YDpbJKo)
17+
- [BH1750 Ambient light](http://youtu.be/AkSFdO0soyo)
18+
- [DS18B20 + iButton + DHT11](http://youtu.be/IuvxwCPNZCc)
19+
- [Muscle connected to the cloud](http://youtu.be/8L96nBNHE14)
20+
- [SSD1306 OLED display](http://youtu.be/gKgU6RzaxFU)
21+
- [Multple sensor connection](http://youtu.be/hzi4djt-wdg)
22+
- [Smart socket](http://youtu.be/hCdzcCjYYMw)
23+
- [Wireless Configuring with Mac and Linux](http://youtu.be/sFD2TTZNNvo)
24+
- [BMP180 Atmospheric pressure](http://youtu.be/P2rxnVjRPyc)
25+
- [MPU6050 Accelerometer + Gyroscope](http://youtu.be/IRj4tOfLTAM)
26+
- [MFRC522 RFID Reader](http://youtu.be/VMT3v49d57g)
27+
- [Simple relay](http://youtu.be/ZLq2X2n_wR0)
2928

30-
# custom firmwares
29+
# Custom firmwares
3130
There is a possibility to build custom firmware on top of this which sends some
3231
notifications to DeviceHive server periodically. In pauses firmware goes to deep
3332
sleep mode. Reimplement `custom_firmware_request()` method in
3433
`custom_firmware.c` file with reading of some sensors data. There are
3534
implementation for some sensors in `sources/devices` dir. Also, it is possible
3635
to create interaction with any sensor using interface implementation modules
37-
(dhi2c, dhspi, dhonewire etc). See `climate` branch as an example.
36+
(`dh/i2c`, `dh/spi`, `dh/onewire` etc). See `climate` branch as an example.
3837

39-
# esp-utils
38+
# Directory content
39+
40+
## esp-utils
4041
Simple utils for flashing and connecting to ESP8266.
4142

42-
# examples-cloud
43-
Simple web pages with JavaScript sample of sendind recieving command
44-
from device via cloud. Onewire DS18B20 examples use 0x33[SKIP ROM] command
43+
## examples-cloud
44+
Simple web pages with JavaScript sample of sendind and receiving commands
45+
from device via cloud. Onewire DS18B20 examples use `0x33[SKIP ROM]` command
4546
which means that examples work only with one currently connected device. Some
46-
browsers(for example Firefox) block cross domen requests even for local file.
47+
browsers (for example Firefox) block cross domen requests even for local file.
4748
Allow temporary cross domain requests in setting or use another browser to run
4849
examples.
4950

5051
Local RESTful API samples are embedded to firmware. Sources of them can be found
5152
at firmware-src/pages directory.
5253

53-
# firmware-src
54+
## firmware-src
5455
Sources of DeviceHive ESP8266 firmware.
5556

56-
# firmware-src/genbin.sh
57+
## firmware-src/genbin.sh
5758
Small utils which is written on bash and can be used on any OS. This util
58-
creates binary firmware files files from crosstool-NG binary file output.
59+
creates binary firmware files from crosstool-NG binary file output.
5960

60-
# firmware-tests
61-
Tests for firmware. Youcan find sample of command in file requests.html. Each
62-
addtest() instance have boolean third parameter. If this parameters is true it
61+
## firmware-tests
62+
Tests for firmware. You can find command samples in file requests.html. Each
63+
`addtest()` instance have boolean third parameter. If this parameters is `true` it
6364
means that command and parameters is written correctly and you can use it as
6465
a sample.
6566

66-
# release
67+
## release
6768
Scripts for generating binary releases.
6869

69-
# sdk
70+
## sdk
7071
SDK from chip manufactor. Included in this repo to make sure that we are
7172
using the same version of this SDK to avoid any surprises from changing APIs
7273

73-
# License
74-
The MIT License. See LICENSE file. Except sdk directory, it has ESPRSSIF MIT
75-
License, see sdk/License file for details.
74+
## License
75+
The MIT License. See [LICENSE](./LICENSE) file. Except sdk directory, it has ESPRSSIF MIT
76+
License, see [sdk/License](./sdk/License) file for details.
7677

7778
# Authors
78-
Nikolay Khabarov
79-
Igor Malovitsa
80-
Maksim Kleshchevnikov
79+
- Nikolay Khabarov
80+
- Sergey Polichnoy
81+
- Igor Malovitsa
82+
- Maksim Kleshchevnikov

changelog.txt

+6
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,9 @@ v0.6
5454
- access point mode
5555
- embedded pages redesign
5656
- sample of using D3.js for plotting graphs from different sensors on embedded web server
57+
58+
v0.7
59+
- new command 'command/list'
60+
- connectino to server now is implemeted with WebSocket
61+
- latest DeviceHive server v3.x and playground support
62+
- compile time ability to disable some devices

esp-utils/README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
# DeviceHive ESP8266 Simple utils
2-
esp-terminal:
3-
Simple tool for easy access to DeviceHive ESP8266 firmware terminal in production
2+
`esp-terminal`:
3+
Simple tool for easy access DeviceHive ESP8266 firmware terminal in production
44
release with simple support of ansi escape codes
5-
esp-flasher:
5+
6+
`esp-flasher`:
67
Simple tool for flashing DeviceHive firmware in ESP8266
78

89
# How To Build
9-
run 'make'
10-
all binary files will be generated in 'build' directory.
10+
Run `make`.
11+
All binary files will be generated in `build` directory.
1112

1213
# esp-terminal usage
1314
Run application and it will try to detect device automatically. You also can
1415
specify device manually by passing port name in command line.
15-
To quit from terminal press Ctrl+Q
16+
To quit from terminal press `Ctrl+Q`.
1617

1718
# esp-flasher usage
1819
Run application and it will try to detect device automatically. If no parameters
19-
were specified it also will try to open files devicehive.bin in current directory
20+
were specified it also will try to open files `devicehive.bin` in current directory
2021
and directory with its binary and flash them to corresponding addresses.
2122
You can specify port name in first argument if you want to specify it manually.
2223
You also can specify which files have to be written in devices in arguments by
23-
pairs hex address <space> file name. For exmaple:
24+
pairs `hex address <space> file name`. For exmaple:
25+
26+
```
2427
esp-flasher COM2 0x00000 boot.img 0x40000 spi.img
2528
esp-flasher 0x40000 myimagefile.bin
29+
```
30+
2631
There also `--developer` and `--reboot` arguments which supposed to be used by
2732
developers only. First enables incremental flash mode, it compares previosuly
2833
flashed file (should be saved as `devicehive.bin.prev`) and if differences are
2934
minimal it will flash only them to save time on flashing. `--reboot` argument
30-
simply reboot chip (serial adapter RTS should connected to GPIO0, DTR to RTS
35+
simply reboot chip (serial adapter `RTS` should be connected to `GPIO0`, `DTR` to `RTS`
3136
pin).
3237

3338
# License
34-
see LICENSE file
35-
36-
# Authors
37-
Nikolay Khabarov
39+
See [LICENSE](./LICENSE) file.

esp-utils/common/serialport.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
#include <string.h>
1313
#include "serialport.h"
1414

15-
SerialPort::SerialPort(COM comport) {
15+
SerialPort::SerialPort(COM comport, const char *name) {
1616
mCom = comport;
1717
mTreadFlag = true;
1818
mReadFlag = false;
1919
mReadError = false;
2020
mBytesRecivedSinceLastSend = 0;
2121
mThread = 0;
2222
mLastReceived = 0;
23+
snprintf(mName, sizeof(mName), "%s", name);
2324
}
2425

2526
COM SerialPort::get_com() {
@@ -65,3 +66,7 @@ void SerialPort::send(const void *data, unsigned int len) {
6566
if(bw != len)
6667
SerialPortError(this, ERROR_WRITE_STRING);
6768
}
69+
70+
const char *SerialPort::getName() {
71+
return mName;
72+
}

esp-utils/common/serialport.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ class SerialPort
4242
void setRts(bool val);
4343
void setDtr(bool val);
4444
void sleep(unsigned int ms);
45+
const char *getName();
4546
private:
4647
#ifdef COMWINDOWS
4748
static DWORD ThreadProc (LPVOID lpdwThreadParam);
4849
#else
4950
static void * thread_start(void *arg);
5051
#endif
51-
SerialPort(COM comport);
52+
SerialPort(COM comport, const char *name);
5253
unsigned int write_native(const void *data, unsigned int len);
5354
bool read_native(const void *data, unsigned int len, unsigned int *rb);
5455
static unsigned int getTick();
@@ -60,6 +61,7 @@ class SerialPort
6061
unsigned int mBytesRecivedSinceLastSend;
6162
bool mReadError;
6263
unsigned int mLastReceived;
64+
char mName[256];
6365
};
6466

6567
extern void SerialPortRecieved(SerialPort *port, const char *text, unsigned int len);

esp-utils/common/serialport_posix.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ SerialPort *SerialPort::open(const char *port) {
6060
{
6161
struct termios tio;
6262
memset(&tio,0,sizeof(tio));
63-
if ( tcgetattr ( comp, &tio ) != 0 ) {
63+
if( tcgetattr ( comp, &tio ) != 0 ) {
6464
close(comp);
6565
return 0;
6666
}
@@ -77,12 +77,12 @@ SerialPort *SerialPort::open(const char *port) {
7777

7878
tcflush(comp, TCIOFLUSH);
7979

80-
if ( tcsetattr ( comp, TCSANOW, &tio ) != 0) {
80+
if( tcsetattr ( comp, TCSANOW, &tio ) != 0) {
8181
close(comp);
8282
return 0;
8383
}
8484

85-
SerialPort *comport = new SerialPort(comp);
85+
SerialPort *comport = new SerialPort(comp, port);
8686
pthread_t thr;
8787
if(pthread_create(&thr, 0, thread_start, (void *)comport)!=0) {
8888
delete comport;
@@ -118,7 +118,7 @@ void SerialPort::sleep(unsigned int ms) {
118118
usleep(ms*1000);
119119
}
120120

121-
#if ( defined(__APPLE__) || defined(__MACH__) )
121+
#if( defined(__APPLE__) || defined(__MACH__) )
122122
const static char TTYUSB_PATTERN[] = "tty.";
123123
#else
124124
const static char TTYUSB_PATTERN[] = "ttyUSB";
@@ -160,7 +160,7 @@ unsigned int SerialPort::getTick() {
160160
void SerialPort::setRts(bool val) {
161161
int flag;
162162
if(ioctl(mCom, TIOCMGET, &flag) != -1) {
163-
if (val)
163+
if(val)
164164
flag |= TIOCM_RTS;
165165
else
166166
flag &= ~TIOCM_RTS;
@@ -171,7 +171,7 @@ void SerialPort::setRts(bool val) {
171171
void SerialPort::setDtr(bool val) {
172172
int flag;
173173
if(ioctl(mCom, TIOCMGET, &flag) != -1) {
174-
if (val)
174+
if(val)
175175
flag |= TIOCM_DTR;
176176
else
177177
flag &= ~TIOCM_DTR;

esp-utils/common/serialport_win.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ SerialPort *SerialPort::open(const char *port) {
5959
char namebuff[MAX_PATH];
6060
snprintf(namebuff, sizeof namebuff, "\\\\.\\%s", port);
6161
HANDLE hCOM=CreateFileA(namebuff,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
62-
if (hCOM!=INVALID_HANDLE_VALUE)
62+
if(hCOM!=INVALID_HANDLE_VALUE)
6363
{
6464
DCB cdcb;
6565
if( GetCommState(hCOM,&cdcb)==0 ) {
@@ -86,9 +86,9 @@ SerialPort *SerialPort::open(const char *port) {
8686
to.WriteTotalTimeoutConstant = 0;
8787
SetCommTimeouts(hCOM,&to);
8888

89-
SerialPort *comport = new SerialPort(hCOM);
89+
SerialPort *comport = new SerialPort(hCOM, port);
9090
DWORD dwThreadId;
91-
if ( (comport->mThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&ThreadProc, (LPVOID)comport, 0, &dwThreadId)) == NULL)
91+
if( (comport->mThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&ThreadProc, (LPVOID)comport, 0, &dwThreadId)) == NULL)
9292
{
9393
delete comport;
9494
return 0;

esp-utils/common/terminal_win.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void Terminal::put(char c) {
7070
} else if(escRecieving) {
7171
escSequence[escSequencePos++] = c;
7272
escSequence[escSequencePos] = 0;
73-
if (escSequencePos == 1 && c == '[')
73+
if(escSequencePos == 1 && c == '[')
7474
return;
7575
if((c >= 0x40 && c <= 0x7e) || escSequencePos >= sizeof(escSequence) - 1) {
7676
if(strcmp(escSequence, "[C") == 0) { // Right

0 commit comments

Comments
 (0)