How to upload code to my device and agent


#1

Hi
How do i upload code to the device(s) and agent(s) in my application work space. What is the equivalent of a device group in the new imp central ide?

Thanks.
Rama.


#2

I assume you are very new to the Imp?

Have you been able to do the blink-up successfully?

When you log into the IDE can you see the imp anywhere?
It won’t have a project assigned yet, but it should appear.


#3

I Just work on and off. I have blinked up before. i can see my devices in the new imp central env. I used the Build api before to upload content, and i am trying to figure out how to upload code to the agent and device.

After getting the access token ( was able to do that), do i need to give username, password with every request i make?

Thanks.


#4

I am very new to imp Central. I am trying to figure out javascript i need to put together to upload code to agent and device which i make changes in this new environment.


#5

For that, you’d use the v5 API. Docs are here: https://preview-apidoc.electricimp.com/


#6

As @hugo says, you’ll need the API. Workspaces only exist in the impCentral IDE; with the API you upload to development devicegroups. Each workspace combines a development devicegroup with other functionality (including the code editor), which is why they have a different name.


#7

I am able to fetch the device group using the accesstoken, in the documentation section ‘UpdateDeviceGroup’ section i do not see how the code files (nut files) are specified for the agent and device in the data section of JSON for UpdateDeviceGroup.


#8

To upload code to a device group, you create a new deployment object — its attributes key is an object which includes the keys device_code and agent_code whose values are the code you want to upload to the device group. You specify the target device group by settings its ID as the value of the deployment’s relationships/devicegroup/id key:

deployment = {
   "attributes": {
      "device_code": "your device code",
      "agent_code": "your agent code" },
   "relationships": {
       "devicegroup": {
          "id": "your device group id" }
   }
}

Note this only shows the relevant keys — there are others. See the API docs.


#9

You should check out How to Use the impCentral API which covers access to the API and cross-resource API functionality, and the impCentral API Primer, which covers each resource type — product, device group, device, deployment, etc. — in detail.


#10

I’ve added a page of sample code here.


#11

I’ve just added a further example: device logging