Code Monkey home page Code Monkey logo

iot-central-firmware's Introduction

Note: The code in this repository is provided as an example of how to connect a device to IoT Central. It is not production ready code, and is not supported by the Azure IoT Central team.

Azure IoT Central Device / Platform Sample projects

Reference firmware / sample implementation repository for some of the supported devices / frameworks.

  • Are you looking for a particular device sample? Create an issue on this repository and let us know.

A quick note about DPS endpoint

The Device Provisioning Service (DPS) endpoint used in these samples are all coded to work with the DPS public cloud endpoint at global.azure-devices-provisioning.net. For China and other sovereign clouds that do not allow access to this DPS public endpoint. For these samples to work it is necessary to change this value the correct DPS endpoint for the private or sovereign cloud being used.

Contents

Device Provisioning Helper Tools

Reporting Security Issues

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at [email protected]. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

iot-central-firmware's People

Contributors

davidemontanari avatar ellenfosborne avatar firedog1024 avatar gmileka avatar kartben avatar microsoftopensource avatar msftgits avatar obastemur avatar pprovost avatar ugreg avatar zhaodong2013062 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iot-central-firmware's Issues

Cannot guarantee that the connection can be successfully every time

Hi ALL,

I can connect the azure iot central from 8266 successfully.

However, it doesn't guarantee that it can connect successfully everytime.

The error as show below. Sometime, i try many times as mid-night. It doesn't work. However, i try one time an another time, it can connect right the way. Sometimes, I try several times to make it work. Is it the problem from server side?

    • iotc.dps : getting auth...
  • ERROR: couldn't fetch the time from NTP.
    • iotc.dps : getting operation id...
  • ERROR: DPS (PUT) request has failed.
    {"errorCode":401002,"trackingId":"e7c63d1e-5831-4b88-8882-c4a170670f8c","message":"Unauthorized","timestampUtc":"2019-04-09T05:06:23.4508912Z"}
    0

X - Error at C:\Users\Ken Lai\Documents\Github_smart\multiple-sensors-plant-microsoft\ESP8266\ESP8266.ino:221
Error @ iotc_connect. Code 1

Used same callback for all the iotc on events

Is it better practice to instead make separate call backs for each event?

Line 81
https://github.com/Azure/iot-central-firmware/blob/master/MXCHIP/mxchip_basic/mxchip_basic.ino

Example

iotc_on_MessageSent(context, "MessageSent", onEvent, NULL);
iotc_on_Command(context, "Command", onEvent, NULL);
iotc_on_ConnectionStatus(context, "ConnectionStatus", onEvent, NULL);
iotc_on_SettingsUpdated(context, "SettingsUpdated", onEvent, NULL);
iotc_on_Error(context, "Error", onEvent, NULL);

Or does the onEvent method need to be decoupled?

Disconnects after 6 hours due to "not authorized"

Device: Raspberry Pi 3 Model B+
Operating System: Raspbian 9
Python Version: 2.7.13

After running for 6 hours I get: 'on(disconnect): Not authorized'
This is accompanied by 12 or 24 'ERROR: (sendTelementry) failed to send. MQTT client return value: 4' when I am rapid firing messages, but when I'm firing messages at a decreased speed I do not get these messages. In the end the command line creates a new pi@raspberrypi ~ $.

Is anyone else having a problem with losing authorization after 6 hours?

I have tried adding an if loop to the script that will reconnect the device if it disconnects but it didn't work.

MXChip - Http connection failed to connect

I have an issue with the MXChip where the device is able to connect to WiFi, but then unable to make an outbound HTTP connection to Azure IoT Central. Looks like it is somewhere in the iotHubClient.cpp. This is what I was able to get from the device on Serial Port 9600:

Info:    DPS Version: 1.2.8

Info: Iothub Version: 1.1.28

Error: Time:Thu Jan  1 00:41:44 1970 File:prov_transport_http_client.c Func:on_http_connected Line:208 Http connection failed to connect
Error: Time:Thu Jan  1 00:41:45 1970 File:tlsio_mbed_os5.c Func:tlsio_mbedtls_open Line:552 Underlying IO open failed
Error: Time:Thu Jan  1 00:41:45 1970 File:uhttp.c Func:uhttp_client_open Line:1064 opening xio failed
Error: Time:Thu Jan  1 00:41:45 1970 File:prov_transport_http_client.c Func:create_connection Line:602 failed to open http client
Error: Time:Thu Jan  1 00:41:45 1970 File:prov_transport_http_client.c Func:prov_transport_http_open Line:747 Failure creating http connection
Error: Time:Thu Jan  1 00:41:45 1970 File:prov_device_ll_client.c Func:Prov_Device_LL_Register_Device Line:804 Failure establishing  connection
Error: Time:Thu Jan  1 00:41:45 1970 File:DevkitDPSClient.cpp Func:DevkitDPSClientStart Line:302 failed calling Prov_Device_LL_Register_Device
Error: Time:Thu Jan  1 00:41:45 1970 File:DevkitDPSClient.cpp Func:DevkitDPSClientStart Line:320 registration failed!

