Smartage application

Dependencies:   BufferedSerial SX1276GenericLib USBDeviceHT mbed Crypto X_NUCLEO_IKS01A2

Fork of STM32L0_LoRa by Helmut Tschemernjak

main.cpp

Committer:
marcozecchini
Date:
2018-05-22
Revision:
21:5d64f9f79190
Parent:
20:1557c9d9c183
Child:
22:2c1359292de1

File content as of revision 21:5d64f9f79190:

/*
 * Copyright (c) 2018 HELIOS Software GmbH
 * 30826 Garbsen (Hannover) Germany
 * Licensed under the Apache License, Version 2.0);
 */
 #include "main.h"


DigitalOut myled(LED);
//D12 TRIGGER D11 ECHO
HCSR04 sensor(D12, D11);

int main() {
#ifdef HELTEC_STM32L4
    DigitalOut vext(POWER_VEXT);
    vext = POWER_VEXT_ON;
#endif    
    /*
     * inits the Serial or USBSerial when available (230400 baud).
     * If the serial uart is not is not connected it swiches to USB Serial
     * blinking LED means USBSerial detected, waiting for a connect.
     * It waits up to 30 seconds for a USB terminal connections 
     */
    InitSerial(30*1000, &myled); 
    print_stuff();
    
    while(1){
        //Ultrasonic measurement
        long distance = sensor.distance();
        dprintf("distance  %d  \n",distance);
        
        char message[8];//Message to be sent
        sprintf(message, "%d", distance);
         
        SendAndBack((uint8_t*)message);
    }
}