-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathE01_Helloworld_StaticIP_W_Debug.ino
76 lines (58 loc) · 2.87 KB
/
E01_Helloworld_StaticIP_W_Debug.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**************************************************************************
Souliss - Hello World with Static IP and Debug Enabled.
This is the basic example, control one LED via a push-button or Android
using SoulissApp (get it from Play Store).
Run this code on one of the following boards:
- Arduino Ethernet (W5100)
- Arduino with Ethernet Shield (W5100)
As option you can run the same code on the following, just changing the
relevant configuration file at begin of the sketch
- Arduino with W5200 Ethernet Shield
- Arduino with W5500 Ethernet Shield
***************************************************************************/
#define MaCaco_DEBUG_INSKETCH
#define MaCaco_DEBUG 1
#define VNET_DEBUG_INSKETCH
#define VNET_DEBUG 1
// Configure the framework
#include "bconf/StandardArduino.h" // Use a standard Arduino
#include "conf/ethW5100.h" // Ethernet through Wiznet W5100
#include "conf/Gateway.h" // The main node is the Gateway, we have just one node
#include "conf/Webhook.h" // Enable DHCP and DNS
// Include framework code and libraries
#include <SPI.h>
#include "Souliss.h"
// This identify the number of the LED logic
#define MYLEDLOGIC 0
uint8_t ip_address[4] = {192, 168, 1, 77};
uint8_t subnet_mask[4] = {255, 255, 255, 0};
uint8_t ip_gateway[4] = {192, 168, 1, 1};
#define myvNet_address ip_address[3] // The last byte of the IP address (77) is also the vNet address
void setup()
{
Serial.begin(115200);
Initialize();
Souliss_SetIPAddress(ip_address, subnet_mask, ip_gateway);
SetAsGateway(myvNet_address);
Set_SimpleLight(MYLEDLOGIC); // Define a simple LED light logic
// We connect a pushbutton between 5V and pin2 with a pulldown resistor
// between pin2 and GND, the LED is connected to pin9 with a resistor to
// limit the current amount
pinMode(2, INPUT); // Hardware pulldown required
pinMode(9, OUTPUT); // Power the LED
}
void loop()
{
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
FAST_50ms() { // We process the logic and relevant input and output every 50 milliseconds
DigIn(2, Souliss_T1n_ToggleCmd, MYLEDLOGIC); // Use the pin2 as ON/OFF toggle command
Logic_SimpleLight(MYLEDLOGIC); // Drive the LED as per command
DigOut(9, Souliss_T1n_Coil, MYLEDLOGIC); // Use the pin9 to give power to the LED according to the logic
}
// Here we handle here the communication with Android, commands and notification
// are automatically assigned to MYLEDLOGIC
FAST_GatewayComms();
}
}