X - Error at /src/iot-central-firmware/AZ3166/BUILD/sketch/src/iotHubClient.cpp:40
	ERROR: DPS client for GroupSAS has failed.
X - Error at /src/iot-central-firmware/AZ3166/BUILD/sketch/src/iotHubClient.cpp:257
	IoTHubClient::closeIotHubClient!

Any ideas where I can get more details or maybe you know of a fix? I am running the latest firmware (2.0.0), and have tried various config options, but it still fails, telling me to reset the device.

The error comes from a corporate network; it all connects and works fine from my home network. Please advise at your convenience.

Connection lost after sending telemetry (ESP8266)

Somehow the connection is lost after sending a telegram.

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "iotc/common/string_buffer.h"
#include "iotc/iotc.h"

#define WIFI_SSID "..."
#define WIFI_PASSWORD "..."

const char *SCOPE_ID = "...";
const char *DEVICE_ID = "...";
const char *DEVICE_KEY = "...";

int pin = D2;
volatile unsigned int pulse;
const int pulses_per_kwh = 1000;
const int interval = 30000;

void on_event(IOTContext ctx, IOTCallbackInfo *callbackInfo);
#include "connection.h"

void on_event(IOTContext ctx, IOTCallbackInfo *callbackInfo)
{
    // ConnectionStatus
    if (strcmp(callbackInfo->eventName, "ConnectionStatus") == 0)
    {
        LOG_VERBOSE("Is connected ? %s (%d)",
                    callbackInfo->statusCode == IOTC_CONNECTION_OK ? "YES" : "NO",
                    callbackInfo->statusCode);
        isConnected = callbackInfo->statusCode == IOTC_CONNECTION_OK;
        return;
    }

    // payload buffer doesn't have a null ending.
    // add null ending in another buffer before print
    AzureIOT::StringBuffer buffer;
    if (callbackInfo->payloadLength > 0)
    {
        buffer.initialize(callbackInfo->payload, callbackInfo->payloadLength);
    }

    LOG_VERBOSE("- [%s] event was received. Payload => %s\n",
                callbackInfo->eventName, buffer.getLength() ? *buffer : "EMPTY");

    if (strcmp(callbackInfo->eventName, "Command") == 0)
    {
        LOG_VERBOSE("- Command name was => %s\r\n", callbackInfo->tag);
    }
}

void sendToAzure(double value)
{
}

void count_pulse()
{
    pulse++;
}

void setup()
{
    Serial.begin(9600);

    connect_wifi(WIFI_SSID, WIFI_PASSWORD);
    connect_client(SCOPE_ID, DEVICE_ID, DEVICE_KEY);

    pinMode(pin, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(pin), count_pulse, RISING);
}

void loop()
{
    if (isConnected)
    {
        pulse = 0;
        interrupts();
        delay(interval);
        noInterrupts();

        Serial.print("Pulses: ");
        Serial.print(pulse);
        Serial.print(", kWh per 30s: ");
        Serial.println(double(pulse) / double(pulses_per_kwh));

        char msg[64] = {0};
        int pos = 0, errorCode = 0;

        pos = snprintf(msg, sizeof(msg) - 1, "{\"energy\": %f}",
                       double(pulse) / double(pulses_per_kwh));
        errorCode = iotc_send_telemetry(context, msg, pos);
        msg[pos] = 0;

        if (errorCode != 0)
        {
            LOG_ERROR("Sending message has failed with error code %d", errorCode);
        }
        iotc_do_work(context);
    }
    else
    {
        iotc_free_context(context);
        context = NULL;
        connect_client(SCOPE_ID, DEVICE_ID, DEVICE_KEY);
    }
}
  - Is connected ? YES (64)
Pulses: 0, kWh per 30s: 0.00
  - - [MessageSent] event was received. Payload => {"energy": 0.000000}

  - Is connected ? NO (128)
  - ERROR: Client was not connected.
  - - iotc.dps : getting auth...
  - - iotc.dps : getting operation id...
  - - iotc.dps : getting host name...

Central firmware device configuration page displays max 10 Wifi SSIDs

When viewing the WiFi connection drop down within the setup page of the device, 10 arbitrary WiFi SSIDs show up, with no ability to connect a specific SSID by name (using free text field). We need to change it so that we can load more APs or have free text field to allow SSID manual entry

ESP32 using Arduino IDE

Can you provide an example for the ESP32 using the Arduino IDE? The given is using the ESP-IDF. Many many thanks!!

sketch/src/config.cpp:119:5: error: 'sasKey' was not declared in this scope

Hi,

