Skip to content

Commit

Permalink
change external id to 'HMS-Talk2M-<Ewon_id>'
Browse files Browse the repository at this point in the history
  • Loading branch information
yhegen committed Jan 21, 2022
1 parent afb9f5b commit 666a846
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/constants/flexy-integration.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const FLEXY_DATAMAILBOX_PATH = 'datamailbox';

export const FLEXY_TENANTOPTIONS_CATEGORY = 'flexy';

export const FLEXY_SERIALTYPE = 'flexy_id';
export const FLEXY_EXTERNALID_PREFIX = 'flexy_';
export const FLEXY_SERIALTYPE = 'talk2m_id';
export const FLEXY_EXTERNALID_PREFIX = 'HMS-Talk2M-';
export const FLEXY_DEVICETYPE = 'c8y_EwonFlexy';

export const TALK2M_BASEURL = 'https://m2web.talk2m.com/t2mapi';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,24 @@ export class BulkRegistrationComponent implements OnInit {

private async registerDevice(item: number) {
const ewon: EwonFlexyStructure = this.rows.find(element => element.id == item);
const externalId = ewon.id.toString();
const ewonId = ewon.id.toString();

if (ewon.registered !== FlexyIntegrated.Not_integrated) {
this.alert.info("Device with externalId '" + externalId + "' is already registered.");
this.alert.info("Device with ewonId '" + ewonId + "' is already registered.");
return;
}

console.log("Start registering device externalId = " + externalId);
console.log("Start registering device ewonId = " + ewonId);
// 1. Create device request if not exists
console.log("existing requests = ", this.existingRequests);
const existingRequest = this.existingRequests.find(element => element.id == FLEXY_EXTERNALID_PREFIX+externalId);
const existingRequest = this.existingRequests.find(element => element.id == FLEXY_EXTERNALID_PREFIX+ewonId);
if (!existingRequest){
console.log("create device request with external id = ", externalId)
const registration = await this.flexyRegistration.createDeviceRequestRegistration(externalId);
console.log(externalId + ' createDeviceRequestRegistration: ', registration);
console.log("create device request with external id = ", ewonId)
const registration = await this.flexyRegistration.createDeviceRequestRegistration(ewonId);
console.log(ewonId + ' createDeviceRequestRegistration: ', registration);
// 1.1 Bootstraps the device credentials
try {
await this.flexyRegistration.requestDeviceCredentials(externalId);
await this.flexyRegistration.requestDeviceCredentials(ewonId);
// return in case we are actually able to retrieve the credentials
return;
} catch (error) {
Expand All @@ -179,9 +179,9 @@ export class BulkRegistrationComponent implements OnInit {
}
console.log("Credentials for device are not available. Device is in state PENDING_ACCEPTANCE, (not ACCEPTED)).");
// 1.2 Change status to acceptance
await this.flexyRegistration.acceptDeviceRequest(externalId);
await this.flexyRegistration.acceptDeviceRequest(ewonId);
}else{
console.log("Request for device already exists. externalId = ", externalId);
console.log("Request for device already exists. ewonId = ", ewonId);
}
// 2. Create inventoty managed object
const deviceInventoryObj = await this.flexyRegistration.createDeviceInventory(ewon).catch((error) => {
Expand All @@ -190,7 +190,7 @@ export class BulkRegistrationComponent implements OnInit {
});
console.log("created inventory: ", deviceInventoryObj);
// 3. Assign externalId to inventory
const identityObj = await this.flexyRegistration.createIdentidyForDevice(deviceInventoryObj.id, externalId);
const identityObj = await this.flexyRegistration.createIdentidyForDevice(deviceInventoryObj.id, ewonId);
// 4. Assign group to inventory
if (ewon.pool && this.poolGroupList.has(ewon.pool)){
console.log("List of groups:", this.poolGroupList);
Expand Down

0 comments on commit 666a846

Please sign in to comment.