Esempio n. 1
0
//The setup function is called once at startup of the sketch
void setup()
{
    // Add your initialization code here
    // Note : This will initialize Serial port on Arduino at 115200 bauds
    OC_LOG_INIT();
    OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
    uint16_t port = OC_WELL_KNOWN_PORT;

    // Connect to Ethernet or WiFi network
    if (ConnectToNetwork() != 0)
    {
        OC_LOG(ERROR, TAG, PCF("Unable to connect to network"));
        return;
    }

    // Initialize the OC Stack in Server mode
    if (OCInit(NULL, port, OC_SERVER) != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, PCF("OCStack init error"));
        return;
    }

    // Declare and create the example resource: Light
    createLightResource();
}
Esempio n. 2
0
//The setup function is called once at startup of the sketch
void setup()
{
    pinMode(dht11_pin, OUTPUT);
    digitalWrite(dht11_pin, HIGH);

    // Add your initialization code here
    OC_LOG_INIT();

    OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
    uint16_t port = OC_WELL_KNOWN_PORT;

    // Connect to Ethernet or WiFi network
    if (ConnectToNetwork() != 0)
    {
        OC_LOG(ERROR, TAG, "Unable to connect to network");
        return;
    }

    // Initialize the OC Stack in Server mode
    if (OCInit(NULL, port, OC_SERVER) != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, PCF("OCStack init error"));
        return;
    }
    OCStartPresence(60);
    // Declare and create the example resource: TH
    createTHResource();

}
Esempio n. 3
0
//The setup function is called once at startup of the sketch
void setup()
{
	// Add your initialization code here
	// Note : This will initialize Serial port on Arduino at 115200 bauds
	OC_LOG_INIT();
	OC_LOG(DEBUG, TAG, ("Demoserver is starting..."));

	// Connect to Ethernet or WiFi network
	if (ConnectToNetwork() != 0) {
		OC_LOG(ERROR, TAG, ("Unable to connect to network"));
		return;
	}

	// Initialize the OC Stack in Server mode
	if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) {
		OC_LOG(ERROR, TAG, ("OCStack init error"));
		return;
	}

	// Initialize Grove related Devices
	sensor_init();
	led_init();
	lcd_init();
	buzzer_init();
	button_init();

	// Declare and create the resource: grove
	createDemoResource();
}
Esempio n. 4
0
//The setup function is called once at startup of the sketch
void setup()
{
    // Add your initialization code here
    // Note : This will initialize Serial port on Arduino at 115200 bauds
    OC_LOG_INIT();

    pinMode(SDCARD_CS, OUTPUT);
    digitalWrite(SDCARD_CS, HIGH); //Deselect the SD card
    pinMode(FANPIN, OUTPUT);
    digitalWrite(FANPIN, LOW);

    Serial.println("OCServer is starting...");
    unsigned int port = OC_WELL_KNOWN_PORT;

    // Connect to Ethernet or WiFi network
    if (ConnectToNetwork() != 0)
    {
        Serial.println("Unable to connect to network");
        return;
    }

    Serial.println("Connected to Ethernet network");
    // Initialize the OC Stack in Server mode
    if (OCInit(NULL, port, OC_SERVER) != OC_STACK_OK)
    {
        Serial.println("OCStack init error");
        return;
    }

    Serial.println("OC Initialized");
    // Declare and create the resource: Fan
    createFanResource();
}
Esempio n. 5
0
//The setup function is called once at startup of the sketch
void setup()
{
    Serial.begin(115200);

    // Add your initialization code here
    OC_LOG_INIT();

    OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
    //    uint16_t port = OC_WELL_KNOWN_PORT;

    // Connect to Ethernet or WiFi network
    if (ConnectToNetwork() != 0)
    {
        OC_LOG(ERROR, TAG, "Unable to connect to network");
        return;
    }

    // Initialize the OC Stack in Server mode
    if (OCInit(NULL, OC_WELL_KNOWN_PORT, OC_SERVER) != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, PCF("OCStack init error"));
        return;
    }

    OCStartPresence(60);
    // Declare and create the example resource
    createResource();

    // This call displays the amount of free SRAM available on Arduino
    PrintArduinoMemoryStats();
#if (ARDUINO == 0)
    ble.init( (long)115200, BLE_MASTER, trackeeID);
#elif (ARDUINO == 1)
    ble.init( (long)115200, BLE_SLAVER, slaveList[0]);
#elif (ARDUINO == 2)
    ble.init( (long)115200, BLE_SLAVER, slaveList[1]);
#endif

//  ble.StatusRead();

    OC_LOG_V(INFO, TAG, "Program Start-\r\n");
}