Working with MXCHIP AZ3166 (v1.6.0)
On macOS with the latest (fixed version) for iotz (obastemur/iotz#51)
Trying to get a customised version of mxchip_advanced for IOT Central:

Defining my own wifi in definitions.h

#define WIFI_NAME "my wifi"
#define WIFI_PASSWORD "mypassword"
.....
#define COMPILE_TIME_DEFINITIONS_SET

$ iotz compile
sketch/src/config.cpp: In static member function 'static void ConfigController::readGroupSXKeyAndDeviceId(char*, char*, char*, char&)':
sketch/src/config.cpp:119:5:
error: 'sasKey' was not declared in this scope sasKey = true;

Looks like that is defined in onboarding.cpp -> OnboardingController::processResultRequest
Which perhaps doesn't get called if you define your own wifi parameters ??

Andy

Adding State information in Raspberry PI sample

I modified my device template to include a Temperature State of Normal, Warning, or Critical. I modified the code to evaluate the temperature and establish the state. The state messages are being sent to IoT Central but the information is not available for display. The simulated device in IoT Central displays the state correctly. Any help would be appreciated.
Here is the section of the code:

while iotc.isConnected():
iotc.doNext() # do the async work needed to be done for MQTT
if gCanSend == True:
if gCounter % 10 == 0:
gCounter = 0
temp = randint(20, 30)
if temp > 29:
tempStatus = "Critical"
elif temp > 27:
tempStatus = "Warning"
else:
tempStatus = "Normal"
iotc.sendState("{ "tempStatus": " + tempStatus + " }")

Undeclared functions prov_dev_set_symmetric_key_info and hsm_client_set_registration_name_and_key

Pulled down the code as is, ran the sample and got the following error. When I comment the following lines in iotc.cpp, the sketch uploads and runs as expected!

// int prov_dev_set_symmetric_key_info(const char* registration_name, const char* symmetric_key) {
//     hsm_client_set_registration_name_and_key(registration_name, symmetric_key);
//     return 0;
// }

MXCHIP firmware Version 1.6.1 (February 1, 2019)

Board

  • IoT Developer Kit by Microsoft Developer version 1.6.1

Arduino libs

  • IoTHub by Microsoft Version 1.0.45
  • IotHub Built-In by Microsoft Version 0.0.1
  • THubMQTTClient by Andri Yadi Version 0.2.3
  • Protocol_HTTP by Microsoft Version 1.0.45
  • Protocol_MQTT by Microsoft Version 1.0.45
  • AzureeIoTUtility by Microsoft Version 1.0.45

Compiler Output

Preparing boards...
Verifying...
sketch/src/iotc/sdk_plat/iotc.cpp: In function 'int prov_dev_set_symmetric_key_info(const char*, const char*)':
sketch/src/iotc/sdk_plat/iotc.cpp:19:78: error: 'hsm_client_set_registration_name_and_key' was not declared in this scope
     hsm_client_set_registration_name_and_key(registration_name, symmetric_key);
                                                                              ^
exit status 1
[Error] Exit with code=1

MXChip setup option to select temperature reading, C or F.

I'm currently using the AZ3166 version of the application. I would like to see 2 options added to the web UI questions that show up when connecting to http://192.168.0.1/start.

New Question 1: Option for delay in seconds in between sending telemetry to Azure.
New Question 2: Option to send Temperature in Celsius or Fahrenheit .

example
Temperature conversion in file: telemetry.cpp

#ifndef DISABLE_TEMPERATURE
Existing line: temp = Globals::sensorController.readTemperature();
New lines:
// Convert Celsius (�C) / Fahrenheit (�F) Conversion
temp = temp * 1.8 + 32;

#endif // DISABLE_TEMPERATURE

trouble using new pi python app

Hi guys !

I'm following the new tutorial from a few hours ago .

But after running the new app on my pi i get the following error:

ERROR : (_mqttConnect) ('ERROR: non JSON is received from %s => %s', ('global.azure-devices-provisioning.net', b'{"operationId":"4.115980cfc72fed8b.6dd9fcff-78d5-4f23-99a7-d84fc34a5263","status":"assigning"}'))

My pi changed from registed to Provisioned inside iot central after running app.py for the first time.

Can anyone point me on the right direction please ?

Thanks in advance!

--
Just a status update.

Tried to run app.py on my pc instead of running from raspberry pi . Went well. I'm sending now data to iot central. The differences might be that on my pc i'm running python 2.7 instead of 3.4.2.

Anyone can help me figure it out ?

Error when connecting to WiFi (after setup) (AZ3166)

Hi there,

I am exposing a WiFi hotspot on a Windows 10 host. The WiFi is a 2.4Ghz network.

I have successfully flashed the device with the latest firmware, set the access credentials to IoT Central and provided the correct WiFi credentials for a WiFi hotspot exposed from a Windows 10 host.

The AZ3166 shows up with its MAC as connected to the WiFi on the Windows 10 host. However, the device shows "WiFi Connecting..." and then "Error: Please reset the device."

No amount of resetting or hard resetting and running through the setup solves the issue.

Any idea how to fix this?

thanks,

Tobias

Getting the template details

Hi,
It will be great to be able to get the template details from IOTC to the device using the API. Use case is: once the template has been changed, the device code can get notified or be checking regularly and only sends the telemetry indicated on the template to the cloud. At the moment, if the template changes, like when new telemetry variables are added to a template, the programmer would have to adjust the code on the device manually. The function I'm requesting for will help to automate this process. Thanks.

c++ or python client?

We are at the prototype stage and couldn't decide whether to invest on c++ or python. We found a python example under raspberry folder and made it work on our mips based board. It ticks all the boxes for us. We've failed to make Azure iot c sdk work with our device.

How likely you guys may come up with a more generic solution for c-c++?

How to register many devices using x509 certificate.

I'd like to register 20 devices to IoT Central using RaspberryPi firmware samples using x509 certificate.
When I use cert file which is generated by dice_device_enrollment tool, all devices communicate with IoT Central as 'riot-device-cert'. I'd like to know how to register devices which has individual register id.
Regards,
Kei

pypi.org/project/iotc/ micropython callback incomplete - any plans to complete?

Hi All,

I notice that the Micropython version that uses umqtt.simple client has an empty callback function.

I finally got iotc to import running on esp32 with no errors (needed expanded PSRAM version)

This _mqttcb function is an empty for callback, so is doing nothing when calling a command initiated from IOTC portal; but received MQTT command when debugging with print.

def _mqttcb(self, topic, msg): #print('### topic: ' + str(topic)) #print('### msg: ' + str(msg)) #pass

Is there any plans to complete library for Micropython version?
ESP32 will obviously not work with paho-mqtt, and can see you have tried to support micropython umqtt.simple - but is incomplete on callback

I actually tried to complete the function based on your paho-mqtt working code, but I was having issues with the class and OOB (I am not strong on Pythton)
It worked on first sending a command to device from IOTC port, but second call would crash the micropython loop.

Any help/pointer appreciated.

I am a hobby programmer, and getting ESP32 working with IOTC would be wonderful. This is since IOTC commands supported Microsoft flow, so once working its easy to build a PowerApps mobile application to send commands to a registered device securely - and within an enterprise O365 customers operating environment and authentication/identity.

I want to showcase a video at the end how easy any O365 customer can build/publish a mobile app to control an IOT device that is registered with IOTC.

Thanks,

Jason

Cheers,

Jason

trying to build Base OS - missing parson.h file

fresh install of Ubuntu 16.04 running fresh install of iotz

Trying to build the MXChip base OS, so I can bypass the certificate validation to connect MXChip to IoT Edge. I'm following the instructions here -> https://github.com/Azure/iot-central-firmware/tree/master/MXCHIP/mxchip_advanced/build_firmware

When I do the iotz make, I get the following error about a missing parson.h file. Where does that come from and how do I get it?

stevebus@azureEdgeUbuntu1:~/mxchip/iot-central-firmware/MXCHIP/mxchip_advanced/build_firmware$ sudo iotz make
SDK_DIR=ls /root/.arduino15/packages/AZ3166/hardware/stm32f4/ | awk '{print }' &&
SDK_DIR="/root/.arduino15/packages/AZ3166/hardware/stm32f4/$SDK_DIR" &&
cp mxchip_tweak ../.iotz.mxchip.tweak &&
cd .. &&
rm -rf BUILD/build.options.json &&
rm -f $SDK_DIR/system/sdk/lib/libaz_iot.a &&
rm -rf $SDK_DIR/cores/arduino/az_iot &&
rm -rf $SDK_DIR/libraries/AzureIoT &&
ln -s pwd/build_firmware/devkit-sdk/AZ3166/src/libraries/AzureIoT $SDK_DIR/libraries/AzureIoT &&
ln -s pwd/build_firmware/devkit-sdk/AZ3166/src/cores/arduino/az_iot $SDK_DIR/cores/arduino/az_iot &&
cp pwd/build_firmware/devkit-sdk/AZ3166/src/cores/arduino/EEPROMInterface.h $SDK_DIR/cores/arduino/ &&
cp .iotz.mxchip.tweak $SDK_DIR/platform.txt &&
arduino --board 'AZ3166:stm32f4:MXCHIP_AZ3166' --verify 'iotCentral.ino' --pref build.path=BUILD &&
cp $SDK_DIR/bootloader/boot.bin /tools &&
mv BUILD/iotCentral.ino.bin BUILD/iotCentral.ino_no_bootloader.bin &&
python /tools/arduino.az3166.boot_patch.py BUILD/iotCentral.ino_no_bootloader.bin BUILD/iotCentral.ino.bin && echo "DONE!"
Picked up JAVA_TOOL_OPTIONS:
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
/root/.arduino15/packages/AZ3166/hardware/stm32f4/1.6.1/libraries/AzureIoT/src/DevKitOTAUtils.cpp:2:20: fatal error: parson.h: No such file or directory
#include "parson.h"

^
compilation terminated.
exit status 1
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 1

IoT Central Website Issues - Gateway Issues

There are times when accessing our URL for our IoT Central Dashboard it would not load and would show an error "Gateway Error" - I did not take a screenshot of it because it just comes sometimes out of no-where and would then disappear.

I am not sure if there are some issues with the servers hosting the IoT Centrals Dashboards. Please let me know if anyone has any idea or faced the same issue?

Also, sometimes it takes a long time to have the page load up... I mean about 5 mins or more at times. Very inconsistent at times.

ESP32 CMakeLists.txt

Hi,

We move our build system to use CMake with CMakeLists.txt for esp-idf (ESP32). We also have to update Azure IoT Hub SDK.

Do you planned to add the required files in Azure/iot-central-firmware to support CMake with appropriate CMakeLists.txt?

Thanks

AZ3166 Access Point Can't Connect To Network (MXCHIP)

Using latest firmware (v2.1.1) I can't for the life of me get a connection (using many other wifi devices) to the MXCHIP's Access Point, to even be able to configure it.

Keeps saying "Can't connect to this network" or "Access Denied".

Prompt on the chip's display is:
Connect HotSpot:
AZ3166_SRSDFT
go-> 192.1638.0.1
PIN CODE XXXX

IoTC python client connect exception: InvalidURL

Hi everyone,
I am using python IoTC client to push data to IOTC app. https://pypi.org/project/iotc/
Everything was working fine a month age but just discovered that all of my iotc python clients are failing with the exception listed below. Please advise if you know any workaround.

Traceback (most recent call last):
  File "2.py", line 43, in <module>
    iotc.connect()
  File "/usr/local/lib/python2.7/dist-packages/iotc/__init__.py", line 635, in connect
    content = _request(self, target.geturl(), "PUT", body, headers)
  File "/usr/local/lib/python2.7/dist-packages/iotc/__init__.py", line 277, in _request
    return _doRequest(device, target_url, method, body, headers)
  File "/usr/local/lib/python2.7/dist-packages/iotc/__init__.py", line 269, in _doRequest
    conn.request(method, socket_buffer)
  File "/usr/lib/python2.7/httplib.py", line 1073, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1107, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/lib/python2.7/httplib.py", line 960, in putrequest
    % (url, match.group()))
**httplib.InvalidURL: URL can't contain control characters. 'https://global.azure-devices-provisioning.net/0ne0008C6C6/registrations/smart1/**register?api-version=2018-11-01 HTTP/1.1\r\nHost: global.azure-devices-provisioning.net\r\ncontent-type: application/json; charset=utf-8\r\nuser-agent: iot-central-client/1.0\r\naccept: */*\r\naccept-encoding: gzip, deflate\r\nauthorization: SharedAccessSignature sr=0ne0008C6C6%2Fregistrations%2Fsmart1&sig=MbFq%2F0Cgtx70EIInc7P1fE7o46NjoIcSTeZeieufzjY%3D&se=1572506101&skn=registration\r\nContent-Length: 27\r\n\r\n{"registrationId":"smart1"}' (found at least ' ')
root@iotdev:~/SmartTable# python 2.py
Traceback (most recent call last):

iotc.isConnected() never fails.

Hi,

i have iotc running on a Raspberry Pi 3 B+.

I run into the issue, that if the Raspberry Pi is loosing Internet connection, the loop

while iotc.isConnected()

never sees that the connection was lost.

The programm keeps running and gCanSend is always true.

I tested this with an LTE Stick running the code and sending telemetry to IoT Central.
As soon as i pull the LTE Stick the mqtt messages timeout but the loop keeps on running and never fails.

Cannot build using vscode & platform.io

I cloned the repo, used eps32 src and put it in this folder structure:
grafik

Project configured as esp-idf:
grafik

Tried to build:
grafik

Processing nodemcu-32s (platform: espressif32; board: nodemcu-32s; framework: espidf)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/nodemcu-32s.html
PLATFORM: Espressif 32 > NodeMCU-32S
HARDWARE: ESP32 240MHz 320KB RAM (4MB Flash)
DEBUG: CURRENT(esp-prog) EXTERNAL(esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 0 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pioenvs\nodemcu-32s\src\azure-iot-central.o
Compiling .pioenvs\nodemcu-32s\src\components\azure_iot\azure\c-utility\adapters\agenttime.o
Compiling .pioenvs\nodemcu-32s\src\components\azure_iot\azure\c-utility\adapters\agenttime_esp8266.o
Compiling .pioenvs\nodemcu-32s\src\components\azure_iot\azure\c-utility\adapters\agenttime_mbed.o
src\components\azure_iot\azure\c-utility\adapters\agenttime.c:4:44: fatal error: azure_c_shared_utility/gballoc.h: No such file or directory
compilation terminated.
*** [.pioenvs\nodemcu-32s\src\components\azure_iot\azure\c-utility\adapters\agenttime.o] Error 1
src\components\azure_iot\azure\c-utility\adapters\agenttime_esp8266.c:4:46: fatal error: azure_c_shared_utility/agenttime.h: No such file or directory
compilation terminated.
src\components\azure_iot\azure\c-utility\adapters\agenttime_mbed.c:4:46: fatal error: azure_c_shared_utility/agenttime.h: No such file or directory
compilation terminated.
*** [.pioenvs\nodemcu-32s\src\components\azure_iot\azure\c-utility\adapters\agenttime_esp8266.o] Error 1
*** [.pioenvs\nodemcu-32s\src\components\azure_iot\azure\c-utility\adapters\agenttime_mbed.o] Error 1
==================================================================================== [ERROR] Took 14.52 seconds ====================================================================================

Where is the Connection String in Iot Central

Hi, I have installed latest version of Iot Central, Dev Kit. Created a Raspberry PI Real Device.

If I go to connection I see the primary/secondary key and a scopeid, but not the full connection string that I need to configure the firmware I downlaoded from main branch of GitHub.

I have also seen that under /release there is an new one zip package that requires the scopeID as parameter in main.py file, but if I use that I get an error: Line 492 Fail retriving data from the provisioning service

Connection error when trying to connect to iot central using sample devkits template

Hi!

I'm following this guide: https://docs.microsoft.com/en-us/azure/iot-central/howto-connect-raspberry-pi-python

I'm using a Raspberry Pi 2 with 2018-04-18-raspbian-stretch-lite with window-manager installed.

Fixes i had to do in order to run the sample:

I had to install pygame:
sudo pip3 install pygame
I received an error "error while loading shared libraries: libSDL-1.2.so.0:" which was fixed with:
sudo apt-get install --reinstall libsdl1.2debian
I received an error for missing Gtk, which was fixed with:
sudo apt-get install libgtk-3-dev

After these fixes, i was able to run start.sh, and configure the device using the webpage.
I used the "Sample Devkits" template as stated in the guide, and used the "Primary connection string" found in "connect this device".

This is the error i have now:

pi@raspberrypi:~/Downloads/iot-central-firmware-master/RaspberryPi $ sudo ./start.sh
/usr/lib/python3/dist-packages/sense_emu/sense_hat.py:90: Warning: No emulator detected; spawning sense_emu_gui
warnings.warn(Warning('No emulator detected; spawning sense_emu_gui'))
Info: IoT Hub SDK for C, version 1.1.24

Press ctrl-c to stop the process
Device information being serving at http://<censored>:8080

Error: Time:Wed May 16 08:39:14 2018 File:/home/pi/github/azure-iot-sdk-python/c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:696 Failure: connect failure 111.

Info: Closing tlsio from a state other than TLSIO_STATE_EXT_OPEN or TLSIO_STATE_EXT_ERROR

Error: Time:Wed May 16 08:39:14 2018 File:/home/pi/github/azure-iot-sdk-python/c/c-utility/src/tlsio_openssl.c Func:on_underlying_io_open_complete Line:688 Invalid tlsio_state. Expected state is TLSIO_STATE_OPENING_UNDERLYING_IO.

Error: Time:Wed May 16 08:39:14 2018 File:/home/pi/github/azure-iot-sdk-python/c/c-utility/src/tlsio_openssl.c Func:tlsio_openssl_open Line:1202 Failed opening the underlying I/O.

Error: Time:Wed May 16 08:39:14 2018 File:/home/pi/github/azure-iot-sdk-python/c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:971 Error: io_open failed

Error: Time:Wed May 16 08:39:14 2018 File:/home/pi/github/azure-iot-sdk-python/c/iothub_client/src/iothubtransport_mqtt_common.c Func:SendMqttConnectMsg Line:1660 failure connecting to address saas-iothub-<censored>.azure-devices.net.

Error: Time:Wed May 16 08:39:14 2018 File:/home/pi/github/azure-iot-sdk-python/c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:696 Failure: connect failure 111.

While these errors are going on, the "Sense HAT Emulator" is running.

Please advice.

azure iot central firmware error rbpi2

[ESP32] deviceTwinGetStateCallback triggers LoadProhibitedError when device receive settings from IoT Central

I am trying the ESP32 firmware and I noticed a bug that triggered LoadProhibitedError which then reboot the ESP32 whenever the device receives setting from Azure IoT Central.

Here's the payload of the setting

{
  "desired": {
    "toggle_led": {
      "value": false
    },
    "$version": 5
  },
  "reported": {
    "toggle_led": {
      "value": 0,
      "statusCode": 200,
      "status": "completed",
      "desiredVersion": 5
    },
    "$version": 5
  }
}

The code that triggers LoadProhibitedError is

if (containsKey && strcmp(desiredVersion, version) == 0) {

See this code

const char * version = NULL, * desiredVersion = NULL,
* value = NULL, * desiredValue = NULL;
bool containsKey = reported.getObjectByName(itemName, &keyObject);
if (containsKey) {
desiredVersion = reported.getStringByName("desiredVersion");
version = desired.getStringByName("$version");
desiredValue = reported.getStringByName("desiredValue");
value = desired.getStringByName("value");
}

desiredVersion, version, desiredValue, and value are initially null and will always be null in my case because the value of these keys is not a string.

The workaround for avoiding the LoadProhibitedError is adding a check to desiredVersion and version to line 419.

if (containsKey && desiredVersion && version && strcmp(desiredVersion, version) == 0) {

This workaround also can be applied to line 421 by checking desiredValue and value instead of desiredVersion and version.

} else if (containsKey && desiredvalue && value && strcmp(desiredValue, value) != 0){

Or we can change the type of desiredVersion and version to double and use getNumberByName instead of getStringByName, so we can change the line 419 to the following line:

if (containsKey && desiredVersion == version) {

But there is another issue with the type of desiredValue and value. The existing code only handles the case where the type of the value of these variables is a string. The value could be boolean, string, or number.

ESP32 Compile Error

Getting the following error when running make flash on ESP32. Tried on two different computers and build stops at same place.

AR build/lwip/liblwip.a
make[1]: *** No rule to make target 'iotc/iotc.o', needed by 'libmain.a'.  Stop.
/home/kx5i/esp/esp-idf/make/project.mk:468: recipe for target 'component-main-build' failed
make: *** [component-main-build] Error 2

Only the iotc.h files is copied to the main/iotc directory. I copied the other folders and files there from ~/esp/iot-central-firmware/MXCHIP/mxchip_basic/src/iotc/ to main/iotc and it did not make a difference.

IrDa send information

Hi
I'm checking the IRremote library for arduino but doesn't work with the az3166; also I'm checking the documentation (https://microsoft.github.io/azure-iot-developer-kit/docs/apis/irda/) but I don't know how to send a infrared command with *char .

For example in arudino with IRremote is like this

irsend.sendNEC(0xFFE896, 32);

how i send in AZ?

unsigned char powerOn2 = 0xFFE896;
IRDASensor *IrdaSensor;
setup(){
IrdaSensor = new IRDASensor();
IrdaSensor->init();
}
loop() {
int irda_status = IrdaSensor->IRDATransmit(&powerOn, 1, 100 );
if(irda_status != 0)
{
Serial.println("Unable to transmit through IRDA");
}
}

But I don't know if the protocol is ok? Because doesn't work.

after coping program.bin int AZ3166 via USB and enter AP can't find /START page

I've copied program.bin into my AZ3166, and after reboot I've entered AP mode, connected with my PC to http://192.168.0.1/start and i got error page with says start page is not found,
are you sure you've burn the image along with the iot central application?
if i go to the root at http://192.168.0.1 i get the standard WiFi config without iot hub connection string and sensors.

I've also confirmed it by configuring IoT Hub connection string via Putty, i'v got the app with 3 counters:

-- Connected --
sent:xx
fail:xx
twin:xx/xx

Latest firmware does not show PIN

I've been trying to install the latest firmware:
MXChip AZ3166 sample firmware v.3.0.0-beta.2

But I've not been able to find the device PIN to complete the setup. Is this a known issue?

Connection string/telemetry data fields not found on device config page

I have been running through the docs for setting up the MXChip (https://docs.microsoft.com/en-us/azure/iot-central/howto-connect-devkit), and step 7 shows that I should be able to navigate to 192.168.0.1/start in order to set up the connection string and telemetry data. I'm having two issues here:

  1. The start page is not found (/start), but it looks like a recent commit moved the HTML into httpHtmlData.h
  2. On the home page, all I am seeing is text fields for WiFi network and password, and no fields for connection string and telemetry data as is detailed in the docs.

Am I doing something wrong here? Are the docs out of date? Would love any assistance. Thanks!

ESP8266 Settings is not picked up directly after restart of device

I sent setting values to my ESP8266 with the latest sketch.

this was done with a device which was running and connected to the Arduino DE but not connected to the WIFI.

Afterward, when deploying the same sketch with update WIFI settings, the settings are still not sent. The Update button is grayed out and the labels are not showing a new latest update time.

I expect the ESP to check for settings once right after successfully connecting to IoT Central with correct WIFI settings.

Error: control reaches end of non-void function [-Werror,-Wreturn-type]

Hi all, this is the issue:
I am trying to compile MBED OS of the IoT-Central Firmware with the MBED Studio v.0.5.3 . This project is for the UBLOX_C030_R410M so I have added the easy connect library made specifically from UBLOX. I have modified the mbed_app.json file to use ETHERNET.

The compiler gave this error at 99.2%.

Compile [ 99.2%]: iotc_common.cpp

[ERROR] In file included from .\src\iotc\common\iotc_common.cpp:4:

In file included from .\src\iotc\common/iotc_internal.h:7:

In file included from .\src\iotc\common/iotc_platform.h:46:

.\src\iotc\common/../mbed_os/mbed_tls_client.h:32:36: error: control reaches end of non-void function [-Werror,-Wreturn-type]

int println() { print("\r\n"); }

^

.\src\iotc\common/../mbed_os/mbed_tls_client.h:33:65: error: control reaches end of non-void function [-Werror,-Wreturn-type]

int println(const char* buffer) { print(buffer); println(); }

^

2 errors generated.

Thank you in advance.

Esp8266 C code message code update

Hi!
Current code for esp8266 send two messages with different telemetry (accelerometer X and DieNumber)
if (loopId++ % 2 == 0) { // send telemetry pos = snprintf(msg, sizeof(msg) - 1, "{\"accelerometerX\": %d}", 10 + (rand() % 20)); errorCode = iotc_send_telemetry(context, msg, pos); } else { // send property pos = snprintf(msg, sizeof(msg) - 1, "{\"dieNumber\":%d}", 1 + (rand() % 5)); errorCode = iotc_send_property(context, msg, pos); }

How to combine both messages in one to avoid messages limit drain faster 2 times (50k/device/month)?

8266 DPS endpoint PUT call has failed.

Hi ALL, i got the wifi connected. I am using nodemcu, entered the right information.

However, the below error I got, I double checked the scopeId, deviceId, deviceKey already. Are there any problem on it? Thanks!

⸮Hp⸮⸮>dh⸮⸮�xI�<⸮ - Connecting WiFi..

  • iotc.dps : getting auth...
  • iotc.dps : getting operation id...
    ERROR: DPS endpoint PUT call has failed.
    X - Error at C:\Users\Ken Lai\Downloads\iot-central-firmware-master\iot-central-firmware-master\ESP8266\esp8266_arduino\esp8266_arduino.ino:70
    Error @ iotc_connect. Code 1

Regards,
Ken

Error when connecting to WiFi (after setup) (AZ3166)

Hi there I have exactly the same problem. From the videos and instructions connecting to azure iot hub seemed to be very easy but I am stuck getting the mxchip connected to my wifi. It always says 'WiFi Connecting...'
I have the plan to connect to an iphone (tethering) and in fact the phones says there is one connection but the chip is continiously trying to connect and every 60 seconds the displays shows 'Starting press a and b button or hard reset ...'. Can you give some further idea what to do now

Originally posted by @sgazinski in #33 (comment)

c client for l476RG iothub

I've been struggling to make azure iot c sdk work with my l476rg. No luck. Found iotc client here and confirmed that it fits into my l476RG with 128kb.

I played the sample application scenario and tested with azure iot central. What I'm supposed to do for iothub only? Is iotc expected to work with azure iothub only?

Corrupted Heap

I just followed all the instructions for the ESP32 example and got everything set up, make flash completed successfully, make monitor looks like it works for a few seconds with successful connect and transmit but the ESP32 resets on what looks like a transmit confirmation:

I (3755) azure: Connected to AP success!
Initializing SNTP
ESP platform sntp inited!
I (3755) platform: The current date/time in Shanghai is: Mon Jul 29 18:10:13 2019
  - - IOTC: Registration status: CONNECTED
  - - IOTC: Registration status: ASSIGNING
  - - IOTC: Registration status: ASSIGNING
  - ConnectionString: HostName=x.azure-devices.net;DeviceId=x;SharedAccessKey=x
  - Is connected ? YES (64)
  - - [ConnectionStatus] event was received. Payload => None
  - SENT => {"T": 18}
  - - [MessageSent] event was received. Payload => {"T": 18}-�?�-�?
CORRUPT HEAP: multi_heap.c:432 detected at 0x3ffd36c4
abort() was called at PC 0x4008990f on core 0
0x4008990f: multi_heap_assert at /home/ben/esp/esp-idf/components/heap/multi_heap.c:380

The only thing I changed was 'temp' to 'T' in the message payload but even after reverting I get the same result

Be more clear on steps and output of start.sh during initial setup with X509

I think it should be more clear here what outputs you get during initial setup procedure for X509 certificates.
After ./start.sh first time execution the device is created in IOT Central but the command says DEV_AUTH_ERROR which makes me think something went wrong.
The documentation should state this or the command should be more user friendly in its response and informative.
You should then stop and restart the command when you set a template for the device in IOT Central. Then the second execution of command succeeds.
Another issue is that the private leaf certificate for the device is actually hard coded in the test firmware. I get confused and was trying to find a way to upload the leaf certificate, generated by the command line tool, to the Raspberry PI. But you don't need it in this test scenario and test firmware. This should as well be more clear.

HTTP Bash: Unterminated string. Expected delimiter.

While using provided bash script I'm getting this error:

undefined:1
{"errorCode":400012,"trackingId":"fa7462e6-0a2f-4316-bc69-56272819ba02","message":"Unterminated string. Expected delimiter: ". Path 'registrationId', line 1, position 25.","timestampUtc":"2019-07-02T14:18:27.8155458Z"}
                                                                                                                             

SyntaxError: Unexpected token . in JSON at position 125
    at JSON.parse (<anonymous>)
    at [eval]:1:8
    at Script.runInThisContext (vm.js:122:20)
    at Object.runInThisContext (vm.js:329:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at evalScript (internal/bootstrap/node.js:589:27)
    at startup (internal/bootstrap/node.js:265:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

This is code that I exactly have:

OUT=$(curl -s \
  -H "authorization: ${AUTH}&skn=registration" \
  -H 'content-type: application/json; charset=utf-8' \
  -H 'content-length: 25' \
  -X PUT -d "{\"registrationId\":\"$DEVICE_ID\"}" \
  "https://global.azure-devices-provisioning.net/$SCOPEID/registrations/$DEVICE_ID/register?api-version=2018-11-01")

What's wrong with registrationId here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.